update carton form and add recent search

This commit is contained in:
tzw
2024-09-23 18:36:23 +06:30
parent 458884bf70
commit 3629a8312c
16 changed files with 292 additions and 96 deletions

View File

@@ -7,7 +7,6 @@
"Buttons Start ================================================================":"", "Buttons Start ================================================================":"",
"btn.save": "Save", "btn.save": "Save",
"btn.approve":"Approve", "btn.approve":"Approve",
"btn.delete":"Delete",
"btn.select":"Select", "btn.select":"Select",
"btn.cancel":"Cancel", "btn.cancel":"Cancel",
"btn.ok": "Ok", "btn.ok": "Ok",
@@ -248,7 +247,7 @@
"pm.add.btn":"Add payment method", "pm.add.btn":"Add payment method",
"pm.save.btn":"Save payment method", "pm.save.btn":"Save payment method",
"pm.delete.confirm":"Delete this payment method?", "pm.delete.confirm":"Delete this payment method?",
"pm_.title": "PAYMENT", "pm_.title": "Payment",
"pm.date": "Date", "pm.date": "Date",
"pm.amount": "Amount", "pm.amount": "Amount",
"pm.receipt":"Payment receipt amount", "pm.receipt":"Payment receipt amount",
@@ -329,15 +328,15 @@
"box.weight":"Weight", "box.weight":"Weight",
"box.mix_carton.update.btn":"Update mix carton", "box.mix_carton.update.btn":"Update mix carton",
"box.cargo.select.btn":"Select", "box.cargo.select.btn":"Select",
"box.select.carton_type":"Select carton type", "box.select.carton_type":"Carton type",
"box.select.sender_and_consignee":"Select sender and consignee", "box.select.sender_and_consignee":"Sender and Consignee",
"box.cartion.count":"Cartons ({0})", "box.cartion.count":"Cartons ({0})",
"box.sender.title":"Sender", "box.sender.title":"Sender",
"box.consignee.title":"Consignee", "box.consignee.title":"Consignee",
"box.bill_to_sender":"Bill to sender", "box.bill_to_sender":"Bill to sender",
"box.bill_to.consignee":"Bill to consignee", "box.bill_to.consignee":"Bill to consignee",
"box.done.btn":"Done", "box.done.btn":"Done",
"box.select_carton_size":"Select the carton size", "box.select_carton_size":"Carton size",
"box.select_shipment":"Select the shipment", "box.select_shipment":"Select the shipment",
"box.shipment":"Shipment", "box.shipment":"Shipment",
"box.standard_carton_size":"Standard carton size", "box.standard_carton_size":"Standard carton size",
@@ -347,11 +346,11 @@
"box.no_carton":"There is no cartons in this shipment.", "box.no_carton":"There is no cartons in this shipment.",
"box.crete.carton":"Create carton", "box.crete.carton":"Create carton",
"box.carton.type":"Carton type", "box.carton.type":"Carton type",
"box.select.delivery":"Select delivery type", "box.select.delivery":"Last mile",
"box.select.package":"Select packages", "box.select.package":"Select packages",
"box.no_package":"There is no packages.", "box.no_package":"There is no packages.",
"box.input_cargo_weight":"Input cargo weight (lb)", "box.input_cargo_weight":"Cargo type (lb)",
"box.input_surcharge_item":"Input surcharge items", "box.input_surcharge_item":"Surcharge items",
"box.select.cargo_type":"Select surcharge item", "box.select.cargo_type":"Select surcharge item",
"box.surcharge.item":"Surcharge items", "box.surcharge.item":"Surcharge items",
"box.package.count":"Packages ({0})", "box.package.count":"Packages ({0})",
@@ -369,6 +368,8 @@
"box.invoice.confirm":"Confirm invoice?", "box.invoice.confirm":"Confirm invoice?",
"box.print.qr.title":"Print QRCode", "box.print.qr.title":"Print QRCode",
"box.print.btn":"Print", "box.print.btn":"Print",
"box.delivery":"Delivery",
"box.pickup":"Pick-up",
"Boxes End ================================================================":"", "Boxes End ================================================================":"",
"Delivery Start ================================================================":"", "Delivery Start ================================================================":"",

View File

