2020-09-06 02:36:57 +06:30
|
|
|
import 'dart:io';
|
|
|
|
|
|
2020-09-07 00:47:02 +06:30
|
|
|
import 'package:fcs/fcs/common/helpers/theme.dart';
|
2020-09-04 15:30:10 +06:30
|
|
|
import 'package:fcs/fcs/common/localization/app_translations_delegate.dart';
|
|
|
|
|
import 'package:fcs/fcs/common/localization/transalation.dart';
|
2020-09-07 16:05:28 +06:30
|
|
|
import 'package:fcs/fcs/common/pages/contact/model/contact_model.dart';
|
2020-09-04 15:30:10 +06:30
|
|
|
import 'package:fcs/fcs/common/pages/model/language_model.dart';
|
2020-09-07 16:05:28 +06:30
|
|
|
import 'package:fcs/fcs/common/pages/term/model/term_model.dart';
|
2020-09-06 02:36:57 +06:30
|
|
|
import 'package:fcs/fcs/common/services/services.dart';
|
2020-05-29 07:45:27 +06:30
|
|
|
import 'package:fcs/model/buyer_model.dart';
|
|
|
|
|
import 'package:fcs/model/delivery_model.dart';
|
2020-08-30 21:26:37 +06:30
|
|
|
import 'package:fcs/model/discount_model.dart';
|
2020-05-29 07:45:27 +06:30
|
|
|
import 'package:fcs/model/manual_model.dart';
|
|
|
|
|
import 'package:fcs/model/notification_model.dart';
|
|
|
|
|
import 'package:fcs/model/pd_model.dart';
|
|
|
|
|
import 'package:fcs/model/reg_model.dart';
|
|
|
|
|
import 'package:fcs/model/report_model.dart';
|
2020-08-30 21:26:37 +06:30
|
|
|
import 'package:fcs/model/shipment_model.dart';
|
2020-05-29 07:45:27 +06:30
|
|
|
import 'package:fcs/model/storage_model.dart';
|
|
|
|
|
import 'package:fcs/model/test_model.dart';
|
2020-08-30 21:26:37 +06:30
|
|
|
import 'package:fcs/model_fcs/message_model.dart';
|
|
|
|
|
import 'package:fcs/model_fcs/package_model.dart';
|
2020-05-29 07:45:27 +06:30
|
|
|
import 'package:fcs/pages/email_page.dart';
|
|
|
|
|
import 'package:fcs/pages/login_page.dart';
|
2020-09-07 00:47:02 +06:30
|
|
|
import 'package:flutter/cupertino.dart';
|
2020-08-30 21:26:37 +06:30
|
|
|
import 'package:flutter/material.dart';
|
2020-09-06 02:36:57 +06:30
|
|
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
2020-08-30 21:26:37 +06:30
|
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
2020-09-04 01:42:58 +06:30
|
|
|
import 'package:fcs/fcs/common/pages/model/main_model.dart' as fcs;
|
2020-05-29 07:45:27 +06:30
|
|
|
|
|
|
|
|
import 'model/announcement_model.dart';
|
|
|
|
|
import 'model/chart_model.dart';
|
2020-06-02 14:52:31 +06:30
|
|
|
import 'model/customer_model.dart';
|
2020-05-29 07:45:27 +06:30
|
|
|
import 'model/device_model.dart';
|
|
|
|
|
import 'model/do_model.dart';
|
|
|
|
|
import 'model/employee_model.dart';
|
2020-06-02 14:56:51 +06:30
|
|
|
import 'model/invoice_model.dart';
|
2020-05-29 07:45:27 +06:30
|
|
|
import 'model/log_model.dart';
|
|
|
|
|
import 'model/main_model.dart';
|
2020-05-29 15:54:26 +06:30
|
|
|
import 'model/pickup_model.dart';
|
2020-05-29 07:45:27 +06:30
|
|
|
import 'model/po_model.dart';
|
|
|
|
|
import 'model/product_model.dart';
|
|
|
|
|
import 'model/report_user_model.dart';
|
2020-05-29 15:54:26 +06:30
|
|
|
import 'model/shipment_rate_model.dart';
|
2020-05-29 07:45:27 +06:30
|
|
|
import 'model/user_model.dart';
|
2020-06-04 01:36:49 +06:30
|
|
|
import 'model_fcs/box_model.dart';
|
2020-08-30 21:26:37 +06:30
|
|
|
import 'fcs/common/pages/home_page.dart';
|
|
|
|
|
import 'fcs/common/pages/welcome_page.dart';
|
|
|
|
|
import 'fcs/common/pages/splash_page.dart';
|
2020-05-29 07:45:27 +06:30
|
|
|
import 'pages/term.dart';
|
|
|
|
|
|
|
|
|
|
class App extends StatefulWidget {
|
|
|
|
|
@override
|
|
|
|
|
_AppState createState() => _AppState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _AppState extends State<App> {
|
2020-09-04 01:42:58 +06:30
|
|
|
final fcs.MainModel mainModel2 = new fcs.MainModel();
|
2020-09-07 16:05:28 +06:30
|
|
|
final ContactModel contactModel =new ContactModel();
|
|
|
|
|
final TermModel termModel=new TermModel();
|
2020-05-29 07:45:27 +06:30
|
|
|
final MainModel mainModel = new MainModel();
|
2020-09-07 16:05:28 +06:30
|
|
|
|
2020-05-29 07:45:27 +06:30
|
|
|
final UserModel userModel = new UserModel();
|
|
|
|
|
final ProductModel productModel = new ProductModel();
|
|
|
|
|
final EmployeeModel employeeModel = new EmployeeModel();
|
|
|
|
|
final POSubmissionModel poSubmissionModel = new POSubmissionModel();
|
|
|
|
|
final DOModel doModel = new DOModel();
|
|
|
|
|
final LanguageModel lanuguageModel = new LanguageModel();
|
|
|
|
|
final StorageModel storageModel = new StorageModel();
|
|
|
|
|
final PDModel pdModel = new PDModel();
|
|
|
|
|
final RegModel regModel = new RegModel();
|
|
|
|
|
final BuyerModel buyerModel = new BuyerModel();
|
|
|
|
|
final NotificationModel notificationModel = new NotificationModel();
|
|
|
|
|
final ChartModel chartModel = new ChartModel();
|
|
|
|
|
final DeliveryModel deliveryModel = new DeliveryModel();
|
|
|
|
|
final ManualModel manualModel = new ManualModel();
|
|
|
|
|
final TestModel testModel = new TestModel();
|
|
|
|
|
final LogModel logModel = new LogModel();
|
|
|
|
|
final PhoneDeviceModel phoneDeviceModel = new PhoneDeviceModel();
|
|
|
|
|
final ReportModel reportModel = new ReportModel();
|
|
|
|
|
final AnnouncementModel announcementModel = new AnnouncementModel();
|
|
|
|
|
final ReportUserModel reportUserModel = new ReportUserModel();
|
2020-05-29 15:54:26 +06:30
|
|
|
final PickUpModel pickUpModel = new PickUpModel();
|
|
|
|
|
final ShipmentRateModel shipmentRateModel = new ShipmentRateModel();
|
2020-06-01 14:24:45 +06:30
|
|
|
final ShipmentModel shipmentModel = new ShipmentModel();
|
2020-06-24 16:06:40 +06:30
|
|
|
final PackageModel packageModel = new PackageModel();
|
|
|
|
|
final BoxModel boxModel = new BoxModel();
|
|
|
|
|
final MessageModel messageModel = new MessageModel();
|
2020-06-02 14:56:51 +06:30
|
|
|
final InvoiceModel invoiceModel = new InvoiceModel();
|
2020-06-02 14:52:31 +06:30
|
|
|
final CustomerModel customerModel = new CustomerModel();
|
2020-06-26 16:04:40 +06:30
|
|
|
final DiscountModel discountModel = new DiscountModel();
|
2020-05-29 07:45:27 +06:30
|
|
|
|
|
|
|
|
AppTranslationsDelegate _newLocaleDelegate;
|
2020-09-06 02:36:57 +06:30
|
|
|
static FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin =
|
|
|
|
|
FlutterLocalNotificationsPlugin();
|
2020-05-29 07:45:27 +06:30
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
2020-09-04 01:42:58 +06:30
|
|
|
mainModel2.init();
|
2020-05-29 07:45:27 +06:30
|
|
|
_newLocaleDelegate = AppTranslationsDelegate(newLocale: null);
|
|
|
|
|
Translation().onLocaleChanged = onLocaleChange;
|
|
|
|
|
mainModel
|
|
|
|
|
..addModel(userModel)
|
|
|
|
|
..addModel(employeeModel)
|
|
|
|
|
..addModel(storageModel)
|
|
|
|
|
..addModel(regModel)
|
|
|
|
|
..addModel(poSubmissionModel)
|
|
|
|
|
..addModel(doModel)
|
|
|
|
|
..addModel(productModel)
|
|
|
|
|
..addModel(pdModel)
|
|
|
|
|
..addModel(buyerModel)
|
|
|
|
|
..addModel(notificationModel)
|
|
|
|
|
..addModel(chartModel)
|
|
|
|
|
..addModel(deliveryModel)
|
|
|
|
|
..addModel(logModel)
|
|
|
|
|
..addModel(manualModel)
|
|
|
|
|
..addModel(phoneDeviceModel)
|
|
|
|
|
..addModel(regModel)
|
|
|
|
|
..addModel(announcementModel)
|
|
|
|
|
..addModel(reportModel)
|
|
|
|
|
..addModel(testModel)
|
2020-05-29 15:54:26 +06:30
|
|
|
..addModel(reportUserModel)
|
|
|
|
|
..addModel(pickUpModel)
|
2020-06-01 14:24:45 +06:30
|
|
|
..addModel(shipmentRateModel)
|
2020-06-01 14:48:29 +06:30
|
|
|
..addModel(shipmentModel)
|
2020-06-01 11:52:12 +06:30
|
|
|
..addModel(packageModel)
|
2020-06-04 01:36:49 +06:30
|
|
|
..addModel(boxModel)
|
2020-06-02 14:56:38 +06:30
|
|
|
..addModel(messageModel)
|
2020-06-02 14:52:31 +06:30
|
|
|
..addModel(shipmentRateModel)
|
2020-06-02 14:55:47 +06:30
|
|
|
..addModel(invoiceModel)
|
2020-06-26 16:04:40 +06:30
|
|
|
..addModel(customerModel)
|
|
|
|
|
..addModel(discountModel);
|
2020-05-29 07:45:27 +06:30
|
|
|
this.mainModel.init();
|
2020-09-06 02:36:57 +06:30
|
|
|
|
|
|
|
|
_initLocalNotifications();
|
|
|
|
|
Services.instance.messagingService.init((message) {
|
|
|
|
|
print("Message from FCM:$message");
|
|
|
|
|
_showNotification(message);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_initLocalNotifications() {
|
|
|
|
|
var initializationSettingsAndroid =
|
|
|
|
|
new AndroidInitializationSettings('@mipmap/ic_launcher');
|
|
|
|
|
var initializationSettingsIOS = new IOSInitializationSettings();
|
|
|
|
|
var initializationSettings = new InitializationSettings(
|
|
|
|
|
initializationSettingsAndroid, initializationSettingsIOS);
|
|
|
|
|
_flutterLocalNotificationsPlugin.initialize(initializationSettings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Future _showNotification(Map<String, dynamic> message) async {
|
|
|
|
|
var pushTitle;
|
|
|
|
|
var pushText;
|
|
|
|
|
var action;
|
|
|
|
|
|
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
|
var nodeData = message['notification'];
|
|
|
|
|
pushTitle = nodeData['title'];
|
|
|
|
|
pushText = nodeData['body'];
|
|
|
|
|
action = nodeData['action'];
|
|
|
|
|
} else {
|
|
|
|
|
pushTitle = message['title'];
|
|
|
|
|
pushText = message['body'];
|
|
|
|
|
action = message['action'];
|
|
|
|
|
}
|
|
|
|
|
print("AppPushs params pushTitle : $pushTitle");
|
|
|
|
|
print("AppPushs params pushText : $pushText");
|
|
|
|
|
print("AppPushs params pushAction : $action");
|
|
|
|
|
|
|
|
|
|
// @formatter:off
|
|
|
|
|
var platformChannelSpecificsAndroid = new AndroidNotificationDetails(
|
|
|
|
|
'your channel id', 'your channel name', 'your channel description',
|
|
|
|
|
playSound: true,
|
|
|
|
|
enableVibration: true,
|
|
|
|
|
importance: Importance.Max,
|
|
|
|
|
priority: Priority.High);
|
|
|
|
|
// @formatter:on
|
|
|
|
|
var platformChannelSpecificsIos =
|
|
|
|
|
new IOSNotificationDetails(presentSound: true);
|
|
|
|
|
var platformChannelSpecifics = new NotificationDetails(
|
|
|
|
|
platformChannelSpecificsAndroid, platformChannelSpecificsIos);
|
|
|
|
|
|
|
|
|
|
new Future.delayed(Duration.zero, () {
|
|
|
|
|
_flutterLocalNotificationsPlugin.show(
|
|
|
|
|
0,
|
|
|
|
|
pushTitle,
|
|
|
|
|
pushText,
|
|
|
|
|
platformChannelSpecifics,
|
|
|
|
|
payload: 'No_Sound',
|
|
|
|
|
);
|
|
|
|
|
});
|
2020-05-29 07:45:27 +06:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void onLocaleChange(Locale locale) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_newLocaleDelegate = AppTranslationsDelegate(newLocale: locale);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, WidgetBuilder> route(BuildContext context) {
|
|
|
|
|
final routes = <String, WidgetBuilder>{
|
|
|
|
|
'/': (_) => SplashScreen(),
|
2020-08-30 21:26:37 +06:30
|
|
|
'/welcome': (_) => WelcomePage(),
|
|
|
|
|
'/home': (_) => HomePage(),
|
2020-05-29 07:45:27 +06:30
|
|
|
'/term': (context) => Term(
|
|
|
|
|
agreePage: true,
|
|
|
|
|
),
|
|
|
|
|
'/login': (context) => LoginPage(),
|
|
|
|
|
'/email': (context) => EmailPage()
|
|
|
|
|
};
|
|
|
|
|
return routes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return MultiProvider(
|
2020-09-06 02:36:57 +06:30
|
|
|
providers: [
|
|
|
|
|
ChangeNotifierProvider.value(value: mainModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: userModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: productModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: employeeModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: poSubmissionModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: doModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: storageModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: pdModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: lanuguageModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: regModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: buyerModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: notificationModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: chartModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: deliveryModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: logModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: phoneDeviceModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: reportModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: announcementModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: reportUserModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: pickUpModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: shipmentRateModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: shipmentModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: packageModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: boxModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: messageModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: invoiceModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: customerModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: discountModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: testModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: mainModel2),
|
2020-09-07 16:05:28 +06:30
|
|
|
ChangeNotifierProvider.value(value: contactModel),
|
|
|
|
|
ChangeNotifierProvider.value(value: termModel),
|
2020-09-06 02:36:57 +06:30
|
|
|
],
|
2020-09-07 00:47:02 +06:30
|
|
|
child: Consumer<LanguageModel>(
|
|
|
|
|
builder: (context, value, child) {
|
|
|
|
|
return CupertinoApp(
|
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
|
title: 'FCS',
|
2020-09-07 16:05:28 +06:30
|
|
|
// theme: CupertinoThemeData(
|
|
|
|
|
// textTheme: CupertinoTextThemeData(
|
|
|
|
|
// navActionTextStyle: TextStyle(color: Colors.white),
|
|
|
|
|
// navTitleTextStyle: TextStyle(
|
|
|
|
|
// color: Colors.white,
|
|
|
|
|
// fontSize: value.isEng ? 20 : 18,
|
|
|
|
|
// fontWeight: FontWeight.w600),
|
|
|
|
|
// navLargeTitleTextStyle: TextStyle(
|
|
|
|
|
// color: Colors.white,
|
|
|
|
|
// fontSize: value.isEng ? 40 : 24,
|
|
|
|
|
// fontWeight: FontWeight.w600),
|
|
|
|
|
// primaryColor: primaryColor,
|
|
|
|
|
// textStyle: TextStyle(color: Colors.white),
|
|
|
|
|
// actionTextStyle: TextStyle(color: Colors.white),
|
|
|
|
|
// )),
|
2020-09-07 00:47:02 +06:30
|
|
|
routes: route(context),
|
|
|
|
|
localizationsDelegates: [
|
|
|
|
|
_newLocaleDelegate,
|
|
|
|
|
//provides localised strings
|
|
|
|
|
GlobalMaterialLocalizations.delegate,
|
|
|
|
|
//provides RTL support
|
|
|
|
|
GlobalWidgetsLocalizations.delegate,
|
|
|
|
|
],
|
|
|
|
|
supportedLocales: Translation().supportedLocales());
|
|
|
|
|
},
|
|
|
|
|
));
|
2020-05-29 07:45:27 +06:30
|
|
|
}
|
|
|
|
|
}
|