This commit is contained in:
2024-09-24 08:21:22 +06:30
18 changed files with 335 additions and 118 deletions

View File

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

View File

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

View File

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

View File

@@ -88,4 +88,24 @@ class SharedPref {
final prefs = await SharedPreferences.getInstance();
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(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(child: senderBox, flex: 2),
Flexible(child: consigneeBox)
@@ -265,7 +266,7 @@ class _CargoWidgetState extends State<CargoWidget> {
_surchargeControllers.clear();
_surchareItems.asMap().entries.forEach((e) {
var editor = new TextEditingController();
editor.text = e.value.qty == 0 ? "" : e.value.qty.toString();
editor.text = e.value.qty.toString();
_surchargeControllers.add(editor);
});
@@ -314,6 +315,12 @@ class _CargoWidgetState extends State<CargoWidget> {
final continueBtn = ContinueButton(
onTap: () {
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);
}
},

View File

@@ -167,27 +167,33 @@ class _CartonFilterState extends State<CartonFilter> {
final _titleWidget = SizedBox(
height: 30,
child: TabBar(
unselectedLabelColor: Colors.grey,
labelColor: primaryColor,
indicatorColor: primaryColor,
indicatorSize: TabBarIndicatorSize.tab,
labelPadding: const EdgeInsets.all(0),
indicatorPadding: const EdgeInsets.all(0),
tabs: [
Tab(
text: AppTranslations.of(context)?.text("box.fcs_shipment_num"),
),
Tab(
text: AppTranslations.of(context)?.text("box.consignee.title"),
),
Tab(
text: AppTranslations.of(context)?.text("box.sender.title"),
),
Tab(
text: AppTranslations.of(context)?.text("box.status"),
),
],
child: Theme(
data: ThemeData(
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
),
child: TabBar(
unselectedLabelColor: Colors.grey,
labelColor: primaryColor,
indicatorColor: primaryColor,
indicatorSize: TabBarIndicatorSize.tab,
labelPadding: const EdgeInsets.all(0),
indicatorPadding: const EdgeInsets.all(0),
tabs: [
Tab(
text: AppTranslations.of(context)?.text("box.fcs_shipment_num"),
),
Tab(
text: AppTranslations.of(context)?.text("box.consignee.title"),
),
Tab(
text: AppTranslations.of(context)?.text("box.sender.title"),
),
Tab(
text: AppTranslations.of(context)?.text("box.status"),
),
],
),
),
);

View File

@@ -90,7 +90,7 @@ class _CartonInfoState extends State<CartonInfo> {
@override
Widget build(BuildContext context) {
String? boxDimension = _carton.cartonSizeType == standardCarton
String? boxDimension = _carton.cartonSizeType == standardCarton
? "${standardSize?.name} - ${standardSize?.length.toInt()}”x${standardSize?.width.toInt()}”x${standardSize?.height.toInt()}"
: _carton.cartonSizeType == customCarton
? "${_carton.length.toInt()}”x${_carton.width.toInt()}”x${_carton.height.toInt()}"
@@ -113,12 +113,20 @@ class _CartonInfoState extends State<CartonInfo> {
final cartonSubTypeBox = DisplayText(
text: _carton.cartonType == carton_from_packages
? "Carton for packages"
? "For packages"
: "Mix carton",
subText: boxDimension == null ? null : Text("$boxDimension"),
labelTextKey: "box.carton.type",
);
final billInfoBox = DisplayText(
text: _carton.billTo == billToSender
? "Sender"
: _carton.billTo == billToConsignee
? "Consignee"
: null,
labelTextKey: "box.bill_to",
);
final shipmentBox = DisplayText(
text: _carton.fcsShipmentNumber,
labelTextKey: "box.fcs_shipment_num",
@@ -129,6 +137,11 @@ class _CartonInfoState extends State<CartonInfo> {
labelTextKey: "box.delivery_type",
);
final cartonSizeBox = DisplayText(
subText: boxDimension == null ? null : Text("$boxDimension"),
labelTextKey: "box.carton_size",
);
final senderBox = DisplayText(
text: _carton.senderName == null ? "" : _carton.senderName,
subText: Text(_carton.senderFCSID ?? "", style: textStyle),
@@ -141,18 +154,18 @@ class _CartonInfoState extends State<CartonInfo> {
labelTextKey: "processing.consignee.name",
);
final billWidget = Expanded(
child: Padding(
padding: EdgeInsets.only(left: 0, top: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Icon(Ionicons.document_text_outline,
color: primaryColor, size: 20),
Text("Bill to",
style: TextStyle(color: primaryColor, fontSize: 15))
],
)));
// final billWidget = Expanded(
// child: Padding(
// padding: EdgeInsets.only(left: 0, top: 15),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.start,
// children: [
// Icon(Ionicons.document_text_outline,
// color: primaryColor, size: 20),
// Text("Bill to",
// style: TextStyle(color: primaryColor, fontSize: 15))
// ],
// )));
final userRowBox = Row(
mainAxisAlignment: MainAxisAlignment.start,
@@ -169,7 +182,7 @@ class _CartonInfoState extends State<CartonInfo> {
],
),
),
_carton.billTo == billToSender ? billWidget : const SizedBox()
// _carton.billTo == billToSender ? billWidget : const SizedBox()
],
),
),
@@ -185,7 +198,7 @@ class _CartonInfoState extends State<CartonInfo> {
],
),
),
_carton.billTo == billToConsignee ? billWidget : const SizedBox()
// _carton.billTo == billToConsignee ? billWidget : const SizedBox()
],
))
],
@@ -354,26 +367,34 @@ class _CartonInfoState extends State<CartonInfo> {
padding: const EdgeInsets.only(left: 20, right: 20),
child: ListView(children: <Widget>[
Row(children: [
Flexible(child: cartonTypeBox),
Flexible(child: cartonTypeBox,flex: 1),
Flexible(
child: cartonQrBox,
),
]),
Row(
children: [
Flexible(child: cartonSubTypeBox),
],
),
_mixCartons.isEmpty ? userRowBox : const SizedBox(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(child: billInfoBox),
Flexible(child: shipmentBox),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_mixCartons.isEmpty
? Flexible(child: deliveryBox)
: const SizedBox(),
Flexible(child: cartonSizeBox),
],
),
_mixCartons.isEmpty ? userRowBox : const SizedBox(),
_packages.isEmpty
? const SizedBox()
: Padding(

View File

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

View File

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

View File

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

View File

@@ -112,7 +112,15 @@ class _MixCartonSubmitState extends State<MixCartonSubmit> {
child: SubmitTextWidget(
labelKey: 'box.carton.type',
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: [
cartonType,
const SizedBox(height: 10),
cartonSizeBox,
const SizedBox(height: 10),
shipmentBox,
const SizedBox(height: 10),
widget.cartons.isNotEmpty ? cartonsBox : const SizedBox(),

View File

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

View File

@@ -31,7 +31,7 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
bool _isLoading = false;
bool _isNew = true;
final _deliveryFormKey=GlobalKey<FormState>();
final _deliveryFormKey = GlobalKey<FormState>();
@override
void initState() {
@@ -64,8 +64,8 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
controller: _nameController,
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: (value) {
if(value==null || value.isEmpty){
return"Please enter full name";
if (value == null || value.isEmpty) {
return "Please enter full name";
}
return null;
});
@@ -74,10 +74,10 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
labelTextKey: 'delivery_address.address_line1',
iconData: Icons.location_on,
controller: _address1Controller,
autovalidateMode: AutovalidateMode.onUserInteraction,
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: (value) {
if(value==null || value.isEmpty){
return"Please enter address";
if (value == null || value.isEmpty) {
return "Please enter address";
}
return null;
});
@@ -91,10 +91,10 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
labelTextKey: 'delivery_address.city',
iconData: Icons.location_city,
controller: _cityController,
autovalidateMode: AutovalidateMode.onUserInteraction,
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: (value) {
if(value==null || value.isEmpty){
return"Please enter city";
if (value == null || value.isEmpty) {
return "Please enter city";
}
return null;
});
@@ -103,10 +103,10 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
labelTextKey: 'delivery_address.state_region',
iconData: Entypo.location,
controller: _stateController,
autovalidateMode: AutovalidateMode.onUserInteraction,
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: (value) {
if(value==null || value.isEmpty){
return"Please enter state/region";
if (value == null || value.isEmpty) {
return "Please enter state/region";
}
return null;
});
@@ -116,10 +116,10 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
iconData: Icons.phone,
textInputType: TextInputType.phone,
controller: _phoneController,
autovalidateMode: AutovalidateMode.onUserInteraction,
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: (value) {
if(value==null || value.isEmpty){
return"Please enter phone number";
if (value == null || value.isEmpty) {
return "Please enter phone number";
}
return null;
});
@@ -207,7 +207,7 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
}
Future<bool> _validate(DeliveryAddress deliveryAddress) async {
if(_deliveryFormKey.currentState!.validate()){
if (!_deliveryFormKey.currentState!.validate()) {
return false;
}
// if (deliveryAddress.addressLine1 == "") {
@@ -236,7 +236,7 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
if (!valid) {
return;
}
if (widget.user != null) {
deliveryAddress.userID = widget.user!.id;
}

View File

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

View File

@@ -13,6 +13,8 @@ import 'package:fcs/pagination/paginator_listener.dart';
import 'package:logging/logging.dart';
import 'package:path/path.dart' as Path;
import '../../../helpers/shared_pref.dart';
class PackageModel extends BaseModel {
final log = Logger('PackageModel');
@@ -214,7 +216,10 @@ class PackageModel extends BaseModel {
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);
}

View File

@@ -86,7 +86,7 @@ class _ProfileState extends State<Profile> {
);
final deleteAccountBox = DisplayText(
labelTextKey: "profile.delete.title",
iconData: MaterialCommunityIcons.delete,
iconData: MaterialCommunityIcons.account_remove,
);
final phonenumberbox = DisplayText(

View File

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

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(() {});
},
),
);
},
);
}
}