@@ -6,7 +6,6 @@
"Buttons Start ================================================================":"", "Buttons Start ================================================================":"",
"btn.save":"သိမ်းဆည်းရန်", "btn.save":"သိမ်းဆည်းရန်",
"btn.approve":"အတည်ပြုရန်", "btn.approve":"အတည်ပြုရန်",
"btn.delete":"ဖျက်ရန်",
"btn.select":"ရွေးချယ်ပါ", "btn.select":"ရွေးချယ်ပါ",
"btn.cancel":"မလုပ်နဲ့", "btn.cancel":"မလုပ်နဲ့",
"btn.ok": "အိုကေ", "btn.ok": "အိုကေ",
@@ -329,15 +328,15 @@
"box.weight":"အလေးချိန်", "box.weight":"အလေးချိန်",
"box.mix_carton.update.btn":"Update mix carton", "box.mix_carton.update.btn":"Update mix carton",
"box.cargo.select.btn":"ရွေးချယ်မည်", "box.cargo.select.btn":"ရွေးချယ်မည်",
"box.select.carton_type":"Select carton type", "box.select.carton_type":"Carton type",
"box.select.sender_and_consignee":"Select sender and consignee", "box.select.sender_and_consignee":"Sender and Consignee",
"box.cartion.count":"Cartons ({0})", "box.cartion.count":"Cartons ({0})",
"box.sender.title":"ပေးပို့သူ", "box.sender.title":"ပေးပို့သူ",
"box.consignee.title":"လက်ခံသူ", "box.consignee.title":"လက်ခံသူ",
"box.bill_to_sender":"ပေးပို့သူထံ ငွေတောင်းခံရန်", "box.bill_to_sender":"ပေးပို့သူထံ ငွေတောင်းခံရန်",
"box.bill_to.consignee":"လက်ခံသူထံ ငွေတောင်းခံရန်", "box.bill_to.consignee":"လက်ခံသူထံ ငွေတောင်းခံရန်",
"box.done.btn":"Done", "box.done.btn":"Done",
"box.select_carton_size":"Select the carton size", "box.select_carton_size":"Carton size",
"box.select_shipment":"Select the shipment", "box.select_shipment":"Select the shipment",
"box.shipment":"Shipment", "box.shipment":"Shipment",
"box.standard_carton_size":"Standard carton size", "box.standard_carton_size":"Standard carton size",
@@ -347,11 +346,11 @@
"box.no_carton":"There is no cartons in this shipment.", "box.no_carton":"There is no cartons in this shipment.",
"box.crete.carton":"Create carton", "box.crete.carton":"Create carton",
"box.carton.type":"ပုံး အမျိုးအစား", "box.carton.type":"ပုံး အမျိုးအစား",
"box.select.delivery":"Select delivery type", "box.select.delivery":"Last mile",
"box.select.package":"Select packages", "box.select.package":"Select packages",
"box.no_package":"There is no packages.", "box.no_package":"There is no packages.",
"box.input_cargo_weight":"Input cargo weight (lb)", "box.input_cargo_weight":"Cargo type (lb)",
"box.input_surcharge_item":"Input surcharge items", "box.input_surcharge_item":"Surcharge items",
"box.select.cargo_type":"Select surcharge item", "box.select.cargo_type":"Select surcharge item",
"box.surcharge.item":"Surcharge items", "box.surcharge.item":"Surcharge items",
"box.package.count":"Packages ({0})", "box.package.count":"Packages ({0})",
@@ -369,6 +368,8 @@
"box.invoice.confirm":"ပြေစာ အတည်ပြုပါ ?", "box.invoice.confirm":"ပြေစာ အတည်ပြုပါ ?",
"box.print.qr.title":"QRCode ပရင့်ထုတ်ရန်", "box.print.qr.title":"QRCode ပရင့်ထုတ်ရန်",
"box.print.btn":"ပရင့်ထုတ်မည်", "box.print.btn":"ပရင့်ထုတ်မည်",
"box.delivery":"Delivery",
"box.pickup":"Pick-up",
"Boxes End ================================================================":"", "Boxes End ================================================================":"",
"Delivery Start ================================================================":"", "Delivery Start ================================================================":"",

View File

