fix
This commit is contained in:
parent
dcb7e6b0da
commit
2f1472e0c7
|
|
@ -73,6 +73,8 @@ android {
|
|||
buildTypes {
|
||||
release {
|
||||
signingConfig signingConfigs.release
|
||||
minifyEnabled false
|
||||
shrinkResources false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:android_intent_plus/android_intent.dart';
|
||||
import 'package:awesome_notifications/awesome_notifications.dart';
|
||||
import 'package:bot_toast/bot_toast.dart';
|
||||
import 'package:didvan/config/theme_data.dart';
|
||||
import 'package:didvan/firebase_options.dart';
|
||||
|
|
@ -33,16 +34,20 @@ final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
|||
|
||||
@pragma('vm:entry-point')
|
||||
Future _initPushNotification(RemoteMessage message) async {
|
||||
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
||||
if (kDebugMode) {
|
||||
print("background: ${NotificationData.fromJson(message.data).toJson()}");
|
||||
if (!kIsWeb) {
|
||||
await NotificationService.initializeNotification();
|
||||
}
|
||||
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
||||
// if (kDebugMode) {
|
||||
print("background: ${NotificationData.fromJson(message.data).toJson()}");
|
||||
// }
|
||||
try {
|
||||
NotificationService.showFirebaseNotification(message);
|
||||
NotificationService.startListeningNotificationEvents();
|
||||
} catch (e) {
|
||||
if (kDebugMode) {
|
||||
// if (kDebugMode) {
|
||||
print(e);
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -98,6 +103,7 @@ class _DidvanState extends State<Didvan> with WidgetsBindingObserver {
|
|||
NotificationService.startListeningNotificationEvents();
|
||||
}
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
NotificationService.startListeningNotificationEvents();
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:didvan/models/notification_message.dart';
|
||||
import 'package:didvan/services/app_initalizer.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:home_widget/home_widget.dart';
|
||||
import 'package:persian_number_utility/persian_number_utility.dart';
|
||||
|
|
@ -226,7 +227,10 @@ class HomeWidgetRepository {
|
|||
}
|
||||
if (route.isNotEmpty) {
|
||||
navigatorKey.currentState!.pushNamed(route, arguments: args);
|
||||
print("Push: $route");
|
||||
}
|
||||
print("Push: empty");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,13 +13,15 @@ import 'package:flutter/foundation.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
enum LaunchMode { inAppWebView }
|
||||
|
||||
void openInWebView(String src, {dynamic mode}) {
|
||||
void openInWebView(String src, {dynamic mode}) async {
|
||||
if (kIsWeb) {
|
||||
launchUrlString(src);
|
||||
if (!await launchUrl(Uri.parse(src))) {
|
||||
throw Exception('Could not launch $src');
|
||||
}
|
||||
return;
|
||||
}
|
||||
navigatorKey.currentState!.pushNamed(Routes.web, arguments: src);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
import 'package:awesome_notifications/awesome_notifications.dart';
|
||||
import 'package:didvan/models/notification_data.dart';
|
||||
import 'package:didvan/models/notification_message.dart';
|
||||
import 'package:didvan/services/app_home_widget/home_widget_repository.dart';
|
||||
import 'package:didvan/services/app_initalizer.dart';
|
||||
import 'package:didvan/services/notification/notification_service.dart';
|
||||
import 'package:didvan/services/storage/storage.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
|
@ -28,7 +33,10 @@ class FirebaseApi {
|
|||
sound: true,
|
||||
);
|
||||
|
||||
FirebaseMessaging.instance.getInitialMessage();
|
||||
FirebaseMessaging.instance
|
||||
.getInitialMessage()
|
||||
.asStream()
|
||||
.listen((event) async {});
|
||||
FirebaseMessaging.onMessageOpenedApp.listen((event) {});
|
||||
FirebaseMessaging.onMessage.listen((event) => handleMessage(event));
|
||||
}
|
||||
|
|
@ -36,13 +44,13 @@ class FirebaseApi {
|
|||
void handleMessage(RemoteMessage? message) async {
|
||||
if (message == null) return;
|
||||
//do ever you want with message
|
||||
if (kDebugMode) {
|
||||
// if (kDebugMode) {
|
||||
print("forground: ${NotificationData.fromJson(message.data).toJson()}");
|
||||
}
|
||||
// }
|
||||
try {
|
||||
await NotificationService.showFirebaseNotification(message);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
e.printError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ class NotificationService {
|
|||
NotificationMessage data =
|
||||
NotificationMessage.fromJson(receivedAction.payload!);
|
||||
HomeWidgetRepository.data = data;
|
||||
print("data: ${HomeWidgetRepository.data}");
|
||||
await HomeWidgetRepository.decideWhereToGoNotif();
|
||||
await StorageService.delete(
|
||||
key: 'notification${AppInitializer.createNotificationId(data)}');
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import 'package:didvan/views/ai/history_ai_chat_state.dart';
|
|||
import 'package:didvan/views/home/home.dart';
|
||||
import 'package:didvan/views/widgets/didvan/text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class Ai extends StatefulWidget {
|
||||
|
|
@ -53,9 +54,16 @@ class _AiState extends State<Ai> {
|
|||
);
|
||||
}
|
||||
final bot = state.bot!;
|
||||
return Stack(
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Column(
|
||||
Expanded(
|
||||
child: Stack(
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 24),
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
|
|
@ -74,7 +82,8 @@ class _AiState extends State<Ai> {
|
|||
),
|
||||
InkWell(
|
||||
onTap: () => ActionSheetUtils(context)
|
||||
.botsDialogSelect(context: context, state: state),
|
||||
.botsDialogSelect(
|
||||
context: context, state: state),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
|
|
@ -105,7 +114,8 @@ class _AiState extends State<Ai> {
|
|||
height: 24,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
child: Text(
|
||||
"به هوشان, هوش مصنوعی دیدوان خوش آمدید. \nبرای شروع گفتگو پیام مورد نظر خود را در کادر زیر بنویسید.\n دریافت پاسخ از: ${bot.name}",
|
||||
textAlign: TextAlign.center,
|
||||
|
|
@ -113,10 +123,33 @@ class _AiState extends State<Ai> {
|
|||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 32,
|
||||
left: 20,
|
||||
right: 20,
|
||||
top: 32,
|
||||
right: 0,
|
||||
child: InkWell(
|
||||
onTap: () => homeScaffKey.currentState!.openDrawer(),
|
||||
child: Container(
|
||||
width: 46,
|
||||
height: 46,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(12),
|
||||
bottomLeft: Radius.circular(12)),
|
||||
boxShadow: DesignConfig.defaultShadow),
|
||||
child: Icon(
|
||||
DidvanIcons.angle_left_light,
|
||||
color: Theme.of(context).colorScheme.title,
|
||||
),
|
||||
)),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(20, 0, 20, 32),
|
||||
child: InkWell(
|
||||
onTap: () => Navigator.of(context).pushNamed(Routes.aiChat,
|
||||
arguments: AiChatArgs(
|
||||
|
|
@ -161,26 +194,6 @@ class _AiState extends State<Ai> {
|
|||
),
|
||||
)),
|
||||
),
|
||||
Positioned(
|
||||
top: 32,
|
||||
right: 0,
|
||||
child: InkWell(
|
||||
onTap: () => homeScaffKey.currentState!.openDrawer(),
|
||||
child: Container(
|
||||
width: 46,
|
||||
height: 46,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(12),
|
||||
bottomLeft: Radius.circular(12)),
|
||||
boxShadow: DesignConfig.defaultShadow),
|
||||
child: Icon(
|
||||
DidvanIcons.angle_left_light,
|
||||
color: Theme.of(context).colorScheme.title,
|
||||
),
|
||||
)),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -156,7 +156,8 @@ class _TypingState extends State<_Typing> {
|
|||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
hintText: 'بنویسید یا پیام صوتی بگذارید...',
|
||||
hintText:
|
||||
kIsWeb ? 'بنویسید...' : 'بنویسید یا پیام صوتی بگذارید...',
|
||||
hintStyle: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: Theme.of(context).colorScheme.disabledText),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ class CategoriesPage extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
DidvanText(
|
||||
|
|
@ -19,6 +20,7 @@ class CategoriesPage extends StatelessWidget {
|
|||
const MainCategories(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import 'package:flutter/cupertino.dart';
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../services/app_home_widget/home_widget_repository.dart';
|
||||
|
||||
|
|
@ -320,9 +321,21 @@ class _HomeState extends State<Home>
|
|||
? Padding(
|
||||
padding:
|
||||
const EdgeInsets.all(12.0),
|
||||
child: EmptyState(
|
||||
asset: Assets.emptyResult,
|
||||
title: 'لیست خالی است',
|
||||
child: Column(
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Assets.emptyResult,
|
||||
height: MediaQuery.sizeOf(
|
||||
context)
|
||||
.height /
|
||||
10,
|
||||
),
|
||||
const DidvanText(
|
||||
'لیست خالی است',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
: state.loadingdeleteAll ||
|
||||
|
|
@ -450,6 +463,9 @@ class _HomeState extends State<Home>
|
|||
body: WillPopScope(
|
||||
onWillPop: () async {
|
||||
if (context.read<HomeState>().tabController.index == 0) {
|
||||
if (kIsWeb) {
|
||||
return true;
|
||||
}
|
||||
ActionSheetUtils(context).openDialog(
|
||||
data: ActionSheetData(
|
||||
content: const DidvanText(
|
||||
|
|
|
|||
Loading…
Reference in New Issue