2020-09-20 05:34:49 +06:30
|
|
|
import 'dart:async';
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/data/services/services.dart';
|
2020-10-12 03:34:05 +06:30
|
|
|
import 'package:fcs/domain/entities/package.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/domain/entities/user.dart';
|
2020-10-12 03:34:05 +06:30
|
|
|
import 'package:fcs/helpers/shared_pref.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/helpers/theme.dart';
|
|
|
|
|
import 'package:fcs/localization/transalation.dart';
|
|
|
|
|
import 'package:fcs/pages/box/box_list.dart';
|
|
|
|
|
import 'package:fcs/pages/chat/message_detail.dart';
|
|
|
|
|
import 'package:fcs/pages/chat/model/message_model.dart';
|
|
|
|
|
import 'package:fcs/pages/customer/customer_list.dart';
|
|
|
|
|
import 'package:fcs/pages/customer/model/customer_model.dart';
|
|
|
|
|
import 'package:fcs/pages/delivery/delivery_list.dart';
|
|
|
|
|
import 'package:fcs/pages/discount/discount_list.dart';
|
|
|
|
|
import 'package:fcs/pages/faq/faq_list_page.dart';
|
|
|
|
|
import 'package:fcs/pages/fcs_shipment/fcs_shipment_list.dart';
|
|
|
|
|
import 'package:fcs/pages/invoice/invoce_list.dart';
|
|
|
|
|
import 'package:fcs/pages/main/model/language_model.dart';
|
|
|
|
|
import 'package:fcs/pages/main/model/main_model.dart';
|
2020-10-12 03:34:05 +06:30
|
|
|
import 'package:fcs/pages/main/util.dart';
|
|
|
|
|
import 'package:fcs/pages/package/model/package_model.dart';
|
|
|
|
|
import 'package:fcs/pages/package/package_info.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/pages/package/package_list.dart';
|
2020-10-08 16:53:43 +06:30
|
|
|
import 'package:fcs/pages/processing/processing_list.dart';
|
2020-10-08 14:40:18 +06:30
|
|
|
import 'package:fcs/pages/receiving/receiving_list.dart';
|
2020-10-07 14:42:07 +06:30
|
|
|
import 'package:fcs/pages/shipment/shipment_list.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/pages/staff/staff_list.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/badge.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/bottom_widgets.dart';
|
2020-10-12 03:34:05 +06:30
|
|
|
import 'package:fcs/pages/widgets/local_text.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/progress.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/pages/widgets/right_left_page_rout.dart';
|
2020-10-12 03:34:05 +06:30
|
|
|
import 'package:fcs/pages/widgets/task_button.dart';
|
2020-05-29 15:53:37 +06:30
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
2020-08-30 21:26:37 +06:30
|
|
|
import 'package:flutter_icons/flutter_icons.dart';
|
2020-09-20 05:34:49 +06:30
|
|
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
2020-05-29 15:53:37 +06:30
|
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
|
|
|
import 'package:logging/logging.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
2020-05-29 07:45:27 +06:30
|
|
|
|
2020-10-07 02:33:06 +06:30
|
|
|
import '../profile/profile_page.dart';
|
|
|
|
|
import '../signin/signin_page.dart';
|
|
|
|
|
import '../widgets/banner.dart';
|
|
|
|
|
import '../widgets/offline_redirect.dart';
|
2020-05-29 07:45:27 +06:30
|
|
|
|
|
|
|
|
final msgLog = Logger('backgroundMessageHandler');
|
|
|
|
|
|
|
|
|
|
class HomePage extends StatefulWidget {
|
|
|
|
|
@override
|
|
|
|
|
_HomePageState createState() => _HomePageState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _HomePageState extends State<HomePage> {
|
|
|
|
|
final log = Logger('_HomePageState');
|
2020-05-31 15:00:11 +06:30
|
|
|
bool login = false;
|
2020-10-12 03:34:05 +06:30
|
|
|
bool _isLoading = false;
|
2020-09-04 15:30:10 +06:30
|
|
|
List<bool> isSelected = [true, false];
|
2020-09-20 05:34:49 +06:30
|
|
|
static FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin =
|
|
|
|
|
FlutterLocalNotificationsPlugin();
|
2020-10-12 03:34:05 +06:30
|
|
|
TextEditingController _searchCtl = TextEditingController();
|
|
|
|
|
List<bool> isFcs = [false];
|
2020-05-29 07:45:27 +06:30
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
2020-09-20 05:34:49 +06:30
|
|
|
MainModel mainModel = Provider.of<MainModel>(context, listen: false);
|
|
|
|
|
|
|
|
|
|
Services.instance.messagingService.init(
|
|
|
|
|
(message) {
|
|
|
|
|
print("Message from FCM:$message");
|
|
|
|
|
_showNotification(message);
|
|
|
|
|
},
|
|
|
|
|
onLaunch: (m) => _showNotiContent(m),
|
|
|
|
|
onResume: (m) => _showNotiContent(m),
|
|
|
|
|
onSetupComplete: (token) {
|
|
|
|
|
mainModel.setMessaginToken = token;
|
|
|
|
|
});
|
|
|
|
|
_initLocalNotifications();
|
2020-10-12 03:34:05 +06:30
|
|
|
_loadStaffMode(mainModel.isCustomer());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_loadStaffMode(bool isCustomer) async {
|
|
|
|
|
bool staffMode = await SharedPref.getStaffMode();
|
|
|
|
|
setState(() {
|
|
|
|
|
if (isCustomer) {
|
|
|
|
|
isFcs[0] = false;
|
|
|
|
|
} else {
|
2020-10-12 09:00:22 +06:30
|
|
|
isFcs[0] = staffMode ?? false;
|
2020-10-12 03:34:05 +06:30
|
|
|
}
|
|
|
|
|
});
|
2020-09-20 05:34:49 +06:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String notiUserID, notiUserName;
|
|
|
|
|
_showNotiContent(Map<String, dynamic> message) {
|
|
|
|
|
try {
|
|
|
|
|
Map<String, dynamic> map = Map<String, dynamic>.from(message["data"]);
|
|
|
|
|
notiUserID = map['user_id'];
|
|
|
|
|
notiUserName = map['user_name'];
|
|
|
|
|
_startNotiTimer();
|
|
|
|
|
print("Notification:$map");
|
|
|
|
|
} catch (e) {
|
|
|
|
|
print("Error:$e");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_startNotiTimer() async {
|
|
|
|
|
var _duration = new Duration(milliseconds: 500);
|
|
|
|
|
new Timer.periodic(_duration, (t) => displayNoti(t));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void displayNoti(Timer timer) async {
|
|
|
|
|
MainModel mainModel = Provider.of<MainModel>(context, listen: false);
|
|
|
|
|
if (mainModel.isLogin()) {
|
|
|
|
|
timer.cancel();
|
|
|
|
|
bool isCustomer = mainModel.isCustomer();
|
|
|
|
|
String receiverID = isCustomer ? mainModel.user.id : notiUserID;
|
|
|
|
|
String receiverName = isCustomer ? mainModel.user.name : notiUserName;
|
|
|
|
|
MessageModel messageModel =
|
|
|
|
|
Provider.of<MessageModel>(context, listen: false);
|
|
|
|
|
messageModel.initQuery(receiverID);
|
|
|
|
|
User user = mainModel.user;
|
|
|
|
|
if (!isCustomer) {
|
|
|
|
|
CustomerModel customerModel =
|
|
|
|
|
Provider.of<CustomerModel>(context, listen: false);
|
|
|
|
|
user = await customerModel.getUser(receiverID);
|
|
|
|
|
}
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (context) => MessageDetail(
|
|
|
|
|
messageModel: messageModel,
|
|
|
|
|
receiverID: receiverID,
|
|
|
|
|
receiverName: receiverName,
|
|
|
|
|
))).then((value) {
|
|
|
|
|
if (user.userUnseenCount > 0) {
|
|
|
|
|
messageModel.seenMessages(user.id, true);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (user.userUnseenCount > 0) {
|
|
|
|
|
messageModel.seenMessages(user.id, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_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 dispose() {
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2020-09-13 21:49:39 +06:30
|
|
|
User user = Provider.of<MainModel>(context).user;
|
2020-09-16 02:29:50 +06:30
|
|
|
if (user == null) {
|
|
|
|
|
return Container();
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-01 14:24:45 +06:30
|
|
|
login = Provider.of<MainModel>(context).isLogin();
|
2020-09-04 15:30:10 +06:30
|
|
|
LanguageModel languageModel = Provider.of<LanguageModel>(context);
|
2020-06-03 00:42:31 +06:30
|
|
|
|
2020-10-07 02:33:06 +06:30
|
|
|
final faqBtn = TaskButton("faq.btn",
|
2020-09-07 16:05:28 +06:30
|
|
|
icon: MaterialCommunityIcons.frequently_asked_questions,
|
|
|
|
|
btnCallback: () => Navigator.of(context).push(CupertinoPageRoute(
|
2020-09-13 21:49:39 +06:30
|
|
|
builder: (context) => FAQListPage(),
|
2020-09-07 16:05:28 +06:30
|
|
|
)));
|
|
|
|
|
|
2020-10-07 02:33:06 +06:30
|
|
|
final packagesBtn = TaskButton("package.btn.name",
|
2020-06-01 11:52:12 +06:30
|
|
|
icon: Octicons.package,
|
2020-09-18 04:04:21 +06:30
|
|
|
btnCallback: () => Navigator.of(context).push<void>(
|
|
|
|
|
CupertinoPageRoute(builder: (context) => PackageList())));
|
2020-10-12 03:34:05 +06:30
|
|
|
final packagesBtnFcs = TaskButton("package.btn.name",
|
|
|
|
|
icon: Octicons.package,
|
|
|
|
|
btnCallback: () => Navigator.of(context).push<void>(CupertinoPageRoute(
|
|
|
|
|
builder: (context) => PackageList(
|
2020-10-16 10:58:31 +06:30
|
|
|
forCustomer: false,
|
2020-10-12 03:34:05 +06:30
|
|
|
))));
|
2020-05-29 07:45:27 +06:30
|
|
|
|
2020-10-08 14:40:18 +06:30
|
|
|
final receivingBtn = TaskButton("receiving.title",
|
2020-10-11 02:17:23 +06:30
|
|
|
icon: MaterialCommunityIcons.inbox_arrow_down,
|
2020-10-08 14:40:18 +06:30
|
|
|
btnCallback: () => Navigator.of(context).push<void>(
|
|
|
|
|
CupertinoPageRoute(builder: (context) => ReceivingList())));
|
|
|
|
|
|
2020-10-08 16:53:43 +06:30
|
|
|
final processingBtn = TaskButton("processing.title",
|
2020-10-11 02:17:23 +06:30
|
|
|
icon: FontAwesome.dropbox,
|
2020-10-08 16:53:43 +06:30
|
|
|
btnCallback: () => Navigator.of(context).push<void>(
|
|
|
|
|
CupertinoPageRoute(builder: (context) => ProcessingList())));
|
2020-10-12 03:34:05 +06:30
|
|
|
final cartonBtn = TaskButton("boxes.name",
|
2020-06-04 01:36:49 +06:30
|
|
|
icon: MaterialCommunityIcons.package,
|
2020-10-12 03:34:05 +06:30
|
|
|
btnCallback: () => Navigator.of(context)
|
|
|
|
|
.push<void>(CupertinoPageRoute(builder: (context) => BoxList())));
|
2020-06-04 01:36:49 +06:30
|
|
|
|
2020-10-12 03:34:05 +06:30
|
|
|
final shipmentBtn = TaskButton("shipment",
|
2020-06-03 00:42:31 +06:30
|
|
|
icon: SimpleLineIcons.direction,
|
2020-10-12 03:34:05 +06:30
|
|
|
btnCallback: () => Navigator.of(context)
|
|
|
|
|
.push(CupertinoPageRoute(builder: (context) => ShipmentList())));
|
|
|
|
|
|
|
|
|
|
final shipmentBtnFcs = TaskButton("shipment",
|
|
|
|
|
icon: SimpleLineIcons.direction,
|
2020-10-16 10:58:31 +06:30
|
|
|
btnCallback: () => Navigator.of(context).push(CupertinoPageRoute(
|
|
|
|
|
builder: (context) => ShipmentList(
|
|
|
|
|
forCustomer: false,
|
|
|
|
|
))));
|
2020-05-29 15:54:26 +06:30
|
|
|
|
2020-10-07 18:19:12 +06:30
|
|
|
final fcsShipmentBtn = TaskButton("FCSshipment.title",
|
2020-05-31 15:00:11 +06:30
|
|
|
icon: Ionicons.ios_airplane,
|
2020-10-12 03:34:05 +06:30
|
|
|
btnCallback: () => Navigator.of(context).push(CupertinoPageRoute(
|
2020-10-08 03:32:52 +06:30
|
|
|
builder: (context) => FcsShipmentList(),
|
|
|
|
|
)));
|
2020-09-20 05:34:49 +06:30
|
|
|
final notiBtnOrg =
|
2020-10-07 02:33:06 +06:30
|
|
|
TaskButton("message.btn", icon: Icons.message, btnCallback: () {
|
2020-09-20 05:34:49 +06:30
|
|
|
MessageModel messageModel =
|
|
|
|
|
Provider.of<MessageModel>(context, listen: false);
|
|
|
|
|
messageModel.initQuery(user.id);
|
2020-10-12 03:34:05 +06:30
|
|
|
Navigator.of(context)
|
|
|
|
|
.push(CupertinoPageRoute(
|
|
|
|
|
builder: (context) => MessageDetail(messageModel: messageModel),
|
|
|
|
|
))
|
|
|
|
|
.then((value) {
|
2020-09-20 05:34:49 +06:30
|
|
|
if (user.userUnseenCount > 0) {
|
|
|
|
|
messageModel.seenMessages(user.id, true);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (user.userUnseenCount > 0) {
|
|
|
|
|
messageModel.seenMessages(user.id, true);
|
|
|
|
|
}
|
2020-05-29 07:45:27 +06:30
|
|
|
});
|
2020-09-20 05:34:49 +06:30
|
|
|
final notiBtn = badgeCounter(notiBtnOrg, user.userUnseenCount);
|
2020-05-29 07:45:27 +06:30
|
|
|
|
2020-10-07 02:33:06 +06:30
|
|
|
final staffBtn = TaskButton(
|
2020-09-18 04:04:21 +06:30
|
|
|
"staff.title",
|
|
|
|
|
icon: MaterialCommunityIcons.worker,
|
|
|
|
|
btnCallback: () => Navigator.of(context).push<void>(CupertinoPageRoute(
|
|
|
|
|
builder: (context) => StaffList(),
|
|
|
|
|
)),
|
|
|
|
|
);
|
2020-05-29 16:14:17 +06:30
|
|
|
|
2020-10-07 02:33:06 +06:30
|
|
|
final customersBtn = TaskButton("customers.btn",
|
2020-06-02 00:00:05 +06:30
|
|
|
icon: Feather.users,
|
2020-09-18 04:04:21 +06:30
|
|
|
btnCallback: () => Navigator.of(context).push<void>(CupertinoPageRoute(
|
|
|
|
|
builder: (context) => CustomerList(),
|
|
|
|
|
)));
|
2020-06-02 00:00:05 +06:30
|
|
|
|
2020-10-07 02:33:06 +06:30
|
|
|
final invoicesBtn = TaskButton("invoices.btn",
|
2020-06-02 00:00:05 +06:30
|
|
|
icon: FontAwesomeIcons.fileInvoice,
|
2020-10-12 03:34:05 +06:30
|
|
|
btnCallback: () => Navigator.of(context).push<void>(
|
|
|
|
|
CupertinoPageRoute(builder: (context) => InvoiceList())));
|
|
|
|
|
final invoicesBtnFcs = TaskButton("invoices.btn",
|
|
|
|
|
icon: FontAwesomeIcons.fileInvoice,
|
|
|
|
|
btnCallback: () => Navigator.of(context).push<void>(
|
|
|
|
|
CupertinoPageRoute(builder: (context) => InvoiceList())));
|
2020-05-29 07:45:27 +06:30
|
|
|
|
2020-10-07 02:33:06 +06:30
|
|
|
final discountBtn = TaskButton("discount.btn",
|
2020-06-29 23:28:21 +06:30
|
|
|
icon: Entypo.price_ribbon,
|
2020-10-12 03:34:05 +06:30
|
|
|
btnCallback: () => Navigator.of(context).push<void>(
|
|
|
|
|
CupertinoPageRoute(builder: (context) => DiscountList())));
|
2020-06-26 16:04:40 +06:30
|
|
|
|
2020-10-07 02:33:06 +06:30
|
|
|
final deliveryBtn = TaskButton("delivery.title",
|
2020-06-26 16:17:40 +06:30
|
|
|
icon: MaterialCommunityIcons.truck_fast,
|
2020-10-12 03:34:05 +06:30
|
|
|
btnCallback: () => Navigator.of(context).push<void>(
|
|
|
|
|
CupertinoPageRoute(builder: (context) => DeliverList())));
|
2020-06-02 14:52:31 +06:30
|
|
|
|
2020-05-31 15:00:11 +06:30
|
|
|
List<Widget> widgets = [];
|
2020-10-12 03:34:05 +06:30
|
|
|
widgets.add(notiBtn);
|
|
|
|
|
widgets.add(packagesBtn);
|
|
|
|
|
widgets.add(shipmentBtn);
|
|
|
|
|
widgets.add(invoicesBtn);
|
2020-10-09 02:42:21 +06:30
|
|
|
widgets.add(faqBtn);
|
2020-10-12 03:34:05 +06:30
|
|
|
|
|
|
|
|
List<Widget> widgetsFcs = [];
|
|
|
|
|
if (user.hasPackages()) widgetsFcs.add(packagesBtnFcs);
|
|
|
|
|
if (user.hasShipment()) widgetsFcs.add(shipmentBtnFcs);
|
|
|
|
|
if (user.hasInvoices()) widgetsFcs.add(invoicesBtnFcs);
|
|
|
|
|
|
|
|
|
|
if (user.hasFcsShipments()) widgetsFcs.add(fcsShipmentBtn);
|
|
|
|
|
if (user.hasReceiving()) widgetsFcs.add(receivingBtn);
|
|
|
|
|
if (user.hasProcessing()) widgetsFcs.add(processingBtn);
|
|
|
|
|
if (user.hasCarton()) widgetsFcs.add(cartonBtn);
|
|
|
|
|
if (user.hasDeliveries()) widgetsFcs.add(deliveryBtn);
|
|
|
|
|
if (user.hasCustomers()) widgetsFcs.add(customersBtn);
|
|
|
|
|
if (user.hasAdmin()) widgetsFcs.add(discountBtn);
|
|
|
|
|
if (user.hasStaffs()) widgetsFcs.add(staffBtn);
|
|
|
|
|
|
|
|
|
|
final fcsToggle = ToggleButtons(
|
|
|
|
|
selectedColor: Colors.white,
|
2020-10-12 09:00:22 +06:30
|
|
|
color: Colors.blue,
|
2020-10-12 03:34:05 +06:30
|
|
|
children: <Widget>[
|
|
|
|
|
Icon(MaterialCommunityIcons.worker),
|
|
|
|
|
],
|
|
|
|
|
onPressed: (i) => this.setState(() {
|
|
|
|
|
isFcs[0] = !isFcs[0];
|
|
|
|
|
SharedPref.saveStaffMode(isFcs[0]);
|
|
|
|
|
}),
|
|
|
|
|
isSelected: isFcs,
|
|
|
|
|
selectedBorderColor: Colors.white24,
|
|
|
|
|
);
|
|
|
|
|
final langToggle = ToggleButtons(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Image.asset(
|
|
|
|
|
'icons/flags/png/us.png',
|
|
|
|
|
package: 'country_icons',
|
|
|
|
|
fit: BoxFit.fitWidth,
|
|
|
|
|
width: 25,
|
|
|
|
|
),
|
|
|
|
|
Image.asset(
|
|
|
|
|
'icons/flags/png/mm.png',
|
|
|
|
|
package: 'country_icons',
|
|
|
|
|
fit: BoxFit.fitWidth,
|
|
|
|
|
width: 25,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
onPressed: _langChange,
|
|
|
|
|
isSelected: languageModel.currentState,
|
|
|
|
|
selectedBorderColor: Colors.white24,
|
|
|
|
|
);
|
|
|
|
|
final signinBtn = FlatButton(
|
|
|
|
|
onPressed: () {
|
2020-10-15 03:06:13 +06:30
|
|
|
Navigator.of(context)
|
|
|
|
|
.push(CupertinoPageRoute(builder: (context) => SigninPage()));
|
2020-10-12 03:34:05 +06:30
|
|
|
},
|
|
|
|
|
child: Text(
|
|
|
|
|
"Sign In",
|
|
|
|
|
style: siginButtonStyle,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
final profileBtn = IconButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.of(context).push(RightLeftPageRoute(Profile()));
|
|
|
|
|
},
|
|
|
|
|
iconSize: 30,
|
|
|
|
|
icon: Icon(Icons.account_circle),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
var searchInput = Row(children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.only(bottom: 3, left: 5, right: 5, top: 3),
|
|
|
|
|
child: Theme(
|
|
|
|
|
data: new ThemeData(
|
|
|
|
|
primaryColor: primaryColor,
|
|
|
|
|
primaryColorDark: primaryColor,
|
|
|
|
|
),
|
|
|
|
|
child: TextField(
|
|
|
|
|
style: TextStyle(color: Colors.white),
|
|
|
|
|
controller: _searchCtl,
|
|
|
|
|
scrollPadding: EdgeInsets.all(0),
|
|
|
|
|
decoration: new InputDecoration(
|
|
|
|
|
enabledBorder: const OutlineInputBorder(
|
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(30)),
|
|
|
|
|
borderSide:
|
|
|
|
|
const BorderSide(color: Colors.white, width: 1.5),
|
|
|
|
|
),
|
|
|
|
|
focusedBorder: const OutlineInputBorder(
|
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(30)),
|
|
|
|
|
borderSide:
|
|
|
|
|
const BorderSide(color: Colors.white, width: 1.5),
|
|
|
|
|
),
|
|
|
|
|
contentPadding: EdgeInsets.only(top: 1, bottom: 1),
|
|
|
|
|
isDense: true,
|
|
|
|
|
hintText: getLocalString(context, "home.search"),
|
|
|
|
|
hintStyle: languageModel.isEng
|
|
|
|
|
? newLabelStyle(color: Colors.white60)
|
|
|
|
|
: newLabelStyleMM(color: Colors.white60),
|
|
|
|
|
prefixIcon: const Icon(
|
|
|
|
|
Icons.search,
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
suffixIcon: InkWell(
|
|
|
|
|
onTap: () => {_searchCtl.clear()},
|
|
|
|
|
child: const Icon(
|
|
|
|
|
Icons.close,
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
suffixStyle: const TextStyle(color: primaryColor)),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
InkWell(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(10.0),
|
|
|
|
|
child: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
"home.search.btn",
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
onTap: _lookup,
|
|
|
|
|
)
|
|
|
|
|
]);
|
|
|
|
|
widgets.insert(0, searchInput);
|
|
|
|
|
|
|
|
|
|
return LocalProgress(
|
|
|
|
|
inAsyncCall: _isLoading,
|
|
|
|
|
child: OfflineRedirect(
|
|
|
|
|
child: FlavorBanner(
|
|
|
|
|
child: Scaffold(
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
elevation: 0,
|
|
|
|
|
backgroundColor: primaryColor,
|
|
|
|
|
title: ClipRRect(
|
|
|
|
|
child: Image.asset("assets/logo.jpg", height: 40),
|
|
|
|
|
borderRadius: new BorderRadius.circular(30.0),
|
|
|
|
|
),
|
|
|
|
|
actions: login
|
|
|
|
|
? user.isCustomer()
|
|
|
|
|
? <Widget>[
|
|
|
|
|
langToggle,
|
|
|
|
|
profileBtn,
|
|
|
|
|
]
|
|
|
|
|
: <Widget>[
|
|
|
|
|
fcsToggle,
|
|
|
|
|
langToggle,
|
|
|
|
|
profileBtn,
|
|
|
|
|
]
|
|
|
|
|
: <Widget>[
|
|
|
|
|
langToggle,
|
|
|
|
|
signinBtn,
|
|
|
|
|
]),
|
|
|
|
|
body: Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
gradient: LinearGradient(
|
|
|
|
|
begin: Alignment.topCenter,
|
|
|
|
|
end: Alignment.bottomCenter,
|
|
|
|
|
colors: [
|
|
|
|
|
Color(0xd0272262),
|
|
|
|
|
Color(0xfa272262),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: ListView(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Column(children: [
|
|
|
|
|
Wrap(
|
|
|
|
|
alignment: WrapAlignment.center,
|
|
|
|
|
children: isFcs[0] ? widgetsFcs : widgets,
|
2020-06-02 14:52:31 +06:30
|
|
|
),
|
2020-05-31 15:00:11 +06:30
|
|
|
]),
|
2020-10-12 03:34:05 +06:30
|
|
|
SizedBox(height: 50),
|
|
|
|
|
BottomWidgets(),
|
2020-09-15 07:13:41 +06:30
|
|
|
],
|
2020-10-12 03:34:05 +06:30
|
|
|
))),
|
|
|
|
|
),
|
2020-05-29 07:45:27 +06:30
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-02 00:00:05 +06:30
|
|
|
_langChange(index) {
|
2020-09-07 16:05:28 +06:30
|
|
|
var languageModel = Provider.of<LanguageModel>(context, listen: false);
|
2020-06-02 14:56:51 +06:30
|
|
|
languageModel.saveLanguage(Translation().supportedLanguages[index]);
|
2020-06-02 00:00:05 +06:30
|
|
|
setState(() {
|
|
|
|
|
isSelected.asMap().forEach((i, e) {
|
|
|
|
|
isSelected[i] = false;
|
|
|
|
|
});
|
|
|
|
|
isSelected[index] = !isSelected[index];
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-10-12 03:34:05 +06:30
|
|
|
|
|
|
|
|
_lookup() async {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
String term = _searchCtl.text;
|
|
|
|
|
if (term == null || term.trim() == "") return;
|
|
|
|
|
var packageModel = Provider.of<PackageModel>(context, listen: false);
|
|
|
|
|
Package package = await packageModel.lookupPackage(term);
|
|
|
|
|
if (package == null) {
|
|
|
|
|
showMsgDialog(context, "Not found", "Tracking ID - '$term' not found!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
2020-10-14 13:54:42 +06:30
|
|
|
CupertinoPageRoute(
|
|
|
|
|
builder: (context) => PackageInfo(
|
|
|
|
|
package: package,
|
|
|
|
|
isSearchResult: true,
|
|
|
|
|
)),
|
2020-10-12 03:34:05 +06:30
|
|
|
);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
showMsgDialog(context, "Error", e.toString());
|
|
|
|
|
} finally {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-29 07:45:27 +06:30
|
|
|
}
|