@@ -89,8 +89,8 @@ const shipment_local_dropoff = "Local drop off";
const shipment_courier_dropoff = "Courier drop off"; const shipment_courier_dropoff = "Courier drop off";
//Carton types //Carton types
const carton_from_packages = "Carton for packages"; const carton_from_packages = "For packages";
const carton_mix_carton = "Mix carton"; const carton_mix_carton = "For cartons (Mix carton)";
const carton_from_cartons = "From cartons"; const carton_from_cartons = "From cartons";
const carton_from_shipments = "From shipments"; const carton_from_shipments = "From shipments";
@@ -140,8 +140,8 @@ const payment_confirmed_status = "confirmed";
const payment_canceled_status = "canceled"; const payment_canceled_status = "canceled";
//Delivery types //Delivery types
const delivery_caton = "Delivery carton"; const delivery_caton = "Delivery";
const pickup_carton = "Pick-up carton"; const pickup_carton = "Pick-up";
// bill // bill
const billToSender = "Bill to sender"; const billToSender = "Bill to sender";

View File

@@ -88,4 +88,24 @@ class SharedPref {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
prefs.remove(key); prefs.remove(key);
} }
static Future<void> saveRecentSearch(String key, String query) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
//Use `Set` to avoid duplication of recentSearches
Set<String> allSearches = prefs.getStringList(key)?.toSet() ?? {};
//Place it at first in the set
allSearches = {query, ...allSearches};
prefs.setStringList(key, allSearches.toList());
}
static Future<List<String>?> getRecentSearch(String key, String query) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
final allSearches = prefs.getStringList(key);
return allSearches!.where((search) => search.startsWith(query)).toList();
}
static Future<void> clearRecentSearch(String key) async {
return await _remove(key);
}
} }

View File

