Files
fcs/lib/pages/main/home_page.dart

603 lines
21 KiB
Dart
Raw Normal View History

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';
2020-10-19 05:13:49 +06:30
import 'package:fcs/pages/carton/carton_list.dart';
2020-10-07 02:33:06 +06:30
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';
2020-10-26 04:41:24 +06:30
import 'package:fcs/pages/invoice/invoice_list.dart';
2020-10-07 02:33:06 +06:30
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';
2021-09-13 17:36:52 +06:30
import 'package:fcs/pages/pickup/pickup_list.dart';
2020-10-08 16:53:43 +06:30
import 'package:fcs/pages/processing/processing_list.dart';
import 'package:fcs/pages/rates/shipment_rates.dart';
2020-10-08 14:40:18 +06:30
import 'package:fcs/pages/receiving/receiving_list.dart';
2024-02-14 16:54:38 +06:30
import 'package:fcs/pages/signin/pinlogin_page.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';
2021-09-10 12:00:08 +06:30
import 'package:flutter_vector_icons/flutter_vector_icons.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];
2024-01-23 16:28:08 +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 {
2021-09-10 15:15:20 +06:30
bool? staffMode = await SharedPref.getStaffMode();
2020-10-12 03:34:05 +06:30
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
}
2021-09-10 12:00:08 +06:30
late String notiUserID, notiUserName;
2020-09-20 05:34:49 +06:30
_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 {
2025-04-02 17:07:09 +06:30
var _duration = Duration(milliseconds: 500);
Timer.periodic(_duration, (t) => displayNoti(t));
2020-09-20 05:34:49 +06:30
}
void displayNoti(Timer timer) async {
MainModel mainModel = Provider.of<MainModel>(context, listen: false);
if (mainModel.isLogin()) {
timer.cancel();
bool isCustomer = mainModel.isCustomer();
2021-09-10 15:15:20 +06:30
String? receiverID = isCustomer ? mainModel.user?.id : notiUserID;
String? receiverName = isCustomer ? mainModel.user?.name : notiUserName;
2020-09-20 05:34:49 +06:30
MessageModel messageModel =
Provider.of<MessageModel>(context, listen: false);
messageModel.initQuery(receiverID);
2021-09-10 15:15:20 +06:30
User user = mainModel.user!;
2020-09-20 05:34:49 +06:30
if (!isCustomer) {
CustomerModel customerModel =
Provider.of<CustomerModel>(context, listen: false);
var u = await customerModel.getUser(receiverID);
if (u != null) {
user = u;
}
2020-09-20 05:34:49 +06:30
}
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MessageDetail(
messageModel: messageModel,
2021-09-10 15:15:20 +06:30
receiverID: receiverID ?? "",
receiverName: receiverName ?? "",
2020-09-20 05:34:49 +06:30
))).then((value) {
if (user.userUnseenCount > 0) {
2021-09-10 15:15:20 +06:30
messageModel.seenMessages(user.id ?? "", true);
2020-09-20 05:34:49 +06:30
}
});
if (user.userUnseenCount > 0) {
2021-09-10 15:15:20 +06:30
messageModel.seenMessages(user.id ?? "", true);
2020-09-20 05:34:49 +06:30
}
}
}
_initLocalNotifications() {
2024-01-09 13:11:22 +06:30
// var initializationSettingsAndroid =
// new AndroidInitializationSettings('@mipmap/ic_launcher');
// var initializationSettingsIOS = new IOSInitializationSettings();
// var initializationSettings = new InitializationSettings(
// android: initializationSettingsAndroid, iOS: initializationSettingsIOS);
// _flutterLocalNotificationsPlugin.initialize(initializationSettings);
2020-09-20 05:34:49 +06:30
}
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
2024-01-09 13:11:22 +06:30
// var platformChannelSpecificsAndroid = new AndroidNotificationDetails(
// 'your channel id', 'your channel name', 'your channel description',
// playSound: true,
// enableVibration: true,
// importance: Importance.max,
// priority: Priority.high);
2021-09-10 16:33:52 +06:30
2020-09-20 05:34:49 +06:30
// @formatter:on
2024-01-09 13:11:22 +06:30
// var platformChannelSpecificsIos =
// new IOSNotificationDetails(presentSound: true);
// var platformChannelSpecifics = new NotificationDetails(
// android: platformChannelSpecificsAndroid,
// iOS: platformChannelSpecificsIos);
// new Future.delayed(Duration.zero, () {
2024-01-23 15:15:07 +06:30
// _flutterLocalNotificationsPlugin.show(
// 0,
// pushTitle,
// pushText,
// platformChannelSpecifics,
// payload: 'No_Sound',
// );
2024-01-09 13:11:22 +06:30
// });
2020-05-29 07:45:27 +06:30
}
void dispose() {
super.dispose();
}
2024-10-04 13:55:59 +06:30
_logoutPinAccount() async {
setState(() {
_isLoading = true;
});
try {
await context.read<MainModel>().logoutPinAccount();
Navigator.pushNamedAndRemoveUntil(context, "/pin_login", (r) => false);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
} finally {
setState(() {
_isLoading = false;
});
}
}
2020-05-29 07:45:27 +06:30
@override
Widget build(BuildContext context) {
2024-10-04 13:55:59 +06:30
var mainModel = context.watch<MainModel>();
User? user = mainModel.user;
2020-11-09 05:53:25 +06:30
2020-09-16 02:29:50 +06:30
if (user == null) {
2020-10-17 01:40:24 +06:30
Future.microtask(
() => Navigator.pushNamedAndRemoveUntil(context, "/", (r) => false));
2020-09-16 02:29:50 +06:30
return Container();
}
2024-10-04 13:55:59 +06:30
login = mainModel.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())));
final rateBtnFcs = TaskButton("rate.title",
icon: Ionicons.ios_calculator,
btnCallback: () => Navigator.of(context).push<void>(
CupertinoPageRoute(builder: (context) => ShipmentRates())));
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-19 05:13:49 +06:30
btnCallback: () => Navigator.of(context).push<void>(
CupertinoPageRoute(builder: (context) => CartonList())));
2020-06-04 01:36:49 +06:30
2024-01-23 16:28:08 +06:30
// final shipmentBtn = TaskButton("shipment",
// icon: SimpleLineIcons.direction,
// btnCallback: () => Navigator.of(context)
// .push(CupertinoPageRoute(builder: (context) => ShipmentList())));
2020-10-12 03:34:05 +06:30
2024-01-23 16:28:08 +06:30
// final shipmentBtnFcs = TaskButton("shipment",
// icon: SimpleLineIcons.direction,
// btnCallback: () => Navigator.of(context).push(CupertinoPageRoute(
// builder: (context) => ShipmentList(
// forCustomer: false,
// ))));
2020-05-29 15:54:26 +06:30
2021-09-13 17:36:52 +06:30
final pickupBtnFcs = TaskButton("pickup.title",
icon: SimpleLineIcons.direction,
btnCallback: () => Navigator.of(context).push<void>(
CupertinoPageRoute(builder: (context) => PickupList())));
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) {
2021-09-10 15:15:20 +06:30
messageModel.seenMessages(user.id ?? "", true);
2020-09-20 05:34:49 +06:30
}
});
if (user.userUnseenCount > 0) {
2021-09-10 15:15:20 +06:30
messageModel.seenMessages(user.id ?? "", true);
2020-09-20 05:34:49 +06:30
}
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",
2021-10-11 17:09:47 +06:30
icon: MaterialCommunityIcons.account_hard_hat,
2020-09-18 04:04:21 +06:30
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-16 21:38:39 +06:30
btnCallback: () => Navigator.of(context).push<void>(CupertinoPageRoute(
2020-10-26 04:41:24 +06:30
builder: (context) => InvoiceList(forCustomer: true))));
2020-10-12 03:34:05 +06:30
final invoicesBtnFcs = TaskButton("invoices.btn",
icon: FontAwesomeIcons.fileInvoice,
2020-10-16 13:46:02 +06:30
btnCallback: () => Navigator.of(context).push<void>(CupertinoPageRoute(
2020-10-26 04:41:24 +06:30
builder: (context) => InvoiceList(forCustomer: false))));
2020-05-29 07:45:27 +06:30
2020-10-07 02:33:06 +06:30
final discountBtn = TaskButton("discount.btn",
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
// final setttingBtn = TaskButton(
// "setting.title",
// icon: Ionicons.ios_settings_outline,
// btnCallback: () => Navigator.of(context).push<void>(CupertinoPageRoute(
// builder: (context) => StaffList(),
// )),
// );
2020-05-31 15:00:11 +06:30
List<Widget> widgets = [];
2020-10-17 01:40:24 +06:30
List<Widget> widgetsFcs = [];
2020-10-12 03:34:05 +06:30
widgets.add(notiBtn);
2020-10-17 01:40:24 +06:30
if (user.joined) {
widgets.add(packagesBtn);
2021-10-11 17:09:47 +06:30
// widgets.add(shipmentBtn);
2025-01-13 10:10:05 +06:30
// widgets.add(invoicesBtn);
2020-10-17 01:40:24 +06:30
if (user.hasAdmin() || user.hasSupport()) widgetsFcs.add(rateBtnFcs);
2020-10-17 01:40:24 +06:30
if (user.hasPackages()) widgetsFcs.add(packagesBtnFcs);
2021-10-11 17:09:47 +06:30
// if (user.hasShipment()) widgetsFcs.add(shipmentBtnFcs);
2025-01-13 10:10:05 +06:30
// if (user.hasShipment()) widgetsFcs.add(pickupBtnFcs);
// if (user.hasInvoices()) widgetsFcs.add(invoicesBtnFcs);
2025-02-17 20:13:30 +06:30
if (user.hasFcsShipments()) widgetsFcs.add(fcsShipmentBtn);
if (user.hasReceiving()) widgetsFcs.add(receivingBtn);
if (user.hasProcessing()) widgetsFcs.add(processingBtn);
2025-02-17 20:13:30 +06:30
if (user.hasCarton()) widgetsFcs.add(cartonBtn);
2025-01-13 10:10:05 +06:30
// if (user.hasDeliveries()) widgetsFcs.add(deliveryBtn);
2020-10-17 01:40:24 +06:30
if (user.hasCustomers()) widgetsFcs.add(customersBtn);
if (user.hasAdmin()) widgetsFcs.add(discountBtn);
if (user.hasStaffs()) widgetsFcs.add(staffBtn);
// widgetsFcs.add(setttingBtn);
2020-10-17 01:40:24 +06:30
}
2020-10-09 02:42:21 +06:30
widgets.add(faqBtn);
// widgets.add(setttingBtn);
2020-10-12 03:34:05 +06:30
final fcsToggle = ToggleButtons(
selectedColor: Colors.white,
2020-10-12 09:00:22 +06:30
color: Colors.blue,
2025-04-02 17:07:09 +06:30
onPressed: (i) => setState(() {
2020-10-12 03:34:05 +06:30
isFcs[0] = !isFcs[0];
SharedPref.saveStaffMode(isFcs[0]);
}),
isSelected: isFcs,
selectedBorderColor: Colors.white24,
2025-04-02 17:07:09 +06:30
children: <Widget>[
Icon(MaterialCommunityIcons.account_tie, size: 25),
],
2020-10-12 03:34:05 +06:30
);
2024-02-14 17:19:55 +06:30
2024-01-09 13:11:22 +06:30
final signinBtn = TextButton(
2020-10-12 03:34:05 +06:30
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()));
},
2024-02-14 17:19:55 +06:30
iconSize: 25,
icon: Icon(
Icons.account_circle,
color: buttonColor,
),
2020-10-12 03:34:05 +06:30
);
2024-10-04 13:55:59 +06:30
2024-02-14 16:54:38 +06:30
final pinLoginBtn = IconButton(
onPressed: () {
2025-02-18 16:50:34 +06:30
if (!mainModel.hasPinLogin()) {
showMsgDialog(context, "Error", "Login user doesn't have permission");
return;
}
if (!mainModel.allowPin()) {
showMsgDialog(
context, "Error", "Login user has more than one privilege");
return;
}
2024-10-04 13:55:59 +06:30
Navigator.pushAndRemoveUntil(
context,
CupertinoPageRoute(
builder: (BuildContext context) => PinLoginPage()),
(r) => false);
2024-02-14 16:54:38 +06:30
},
2024-02-14 17:19:55 +06:30
iconSize: 25,
icon: Icon(
Icons.lock_outline,
color: buttonColor,
),
2024-02-14 16:54:38 +06:30
);
2020-10-12 03:34:05 +06:30
2024-10-04 13:55:59 +06:30
final pinLogoutBtn = IconButton(
onPressed: () {
showConfirmDialog(context, "home.pin.logout.confirm", () async {
await _logoutPinAccount();
});
},
iconSize: 25,
icon: Icon(
2025-02-18 12:19:08 +06:30
Icons.lock_outline,
2024-10-04 13:55:59 +06:30
color: buttonColor,
),
);
2025-04-02 17:07:09 +06:30
var searchInput = Padding(
padding: const EdgeInsets.only(left: 5, right: 5, bottom: 10, top: 5),
child: Row(children: [
Expanded(
child: Padding(
padding: const EdgeInsets.only(),
child: Theme(
data: ThemeData(
primaryColor: primaryColor,
primaryColorDark: primaryColor,
),
child: TextField(
style: TextStyle(color: Colors.white),
controller: _searchCtl,
scrollPadding: EdgeInsets.all(0),
cursorColor: Colors.white,
decoration: InputDecoration(
enabledBorder: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(30)),
borderSide: BorderSide(color: Colors.white60, width: 1.5),
2020-10-12 03:34:05 +06:30
),
2025-04-02 17:07:09 +06:30
focusedBorder: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(30)),
borderSide: BorderSide(color: Colors.white60, width: 1.5),
),
contentPadding: EdgeInsets.only(top: 1, bottom: 1),
isDense: true,
hintText: getLocalString(context, "home.search"),
hintStyle: languageModel.isEng
? newLabelStyle(color: Colors.grey)
: newLabelStyleMM(color: Colors.grey),
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)),
),
2020-10-12 03:34:05 +06:30
),
),
),
2025-04-02 17:07:09 +06:30
InkWell(
onTap: _lookup,
child: Padding(
padding: const EdgeInsets.all(10.0),
child: LocalText(
context,
"home.search.btn",
color: Colors.white,
),
2020-10-12 03:34:05 +06:30
),
2025-04-02 17:07:09 +06:30
)
]),
);
2020-10-12 03:34:05 +06:30
widgets.insert(0, searchInput);
return LocalProgress(
inAsyncCall: _isLoading,
child: OfflineRedirect(
child: FlavorBanner(
child: Scaffold(
appBar: AppBar(
elevation: 0,
backgroundColor: primaryColor,
title: ClipRRect(
2025-04-02 17:07:09 +06:30
borderRadius: BorderRadius.circular(30.0),
2020-10-12 03:34:05 +06:30
child: Image.asset("assets/logo.jpg", height: 40),
),
actions: login
? user.isCustomer()
? <Widget>[
2024-02-14 17:19:55 +06:30
profileBtn,
2020-10-12 03:34:05 +06:30
]
: <Widget>[
2025-02-18 12:19:08 +06:30
mainModel.isPinLogin ? pinLogoutBtn : pinLoginBtn,
2024-02-14 17:19:55 +06:30
fcsToggle,
2020-10-12 03:34:05 +06:30
profileBtn,
]
: <Widget>[
2024-02-14 17:19:55 +06:30
signinBtn,
2020-10-12 03:34:05 +06:30
]),
body: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color(0xd0272262),
Color(0xfa272262),
],
),
),
child: ListView(
children: <Widget>[
2025-04-02 17:07:09 +06:30
const SizedBox(height: 10),
2020-10-12 03:34:05 +06:30
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-10-12 03:34:05 +06:30
_lookup() async {
setState(() {
_isLoading = true;
});
try {
String term = _searchCtl.text;
2024-02-14 17:19:55 +06:30
if (term.trim() == "") return;
2020-10-12 03:34:05 +06:30
var packageModel = Provider.of<PackageModel>(context, listen: false);
2021-09-10 17:15:23 +06:30
Package? package = await packageModel.lookupPackage(term);
2020-10-12 03:34:05 +06:30
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
}