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