@@ -151,6 +151,7 @@ class _CargoWidgetState extends State<CargoWidget> {
); );
final userRow = Row( final userRow = Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Expanded(child: senderBox, flex: 2), Expanded(child: senderBox, flex: 2),
Flexible(child: consigneeBox) Flexible(child: consigneeBox)
@@ -265,7 +266,7 @@ class _CargoWidgetState extends State<CargoWidget> {
_surchargeControllers.clear(); _surchargeControllers.clear();
_surchareItems.asMap().entries.forEach((e) { _surchareItems.asMap().entries.forEach((e) {
var editor = new TextEditingController(); var editor = new TextEditingController();
editor.text = e.value.qty == 0 ? "" : e.value.qty.toString(); editor.text = e.value.qty.toString();
_surchargeControllers.add(editor); _surchargeControllers.add(editor);
}); });
@@ -314,6 +315,12 @@ class _CargoWidgetState extends State<CargoWidget> {
final continueBtn = ContinueButton( final continueBtn = ContinueButton(
onTap: () { onTap: () {
if (widget.onContinue != null) { if (widget.onContinue != null) {
if(_surchareItems.isNotEmpty && _surchareItems.any((item)=> item.qty == 0)){
showMsgDialog(context, "Error", "Please insert surcharge item quantity");
return;
}
widget.onContinue!(_cargoTypes, _surchareItems); widget.onContinue!(_cargoTypes, _surchareItems);
} }
}, },

View File

@@ -167,6 +167,11 @@ class _CartonFilterState extends State<CartonFilter> {
final _titleWidget = SizedBox( final _titleWidget = SizedBox(
height: 30, height: 30,
child: Theme(
data: ThemeData(
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
),
child: TabBar( child: TabBar(
unselectedLabelColor: Colors.grey, unselectedLabelColor: Colors.grey,
labelColor: primaryColor, labelColor: primaryColor,
@@ -189,6 +194,7 @@ class _CartonFilterState extends State<CartonFilter> {
), ),
], ],
), ),
),
); );
final _shipmentWidget = Column( final _shipmentWidget = Column(

View File

@@ -16,7 +16,6 @@ import '../widgets/box_size_picker.dart';
import '../widgets/continue_button.dart'; import '../widgets/continue_button.dart';
import '../widgets/display_text.dart'; import '../widgets/display_text.dart';
import '../widgets/local_dropdown.dart'; import '../widgets/local_dropdown.dart';
import '../widgets/local_radio_buttons.dart';
import '../widgets/local_text.dart'; import '../widgets/local_text.dart';
import '../widgets/local_title.dart'; import '../widgets/local_title.dart';
import '../widgets/previous_button.dart'; import '../widgets/previous_button.dart';
@@ -62,7 +61,7 @@ class CartonSizeWidget extends StatefulWidget {
} }
class _CartonSizeWidgetState extends State<CartonSizeWidget> { class _CartonSizeWidgetState extends State<CartonSizeWidget> {
List<String> _deliveryTypes = [delivery_caton, pickup_carton]; // List<String> _deliveryTypes = [delivery_caton, pickup_carton];
FcsShipment? _shipment; FcsShipment? _shipment;
String _cartonSizeType = standardCarton; String _cartonSizeType = standardCarton;
@@ -132,7 +131,7 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
text: widget.sender.name, text: widget.sender.name,
labelTextKey: "box.sender.title", labelTextKey: "box.sender.title",
iconData: MaterialCommunityIcons.account_arrow_right, iconData: MaterialCommunityIcons.account_arrow_right,
subText: Text(widget.sender.fcsID!, subText: Text(widget.sender.fcsID ?? "",
style: TextStyle(fontSize: 13, color: labelColor)), style: TextStyle(fontSize: 13, color: labelColor)),
); );
@@ -145,6 +144,7 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
); );
final userRow = Row( final userRow = Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Expanded( Expanded(
child: senderBox, child: senderBox,
@@ -154,14 +154,71 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
], ],
); );
final deliveryTypeBox = LocalRadioButtons( final deliveryTypeBox = Container(
values: _deliveryTypes, child: Row(
selectedValue: _selectedDeliveryType, children: [
callback: (String? v) { Flexible(
child: InkWell(
onTap: () {
setState(() { setState(() {
_selectedDeliveryType = v!; _selectedDeliveryType = delivery_caton;
}); });
},
child: Row(children: <Widget>[
LocalRadio(
value: delivery_caton,
groupValue: _selectedDeliveryType,
onChanged: (p0) {
setState(() {
_selectedDeliveryType = delivery_caton;
}); });
},
),
Flexible(
child: Padding(
padding: const EdgeInsets.only(left: 10),
child: LocalText(context, 'box.delivery',
fontSize: 15,
color: _selectedDeliveryType == delivery_caton
? primaryColor
: Colors.black),
),
)
]),
)),
Flexible(
child: InkWell(
onTap: () {
setState(() {
_selectedDeliveryType = pickup_carton;
});
},
child: Row(children: <Widget>[
LocalRadio(
value: pickup_carton,
groupValue: _selectedDeliveryType,
onChanged: (p0) {
setState(() {
_selectedDeliveryType = pickup_carton;
});
},
),
Flexible(
child: Padding(
padding: const EdgeInsets.only(left: 10),
child: LocalText(context, 'box.pickup',
fontSize: 15,
color: _selectedDeliveryType == pickup_carton
? primaryColor
: Colors.black),
),
)
]),
),
)
],
),
);
final billRadioBox = Container( final billRadioBox = Container(
child: Row( child: Row(
@@ -186,7 +243,7 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
Flexible( Flexible(
child: Padding( child: Padding(
padding: const EdgeInsets.only(left: 10), padding: const EdgeInsets.only(left: 10),
child: LocalText(context, 'box.bill_to_sender', child: LocalText(context, 'box.sender.title',
fontSize: 15, fontSize: 15,
color: _billToValue == billToSender color: _billToValue == billToSender
? primaryColor ? primaryColor
@@ -215,7 +272,7 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
Flexible( Flexible(
child: Padding( child: Padding(
padding: const EdgeInsets.only(left: 10), padding: const EdgeInsets.only(left: 10),
child: LocalText(context, 'box.bill_to.consignee', child: LocalText(context, 'box.consignee.title',
fontSize: 15, fontSize: 15,
color: _billToValue == billToConsignee color: _billToValue == billToConsignee
? primaryColor ? primaryColor
@@ -465,12 +522,14 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
children: [ children: [
const SizedBox(height: 8), const SizedBox(height: 8),
userRow, userRow,
LocalTitle(textKey: "box.bill_to", topPadding: 8),
const SizedBox(height: 5), const SizedBox(height: 5),
billRadioBox, billRadioBox,
const SizedBox(height: 8),
LocalTitle(textKey: "box.select.delivery"), LocalTitle(textKey: "box.select.delivery"),
const SizedBox(height: 5), const SizedBox(height: 5),
deliveryTypeBox, deliveryTypeBox,
const SizedBox(height: 5), const SizedBox(height: 8),
LocalTitle(textKey: "box.select_carton_size"), LocalTitle(textKey: "box.select_carton_size"),
const SizedBox(height: 8), const SizedBox(height: 8),
cartonSizedBox, cartonSizedBox,

View File

@@ -71,7 +71,8 @@ class CartonSubmit extends StatelessWidget {
child: SubmitTextWidget( child: SubmitTextWidget(
labelKey: 'box.carton.type', labelKey: 'box.carton.type',
text: carton_from_packages, text: carton_from_packages,
subText: boxDimension), // subText: boxDimension
),
); );
final shipmentBox = Padding( final shipmentBox = Padding(
@@ -135,9 +136,9 @@ class CartonSubmit extends StatelessWidget {
], ],
), ),
), ),
billToValue == billToSender // billToValue == billToSender
? billWidget(context) // ? billWidget(context)
: const SizedBox() // : const SizedBox()
], ],
), ),
), ),
@@ -162,9 +163,9 @@ class CartonSubmit extends StatelessWidget {
], ],
), ),
), ),
billToValue == billToConsignee // billToValue == billToConsignee
? billWidget(context) // ? billWidget(context)
: const SizedBox() // : const SizedBox()
], ],
), ),
)) ))
@@ -174,14 +175,30 @@ class CartonSubmit extends StatelessWidget {
]), ]),
); );
final billToBox = Padding(
padding: const EdgeInsets.only(top: 10),
child: SubmitTextWidget(
labelKey: 'box.bill_to',
text: billToValue == billToSender ? 'Sender' : 'Consignee',
),
);
final deliveryTypeBox = Padding( final deliveryTypeBox = Padding(
padding: const EdgeInsets.only(top: 10), padding: const EdgeInsets.only(top: 10),
child: SubmitTextWidget( child: SubmitTextWidget(
labelKey: 'box.delivery_type', labelKey: 'box.select.delivery',
text: deliveryType, text: deliveryType,
), ),
); );
final cartonSizeBox = Padding(
padding: const EdgeInsets.only(top: 10),
child: SubmitTextWidget(
labelKey: 'box.carton_size',
text: boxDimension??'',
),
);
final packagesBox = Padding( final packagesBox = Padding(
padding: const EdgeInsets.only(top: 10), padding: const EdgeInsets.only(top: 10),
child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [ child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
@@ -341,12 +358,16 @@ class CartonSubmit extends StatelessWidget {
children: [ children: [
cartonType, cartonType,
const SizedBox(height: 10), const SizedBox(height: 10),
shipmentBox,
const SizedBox(height: 10),
usersBox, usersBox,
const SizedBox(height: 10), const SizedBox(height: 10),
billToBox,
const SizedBox(height: 10),
deliveryTypeBox, deliveryTypeBox,
const SizedBox(height: 10), const SizedBox(height: 10),
cartonSizeBox,
const SizedBox(height: 10),
shipmentBox,
const SizedBox(height: 10),
packages.isNotEmpty ? packagesBox : const SizedBox(), packages.isNotEmpty ? packagesBox : const SizedBox(),
const SizedBox(height: 10), const SizedBox(height: 10),
cargosBox, cargosBox,

View File

@@ -3,7 +3,6 @@ import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/main/util.dart'; import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/rates/model/shipment_rate_model.dart'; import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
import 'package:fcs/pages/widgets/local_app_bar.dart'; import 'package:fcs/pages/widgets/local_app_bar.dart';
import 'package:fcs/pages/widgets/local_title.dart';
import 'package:fcs/pages/widgets/progress.dart'; import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@@ -117,9 +116,6 @@ class _CustomDutyAdditionState extends State<CustomDutyAddition> {
child: ListView( child: ListView(
shrinkWrap: true, shrinkWrap: true,
children: <Widget>[ children: <Widget>[
LocalTitle(
textKey: "box.select.cargo.title",
),
Column( Column(
children: getCargoRowList(customDuties), children: getCargoRowList(customDuties),
), ),

View File

@@ -112,7 +112,15 @@ class _MixCartonSubmitState extends State<MixCartonSubmit> {
child: SubmitTextWidget( child: SubmitTextWidget(
labelKey: 'box.carton.type', labelKey: 'box.carton.type',
text: carton_mix_carton, text: carton_mix_carton,
subText: boxDimension, // subText: boxDimension,
),
);
final cartonSizeBox = Padding(
padding: const EdgeInsets.only(top: 10),
child: SubmitTextWidget(
labelKey: 'box.carton_size',
text: boxDimension ?? '',
), ),
); );
@@ -284,6 +292,8 @@ class _MixCartonSubmitState extends State<MixCartonSubmit> {
children: [ children: [
cartonType, cartonType,
const SizedBox(height: 10), const SizedBox(height: 10),
cartonSizeBox,
const SizedBox(height: 10),
shipmentBox, shipmentBox,
const SizedBox(height: 10), const SizedBox(height: 10),
widget.cartons.isNotEmpty ? cartonsBox : const SizedBox(), widget.cartons.isNotEmpty ? cartonsBox : const SizedBox(),

View File

@@ -126,6 +126,7 @@ class _PackageSelectionWidgetState extends State<PackageSelectionWidget> {
); );
final userRow = Row( final userRow = Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Expanded( Expanded(
child: senderBox, child: senderBox,

View File

@@ -31,7 +31,7 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
bool _isLoading = false; bool _isLoading = false;
bool _isNew = true; bool _isNew = true;
final _deliveryFormKey=GlobalKey<FormState>(); final _deliveryFormKey = GlobalKey<FormState>();
@override @override
void initState() { void initState() {
@@ -64,8 +64,8 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
controller: _nameController, controller: _nameController,
autovalidateMode: AutovalidateMode.onUserInteraction, autovalidateMode: AutovalidateMode.onUserInteraction,
validator: (value) { validator: (value) {
if(value==null || value.isEmpty){ if (value == null || value.isEmpty) {
return"Please enter full name"; return "Please enter full name";
} }
return null; return null;
}); });
@@ -76,8 +76,8 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
controller: _address1Controller, controller: _address1Controller,
autovalidateMode: AutovalidateMode.onUserInteraction, autovalidateMode: AutovalidateMode.onUserInteraction,
validator: (value) { validator: (value) {
if(value==null || value.isEmpty){ if (value == null || value.isEmpty) {
return"Please enter address"; return "Please enter address";
} }
return null; return null;
}); });
@@ -93,8 +93,8 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
controller: _cityController, controller: _cityController,
autovalidateMode: AutovalidateMode.onUserInteraction, autovalidateMode: AutovalidateMode.onUserInteraction,
validator: (value) { validator: (value) {
if(value==null || value.isEmpty){ if (value == null || value.isEmpty) {
return"Please enter city"; return "Please enter city";
} }
return null; return null;
}); });
@@ -105,8 +105,8 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
controller: _stateController, controller: _stateController,
autovalidateMode: AutovalidateMode.onUserInteraction, autovalidateMode: AutovalidateMode.onUserInteraction,
validator: (value) { validator: (value) {
if(value==null || value.isEmpty){ if (value == null || value.isEmpty) {
return"Please enter state/region"; return "Please enter state/region";
} }
return null; return null;
}); });
@@ -118,8 +118,8 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
controller: _phoneController, controller: _phoneController,
autovalidateMode: AutovalidateMode.onUserInteraction, autovalidateMode: AutovalidateMode.onUserInteraction,
validator: (value) { validator: (value) {
if(value==null || value.isEmpty){ if (value == null || value.isEmpty) {
return"Please enter phone number"; return "Please enter phone number";
} }
return null; return null;
}); });
@@ -207,7 +207,7 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
} }
Future<bool> _validate(DeliveryAddress deliveryAddress) async { Future<bool> _validate(DeliveryAddress deliveryAddress) async {
if(_deliveryFormKey.currentState!.validate()){ if (!_deliveryFormKey.currentState!.validate()) {
return false; return false;
} }
// if (deliveryAddress.addressLine1 == "") { // if (deliveryAddress.addressLine1 == "") {

View File

@@ -87,7 +87,7 @@ class FcsShipmentModel extends BaseModel {
try { try {
var snaps = await FirebaseFirestore.instance var snaps = await FirebaseFirestore.instance
.collection("/$fcs_shipment_collection") .collection("/$fcs_shipment_collection")
.where("status", isEqualTo: fcs_shipment_processed_status) // .where("status", isEqualTo: fcs_shipment_processed_status)
.get(const GetOptions(source: Source.server)); .get(const GetOptions(source: Source.server));
fcsShipments = snaps.docs.map((documentSnapshot) { fcsShipments = snaps.docs.map((documentSnapshot) {
var fcs = var fcs =

View File

@@ -13,6 +13,8 @@ import 'package:fcs/pagination/paginator_listener.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:path/path.dart' as Path; import 'package:path/path.dart' as Path;
import '../../../helpers/shared_pref.dart';
class PackageModel extends BaseModel { class PackageModel extends BaseModel {
final log = Logger('PackageModel'); final log = Logger('PackageModel');
@@ -214,7 +216,10 @@ class PackageModel extends BaseModel {
return packages; return packages;
} }
Future<List<User>> searchUser(String term) { Future<List<User>> searchUser(String term) async {
if (term != '') {
await SharedPref.saveRecentSearch('account_search', term);
}
return Services.instance.userService.searchUser(term); return Services.instance.userService.searchUser(term);
} }

View File

@@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../../data/services/services.dart'; import '../../data/services/services.dart';
import '../../helpers/shared_pref.dart';
import '../widgets/suggest_list.dart';
typedef OnUserSelect(User suer); typedef OnUserSelect(User suer);
typedef OnUserRowSelect(User suer); typedef OnUserRowSelect(User suer);
@@ -79,7 +81,7 @@ class UserSearchDelegate extends SearchDelegate<User> {
child: Text( child: Text(
"No result found", "No result found",
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle(color:Colors.black), style: TextStyle(color: Colors.black),
), ),
), ),
); );
@@ -118,14 +120,28 @@ class UserSearchDelegate extends SearchDelegate<User> {
@override @override
Widget buildSuggestions(BuildContext context) { Widget buildSuggestions(BuildContext context) {
return Container( return FutureBuilder<List<String>?>(
child: Center( future: SharedPref.getRecentSearch('account_search', query),
builder: (context, snapshot) {
List<String> _oldFilters = snapshot.data ?? [];
if (_oldFilters.isEmpty) {
return const Center(
child: Opacity( child: Opacity(
opacity: 0.2, opacity: 0.2,
child: Icon(Icons.perm_identity, size: 200, color: primaryColor)), child: Icon(Icons.perm_identity, color: primaryColor, size: 200),
), ),
); );
} }
return SuggestList(
recentSearchList: _oldFilters,
onTap: (String s) {
query = s;
showResults(context);
},
prefKey: 'account_search');
},
);
}
_onUserRowSelect(BuildContext context, User user) async { _onUserRowSelect(BuildContext context, User user) async {
User? u = await Services.instance.userService.getUser(user.id ?? ""); User? u = await Services.instance.userService.getUser(user.id ?? "");

View File

@@ -0,0 +1,53 @@
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../helpers/theme.dart';
typedef OnTap = Function(String query);
class SuggestList extends StatefulWidget {
final List<String>? recentSearchList;
final String prefKey;
final OnTap? onTap;
const SuggestList(
{Key? key, this.recentSearchList, this.onTap, required this.prefKey})
: super(key: key);
@override
_SuggestListState createState() => _SuggestListState();
}
class _SuggestListState extends State<SuggestList> {
@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: widget.recentSearchList?.length,
itemBuilder: (context, index) {
return ListTile(
leading: const Icon(Icons.restore, color: labelColor),
title: Text(
widget.recentSearchList?[index] ?? '',
style: const TextStyle(color: primaryColor),
),
onTap: () {
if (widget.onTap != null) {
widget.onTap!(widget.recentSearchList![index]);
}
},
trailing: IconButton(
icon: const Icon(Icons.close, color: labelColor),
onPressed: () async {
setState(() {
widget.recentSearchList
?.remove(widget.recentSearchList?[index]);
});
final prefs = await SharedPreferences.getInstance();
prefs.setStringList(widget.prefKey, widget.recentSearchList!);
setState(() {});
},
),
);
},
);
}
}