diff --git a/lib/domain/constants.dart b/lib/domain/constants.dart index f7cb5cf..865a62a 100644 --- a/lib/domain/constants.dart +++ b/lib/domain/constants.dart @@ -69,6 +69,7 @@ const privilege_delivery = "deli"; const privilege_invoice = "inv"; const privilege_processing = "pr"; const privilege_receiving = "rc"; +const privilege_pickup = "pku"; // Pickup types const shipment_local_pickup = "Local pickup"; diff --git a/lib/domain/entities/carton.dart b/lib/domain/entities/carton.dart index 22254ac..c17940e 100644 --- a/lib/domain/entities/carton.dart +++ b/lib/domain/entities/carton.dart @@ -64,9 +64,8 @@ class Carton { // String get packageNumber => // shipmentNumber + "-" + receiverNumber + " #" + boxNumber; - double get actualWeight => cargoTypes == null - ? 0 - : cargoTypes.fold(0, (p, e) => e.weight + p); + double get actualWeight => + cargoTypes == null ? 0 : cargoTypes.fold(0, (p, e) => e.weight + p); int getShipmentWeight(double volumetricRatio) { if (length == null || @@ -110,13 +109,12 @@ class Carton { double wd = sw - aw; wd = wd - rate.diffDiscountWeight; double wdAmount = wd > 0 ? wd * rate.diffWeightRate : 0; - DiscountByWeight discountByWeight = rate.getDiscountByWeight(aw); double total = 0; cargoTypes.forEach((e) { - double r = e.rate - - (discountByWeight != null ? (discountByWeight.discount) : 0); + double r = + e.rate - (discountByWeight != null ? (discountByWeight.discount) : 0); double amount = e.weight * r; total += amount; }); @@ -194,7 +192,8 @@ class Carton { } factory Carton.fromMap(Map map, String docID) { - var _arrivedDate = (map['arrived_date'] as Timestamp); + var _arrivedDate = + map['arrived_date'] == null ? null : (map['arrived_date'] as Timestamp); var da = map['delivery_address']; var _da = da != null ? DeliveryAddress.fromMap(da, da["id"]) : null; var cargoTypesMaps = diff --git a/lib/domain/entities/rate.dart b/lib/domain/entities/rate.dart index 54442e8..50f0f8c 100644 --- a/lib/domain/entities/rate.dart +++ b/lib/domain/entities/rate.dart @@ -16,10 +16,12 @@ class Rate { DiscountByWeight getDiscountByWeight(double weight) { discountByWeights.sort((d1, d2) => d2.weight.compareTo(d1.weight)); - return discountByWeights.firstWhere((e) => e.weight < weight); + return discountByWeights.firstWhere((e) => e.weight < weight, + orElse: () => DiscountByWeight()); } - CargoType get defaultCargoType => cargoTypes.firstWhere((e) => e.name == "General"); + CargoType get defaultCargoType => + cargoTypes.firstWhere((e) => e.name == "General"); Rate( {this.deliveryFee = 0, diff --git a/lib/domain/entities/shipment.dart b/lib/domain/entities/shipment.dart index 2d4cabc..d1b31d6 100644 --- a/lib/domain/entities/shipment.dart +++ b/lib/domain/entities/shipment.dart @@ -52,7 +52,7 @@ class Shipment { this.pickupDate, this.isCourier = false, this.radioIndex = 1, - required this.pickupAddress, + this.pickupAddress, this.pickupUserID, this.pickupUserName, this.pickupUserPhoneNumber, diff --git a/lib/domain/vo/privilege.dart b/lib/domain/vo/privilege.dart index 85907a2..ac0926b 100644 --- a/lib/domain/vo/privilege.dart +++ b/lib/domain/vo/privilege.dart @@ -43,6 +43,8 @@ class Privilege { iconData = FontAwesome.dropbox; } else if (this.id == privilege_receiving) { iconData = MaterialCommunityIcons.inbox_arrow_down; + } else if (this.id == privilege_pickup) { + iconData = SimpleLineIcons.direction; } else { iconData = MaterialCommunityIcons.account_question; } diff --git a/lib/pages/carton/cargo_table.dart b/lib/pages/carton/cargo_table.dart index 9266868..5e9d5ac 100644 --- a/lib/pages/carton/cargo_table.dart +++ b/lib/pages/carton/cargo_table.dart @@ -22,25 +22,26 @@ class _CargoTableState extends State { Widget build(BuildContext context) { return SingleChildScrollView( scrollDirection: Axis.horizontal, - child: MyDataTable( + child: DataTable( headingRowHeight: 40, columnSpacing: 50, + showCheckboxColumn: false, columns: [ - MyDataColumn( + DataColumn( label: LocalText( context, "cargo.type", color: Colors.grey, ), ), - MyDataColumn( + DataColumn( label: LocalText( context, "cargo.qty", color: Colors.grey, ), ), - MyDataColumn( + DataColumn( label: LocalText( context, "cargo.weight", @@ -53,21 +54,21 @@ class _CargoTableState extends State { ); } - List getCargoRows(BuildContext context) { + List getCargoRows(BuildContext context) { if (widget.cargoTypes == null) { return []; } double total = 0; var rows = widget.cargoTypes!.map((c) { total += c.weight; - return MyDataRow( - onSelectChanged: (bool selected) async {}, + return DataRow( + onSelectChanged: (bool? selected) async {}, cells: [ - MyDataCell(new Text( + DataCell(new Text( c.name ?? "", style: textStyle, )), - MyDataCell(c.qty == null || c.qty == 0 + DataCell(c.qty == null || c.qty == 0 ? Center( child: Text( "-", @@ -80,7 +81,7 @@ class _CargoTableState extends State { style: textStyle, ), )), - MyDataCell( + DataCell( Text(c.weight == null ? "0" : c.weight.toStringAsFixed(2), style: textStyle), ), @@ -88,10 +89,10 @@ class _CargoTableState extends State { ); }).toList(); - var totalRow = MyDataRow( - onSelectChanged: (bool selected) {}, + var totalRow = DataRow( + onSelectChanged: (bool? selected) {}, cells: [ - MyDataCell(Align( + DataCell(Align( alignment: Alignment.centerRight, child: LocalText( context, @@ -100,8 +101,8 @@ class _CargoTableState extends State { fontWeight: FontWeight.bold, ), )), - MyDataCell(Text("")), - MyDataCell( + DataCell(Text("")), + DataCell( Padding( padding: const EdgeInsets.only(right: 48.0), child: Align( diff --git a/lib/pages/carton/carton_cargo_table.dart b/lib/pages/carton/carton_cargo_table.dart index cd02930..4aca979 100644 --- a/lib/pages/carton/carton_cargo_table.dart +++ b/lib/pages/carton/carton_cargo_table.dart @@ -3,7 +3,6 @@ import 'package:fcs/helpers/theme.dart'; import 'package:fcs/pages/main/util.dart'; import 'package:fcs/pages/widgets/dialog_input.dart'; import 'package:fcs/pages/widgets/local_text.dart'; -import 'package:fcs/pages/widgets/my_data_table.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -45,25 +44,26 @@ class _CargoTableState extends State { return SingleChildScrollView( scrollDirection: Axis.horizontal, - child: MyDataTable( + child: DataTable( + showCheckboxColumn: false, headingRowHeight: 40, columnSpacing: 40, columns: [ - MyDataColumn( + DataColumn( label: LocalText( context, "cargo.type", color: Colors.grey, ), ), - MyDataColumn( + DataColumn( label: LocalText( context, "cargo.qty", color: Colors.grey, ), ), - MyDataColumn( + DataColumn( label: LocalText( context, "cargo.weight", @@ -76,21 +76,21 @@ class _CargoTableState extends State { ); } - List getCargoRows(BuildContext context) { + List getCargoRows(BuildContext context) { if (cargoTypes == null) { return []; } var rows = cargoTypes!.map((c) { - return MyDataRow( - onSelectChanged: (bool selected) async {}, + return DataRow( + onSelectChanged: (bool? selected) async {}, cells: [ - MyDataCell( + DataCell( new Text( c.name ?? '', style: textStyle, ), ), - MyDataCell( + DataCell( c.isCutomDuty! ? GestureDetector( onTap: () async { @@ -128,7 +128,7 @@ class _CargoTableState extends State { ), ), ), - MyDataCell( + DataCell( Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -185,10 +185,10 @@ class _CargoTableState extends State { ); }).toList(); - var totalRow = MyDataRow( - onSelectChanged: (bool selected) {}, + var totalRow = DataRow( + onSelectChanged: (bool? selected) {}, cells: [ - MyDataCell(Align( + DataCell(Align( alignment: Alignment.centerRight, child: LocalText( context, @@ -197,8 +197,8 @@ class _CargoTableState extends State { fontWeight: FontWeight.bold, ), )), - MyDataCell(Text("")), - MyDataCell( + DataCell(Text("")), + DataCell( Padding( padding: const EdgeInsets.only(right: 48.0), child: Align( diff --git a/lib/pages/carton/carton_cargo_table_old.dart b/lib/pages/carton/carton_cargo_table_old.dart index 05378f2..b2b8ff4 100644 --- a/lib/pages/carton/carton_cargo_table_old.dart +++ b/lib/pages/carton/carton_cargo_table_old.dart @@ -28,17 +28,18 @@ class _CargoTableState extends State { double remainingWeight = 0; @override Widget build(BuildContext context) { - return MyDataTable( + return DataTable( headingRowHeight: 40, + showCheckboxColumn: false, columns: [ - MyDataColumn( + DataColumn( label: LocalText( context, "cargo.type", color: Colors.grey, ), ), - MyDataColumn( + DataColumn( label: Row( children: [ Container( @@ -57,7 +58,7 @@ class _CargoTableState extends State { ); } - List getCargoRows(BuildContext context) { + List getCargoRows(BuildContext context) { if (widget.cargoTypes == null) { return []; } @@ -67,10 +68,10 @@ class _CargoTableState extends State { var rows = widget.cargoTypes!.map((c) { _total += c.weight; - return MyDataRow( - onSelectChanged: (bool selected) async {}, + return DataRow( + onSelectChanged: (bool? selected) async {}, cells: [ - MyDataCell(Row( + DataCell(Row( children: [ new Text( c.name ?? "", @@ -82,7 +83,7 @@ class _CargoTableState extends State { ), ], )), - MyDataCell( + DataCell( Row( mainAxisAlignment: MainAxisAlignment.end, children: [ @@ -106,10 +107,10 @@ class _CargoTableState extends State { ); }).toList(); - var totalRow = MyDataRow( - onSelectChanged: (bool selected) {}, + var totalRow = DataRow( + onSelectChanged: (bool? selected) {}, cells: [ - MyDataCell(Align( + DataCell(Align( alignment: Alignment.centerRight, child: LocalText( context, @@ -118,7 +119,7 @@ class _CargoTableState extends State { fontWeight: FontWeight.bold, ), )), - MyDataCell( + DataCell( Padding( padding: const EdgeInsets.only(right: 40.0), child: Align( @@ -144,7 +145,8 @@ class _CargoTableState extends State { widget.cargoTypes!.forEach((c) { _types.add(c.name!); }); - if (this._cargos.length == widget.cargoTypes!.length - 1) { + if (this._cargos.length == + widget.cargoTypes!.length - 1) { _types.forEach((t) { if (!_list.contains(t)) { widget.cargoTypes!.forEach((c) { diff --git a/lib/pages/carton/carton_editor.dart b/lib/pages/carton/carton_editor.dart index e83d6b1..4cd1c36 100644 --- a/lib/pages/carton/carton_editor.dart +++ b/lib/pages/carton/carton_editor.dart @@ -10,7 +10,6 @@ import 'package:fcs/helpers/theme.dart'; import 'package:fcs/pages/carton/carton_package_table.dart'; import 'package:fcs/pages/carton_search/carton_search.dart'; import 'package:fcs/pages/carton_size/carton_size_list.dart'; -import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart'; import 'package:fcs/pages/fcs_shipment/model/fcs_shipment_model.dart'; import 'package:fcs/pages/main/util.dart'; import 'package:fcs/pages/package/model/package_model.dart'; @@ -40,8 +39,8 @@ import 'package_carton_editor.dart'; import 'widgets.dart'; class CartonEditor extends StatefulWidget { - final Carton? box; - CartonEditor({this.box}); + final Carton? carton; + CartonEditor({this.carton}); @override _CartonEditorState createState() => _CartonEditorState(); @@ -63,7 +62,7 @@ class _CartonEditorState extends State { double volumetricRatio = 0; double shipmentWeight = 0; FcsShipment? _fcsShipment; - List? _fcsShipments; + List _fcsShipments = []; List _cartons = []; CartonSize? selectedCatonSize; @@ -90,8 +89,8 @@ class _CartonEditorState extends State { _widthController.addListener(_calShipmentWeight); _heightController.addListener(_calShipmentWeight); - if (widget.box != null) { - _carton = widget.box; + if (widget.carton != null) { + _carton = widget.carton; _deliveryAddress = _carton!.deliveryAddress; _widthController.text = _carton!.width.toString(); _heightController.text = _carton!.height.toString(); @@ -138,11 +137,13 @@ class _CartonEditorState extends State { FcsShipmentModel fcsShipmentModel = Provider.of(context, listen: false); var fcsShipments = await fcsShipmentModel.getActiveFcsShipments(); - var fcsShipment = - fcsShipments.firstWhere((e) => e.id == _carton!.fcsShipmentID); + + // var fcsShipment = + // fcsShipments.firstWhere((e) => e.id == _carton?.fcsShipmentID); + setState(() { _fcsShipments = fcsShipments; - _fcsShipment = fcsShipment; + // _fcsShipment = fcsShipment; }); } @@ -195,9 +196,9 @@ class _CartonEditorState extends State { // } _calShipmentWeight() { - double l = double.parse(_lengthController.text); - double w = double.parse(_widthController.text); - double h = double.parse(_heightController.text); + double l = double.tryParse(_lengthController.text) ?? 0; + double w = double.tryParse(_widthController.text) ?? 0; + double h = double.tryParse(_heightController.text) ?? 0; setState(() { shipmentWeight = l * w * h / volumetricRatio; }); @@ -248,8 +249,8 @@ class _CartonEditorState extends State { labelKey: "shipment.pack.fcs.shipment", iconData: Ionicons.ios_airplane, display: (u) => u.shipmentNumber, - selectedValue: _fcsShipment!, - values: _fcsShipments!, + selectedValue: _fcsShipment, + values: _fcsShipments, )); final fcsIDBox = Container( diff --git a/lib/pages/carton/carton_info.dart b/lib/pages/carton/carton_info.dart index 68358c3..db67495 100644 --- a/lib/pages/carton/carton_info.dart +++ b/lib/pages/carton/carton_info.dart @@ -144,9 +144,9 @@ class _CartonInfoState extends State { } _calShipmentWeight() { - double l = double.parse(_lengthController.text); - double w = double.parse(_widthController.text); - double h = double.parse(_heightController.text); + double l = double.tryParse(_lengthController.text) ?? 0; + double w = double.tryParse(_widthController.text) ?? 0; + double h = double.tryParse(_heightController.text) ?? 0; setState(() { shipmentWeight = l * w * h / volumetricRatio; }); @@ -412,7 +412,7 @@ class _CartonInfoState extends State { _box!.mixCartons = _box!.mixCartons; bool? updated = await Navigator.push( context, - CupertinoPageRoute(builder: (context) => CartonEditor(box: _box)), + CupertinoPageRoute(builder: (context) => CartonEditor(carton: _box)), ); if (updated ?? false) { var cartonModel = Provider.of(context, listen: false); diff --git a/lib/pages/carton_search/carton_search.dart b/lib/pages/carton_search/carton_search.dart index 4c441da..1139cce 100644 --- a/lib/pages/carton_search/carton_search.dart +++ b/lib/pages/carton_search/carton_search.dart @@ -1,17 +1,12 @@ -import 'package:fcs/domain/constants.dart'; import 'package:fcs/domain/entities/carton.dart'; import 'package:fcs/helpers/theme.dart'; import 'package:fcs/pages/carton/model/carton_model.dart'; -import 'package:fcs/pages/main/util.dart'; import 'package:fcs/pages/widgets/barcode_scanner.dart'; import 'package:fcs/pages/widgets/local_popup_menu_button.dart'; import 'package:fcs/pages/widgets/local_popupmenu.dart'; -import 'package:fcs/pages/widgets/local_text.dart'; -import 'package:fcs/pages/widgets/popupmenu.dart'; import 'package:fcs/pagination/paginator_listview.dart'; import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; -import 'package:permission_handler/permission_handler.dart'; import 'package:provider/provider.dart'; import 'carton_list_row.dart'; @@ -36,12 +31,16 @@ class PartSearchDelegate extends SearchDelegate { ThemeData appBarTheme(BuildContext context) { final ThemeData theme = Theme.of(context); return theme.copyWith( + appBarTheme: AppBarTheme(color: primaryColor), inputDecorationTheme: InputDecorationTheme( + border: InputBorder.none, hintStyle: TextStyle( - color: theme.primaryTextTheme.caption!.color, fontSize: 14)), - textTheme: theme.textTheme.copyWith( - title: theme.textTheme.title!.copyWith( - color: theme.primaryTextTheme.title!.color, fontSize: 16)), + color: theme.primaryTextTheme.caption?.color, fontSize: 14)), + textTheme: TextTheme( + headline1: TextStyle( + color: theme.primaryTextTheme.headline1?.color, + fontSize: 16, + backgroundColor: primaryColor)), primaryColor: primaryColor, ); } diff --git a/lib/pages/contact/contact_editor.dart b/lib/pages/contact/contact_editor.dart index 8092c2f..f292008 100644 --- a/lib/pages/contact/contact_editor.dart +++ b/lib/pages/contact/contact_editor.dart @@ -33,9 +33,14 @@ class _ContactEditorState extends State { Contact? _contact; @override void initState() { - if (widget.contact != null) _contact = widget.contact!; super.initState(); - isNew = widget.contact == null; + if (widget.contact != null) { + isNew = false; + _contact = widget.contact; + initContact(); + } else { + isNew = true; + } } initContact() { diff --git a/lib/pages/contact/contact_page.dart b/lib/pages/contact/contact_page.dart index f0c1fae..ed56946 100644 --- a/lib/pages/contact/contact_page.dart +++ b/lib/pages/contact/contact_page.dart @@ -52,7 +52,7 @@ class _ContactPageState extends State { contact: Contact.fromSetting(setting)), )), icon: Icon( - CupertinoIcons.pen, + Icons.edit, color: primaryColor, )) ] diff --git a/lib/pages/customer/invitation_create.dart b/lib/pages/customer/invitation_create.dart index e2bb37a..f058c9b 100644 --- a/lib/pages/customer/invitation_create.dart +++ b/lib/pages/customer/invitation_create.dart @@ -85,7 +85,8 @@ class _InvitationCreateState extends State { ), Container( decoration: BoxDecoration( - border: Border.all(color: Colors.grey.shade400, width: 1), + border: + Border.all(color: Colors.grey.shade400, width: 1), borderRadius: BorderRadius.all(Radius.circular(12.0))), child: CountryCodePicker( onChanged: _countryChange, @@ -94,9 +95,7 @@ class _InvitationCreateState extends State { showCountryOnly: false, showOnlyCountryWhenClosed: false, alignLeft: false, - textStyle: TextStyle( - fontSize: 16, - ), + textStyle: TextStyle(fontSize: 16, color: Colors.black87), ), ), SizedBox( @@ -172,7 +171,7 @@ class _InvitationCreateState extends State { } isDataChanged() { - String userName = _nameController.text; + String userName = _nameController.text; String phoneNumber = _phoneController.text; return userName != "" || phoneNumber != ""; } diff --git a/lib/pages/customer/model/customer_model.dart b/lib/pages/customer/model/customer_model.dart index a82c24b..556895d 100644 --- a/lib/pages/customer/model/customer_model.dart +++ b/lib/pages/customer/model/customer_model.dart @@ -12,8 +12,8 @@ class CustomerModel extends BaseModel { List customers = []; List invitations = []; - late StreamSubscription? customerListener; - late StreamSubscription? invitationListener; + StreamSubscription? customerListener; + StreamSubscription? invitationListener; @override void privilegeChanged() { diff --git a/lib/pages/delivery/model/delivery_model.dart b/lib/pages/delivery/model/delivery_model.dart index 235f820..97da1e9 100644 --- a/lib/pages/delivery/model/delivery_model.dart +++ b/lib/pages/delivery/model/delivery_model.dart @@ -4,17 +4,17 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:fcs/data/services/services.dart'; import 'package:fcs/domain/constants.dart'; import 'package:fcs/domain/entities/carton.dart'; -import 'package:fcs/domain/vo/message.dart'; import 'package:fcs/helpers/paginator.dart'; import 'package:fcs/pages/main/model/base_model.dart'; import 'package:logging/logging.dart'; class DeliveryModel extends BaseModel { final log = Logger('DeliveryModel'); - List get cartons => - _selectedIndex == 1 ? _cartons : List.from(_delivered.values); + List get cartons => _selectedIndex == 1 + ? _cartons + : List.from(_delivered?.values ?? []); - late Paginator _delivered; + Paginator? _delivered; int _selectedIndex = 1; bool isLoading = false; List _cartons = []; @@ -31,9 +31,9 @@ class DeliveryModel extends BaseModel { _selectedIndex = 1; _loadCartons(); - if (_delivered != null) _delivered.close(); + if (_delivered != null) _delivered!.close(); _delivered = _getDelivered(); - _delivered.load(); + _delivered!.load(); } Future _loadCartons() async { @@ -57,7 +57,8 @@ class DeliveryModel extends BaseModel { _cartons.clear(); _cartons = snapshot.docs.map((documentSnapshot) { var s = Carton.fromMap( - documentSnapshot.data as Map, documentSnapshot.id); + documentSnapshot.data as Map, + documentSnapshot.id); return s; }).toList(); notifyListeners(); @@ -82,10 +83,10 @@ class DeliveryModel extends BaseModel { } Future loadMore() async { - if (_delivered.ended || _selectedIndex == 1) return; + if (_delivered!.ended || _selectedIndex == 1) return; isLoading = true; notifyListeners(); - await _delivered.load(onFinished: () { + await _delivered!.load(onFinished: () { isLoading = false; notifyListeners(); }); @@ -94,7 +95,7 @@ class DeliveryModel extends BaseModel { Future refresh() async { if (_selectedIndex == 1) return; - await _delivered.refresh(onFinished: () { + await _delivered!.refresh(onFinished: () { notifyListeners(); }); } @@ -106,7 +107,7 @@ class DeliveryModel extends BaseModel { @override logout() async { if (listener != null) await listener!.cancel(); - if (_delivered != null) _delivered.close(); + if (_delivered != null) _delivered!.close(); _cartons = []; } diff --git a/lib/pages/delivery_address/model/delivery_address_model.dart b/lib/pages/delivery_address/model/delivery_address_model.dart index 33c4d4d..719c552 100644 --- a/lib/pages/delivery_address/model/delivery_address_model.dart +++ b/lib/pages/delivery_address/model/delivery_address_model.dart @@ -60,7 +60,7 @@ class DeliveryAddressModel extends BaseModel { Future getDeliveryAddress(String id) async { String path = "/$user_collection/${user!.id}/$delivery_address_collection"; var snap = await FirebaseFirestore.instance.collection(path).doc(id).get(); - return DeliveryAddress.fromMap(snap.data as Map, snap.id); + return DeliveryAddress.fromMap(snap.data()!, snap.id); } void initUser(user) { @@ -96,8 +96,7 @@ class DeliveryAddressModel extends BaseModel { .orderBy("full_name") .get(); return querySnap.docs - .map((e) => - DeliveryAddress.fromMap(e.data as Map, e.id)) + .map((e) => DeliveryAddress.fromMap(e.data(), e.id)) .toList(); } } diff --git a/lib/pages/discount/discount_editor.dart b/lib/pages/discount/discount_editor.dart index 3b66baf..32333f0 100644 --- a/lib/pages/discount/discount_editor.dart +++ b/lib/pages/discount/discount_editor.dart @@ -80,7 +80,7 @@ class _DiscountEditorState extends State { customerId = u.id ?? ""; customerName = u.name ?? ""; }); - },popPage: true)), + }, popPage: true)), ], ); diff --git a/lib/pages/discount/model/discount_model.dart b/lib/pages/discount/model/discount_model.dart index 415aad1..ce2b478 100644 --- a/lib/pages/discount/model/discount_model.dart +++ b/lib/pages/discount/model/discount_model.dart @@ -14,10 +14,11 @@ class DiscountModel extends BaseModel { StreamSubscription? listener; List _discounts = []; - List get discounts => - _selectedIndex == 1 ? _discounts : List.from(_used.values); + List get discounts => _selectedIndex == 1 + ? _discounts + : List.from(_used?.values ?? []); - late Paginator _used; + Paginator? _used; bool isLoading = false; int _selectedIndex = 1; set selectedIndex(int index) { @@ -31,7 +32,7 @@ class DiscountModel extends BaseModel { _selectedIndex = 1; _load(); if (_getUsed() != null) _used = _getUsed(); - _used.load(); + _used?.load(); } void initUser(user) { @@ -49,8 +50,7 @@ class DiscountModel extends BaseModel { .listen((snaps) { _discounts.clear(); snaps.docs.forEach((d) { - _discounts - .add(Discount.fromMap(d.data() as Map, d.id)); + _discounts.add(Discount.fromMap(d.data(), d.id)); }); notifyListeners(); }); @@ -94,10 +94,10 @@ class DiscountModel extends BaseModel { } Future loadMore() async { - if (_used.ended || _selectedIndex == 1) return; + if (_used!.ended || _selectedIndex == 1) return; isLoading = true; notifyListeners(); - await _used.load(onFinished: () { + await _used!.load(onFinished: () { isLoading = false; notifyListeners(); }); @@ -105,7 +105,7 @@ class DiscountModel extends BaseModel { Future refresh() async { if (_selectedIndex == 1) return; - await _used.refresh(onFinished: () { + await _used!.refresh(onFinished: () { notifyListeners(); }); } @@ -113,7 +113,7 @@ class DiscountModel extends BaseModel { @override logout() async { if (listener != null) await listener!.cancel(); - if (_used != null) _used.close(); + if (_used != null) _used!.close(); _discounts = []; } diff --git a/lib/pages/fcs_shipment/fcs_shipment_info.dart b/lib/pages/fcs_shipment/fcs_shipment_info.dart index ffd7723..d3fa572 100644 --- a/lib/pages/fcs_shipment/fcs_shipment_info.dart +++ b/lib/pages/fcs_shipment/fcs_shipment_info.dart @@ -48,15 +48,16 @@ class _FcsShipmentInfoState extends State { } _load() { - _shipmentNumberController.text = _fcsShipment!.shipmentNumber ?? ""; - if(_fcsShipment!.cutoffDate != null) - _cutoffDateController.text = dateFormatter.format(_fcsShipment!.cutoffDate!); - if(_fcsShipment!.arrivalDate != null) - _arrivalDateController.text = - dateFormatter.format(_fcsShipment!.arrivalDate!); - if(_fcsShipment!.departureDate != null) - _departureDateControler.text = - dateFormatter.format(_fcsShipment!.departureDate!); + _shipmentNumberController.text = _fcsShipment?.shipmentNumber ?? ""; + if (_fcsShipment?.cutoffDate != null) + _cutoffDateController.text = + dateFormatter.format(_fcsShipment!.cutoffDate!); + if (_fcsShipment?.arrivalDate != null) + _arrivalDateController.text = + dateFormatter.format(_fcsShipment!.arrivalDate!); + if (_fcsShipment?.departureDate != null) + _departureDateControler.text = + dateFormatter.format(_fcsShipment!.departureDate!); _shipmentTypeControler.text = _fcsShipment!.shipType ?? ""; _consigneeController.text = _fcsShipment!.consignee ?? ""; _portController.text = _fcsShipment!.port ?? ""; @@ -169,7 +170,7 @@ class _FcsShipmentInfoState extends State { portBox, destinationBox, statusBox, - _fcsShipment!.status == fcs_shipment_confirmed_status + _fcsShipment?.status == fcs_shipment_confirmed_status ? shipBtn : Container(), SizedBox( @@ -185,7 +186,6 @@ class _FcsShipmentInfoState extends State { } _edit() async { - var f; bool? updated = await Navigator.push( context, CupertinoPageRoute( @@ -193,12 +193,14 @@ class _FcsShipmentInfoState extends State { ); if (updated ?? false) { var shipmentModel = Provider.of(context, listen: false); - if(_fcsShipment != null && _fcsShipment!.id != null ) - f = await shipmentModel.getFcsShipment(_fcsShipment!.id!); - setState(() { - _fcsShipment = f; - }); - _load(); + if (_fcsShipment != null && _fcsShipment!.id != null) { + FcsShipment? f = await shipmentModel.getFcsShipment(_fcsShipment!.id!); + if (f == null) return; + setState(() { + _fcsShipment = f; + }); + _load(); + } } } diff --git a/lib/pages/fcs_shipment/model/fcs_shipment_model.dart b/lib/pages/fcs_shipment/model/fcs_shipment_model.dart index 6bb8a16..3667a88 100644 --- a/lib/pages/fcs_shipment/model/fcs_shipment_model.dart +++ b/lib/pages/fcs_shipment/model/fcs_shipment_model.dart @@ -15,9 +15,9 @@ class FcsShipmentModel extends BaseModel { List _fcsShipments = []; List get fcsShipments => _selectedIndex == 1 ? _fcsShipments - : List.from(_shipped.values); + : List.from(_shipped!.values); - late Paginator _shipped; + Paginator? _shipped; bool isLoading = false; int _selectedIndex = 1; set selectedIndex(int index) { @@ -25,7 +25,7 @@ class FcsShipmentModel extends BaseModel { notifyListeners(); } - int get selectedIndex => _selectedIndex; + int get selectedIndex => _selectedIndex; @override void privilegeChanged() { @@ -37,9 +37,9 @@ class FcsShipmentModel extends BaseModel { _selectedIndex = 1; _loadFcsShipments(); - if (_shipped != null) _shipped.close(); + if (_shipped != null) _shipped!.close(); _shipped = _getShipped(); - _shipped.load(); + _shipped!.load(); } Future _loadFcsShipments() async { @@ -58,7 +58,8 @@ class FcsShipmentModel extends BaseModel { _fcsShipments.clear(); _fcsShipments = snapshot.docs.map((documentSnapshot) { var s = FcsShipment.fromMap( - documentSnapshot.data() as Map, documentSnapshot.id); + documentSnapshot.data() as Map, + documentSnapshot.id); return s; }).toList(); notifyListeners(); @@ -83,10 +84,10 @@ class FcsShipmentModel extends BaseModel { } Future loadMore() async { - if (_shipped.ended || _selectedIndex == 1) return; + if (_shipped!.ended || _selectedIndex == 1) return; isLoading = true; notifyListeners(); - await _shipped.load(onFinished: () { + await _shipped!.load(onFinished: () { isLoading = false; notifyListeners(); }); @@ -94,7 +95,7 @@ class FcsShipmentModel extends BaseModel { Future refresh() async { if (_selectedIndex == 1) return; - await _shipped.refresh(onFinished: () { + await _shipped!.refresh(onFinished: () { notifyListeners(); }); } @@ -107,8 +108,8 @@ class FcsShipmentModel extends BaseModel { .where("status", isEqualTo: fcs_shipment_confirmed_status) .get(const GetOptions(source: Source.server)); fcsShipments = snaps.docs.map((documentSnapshot) { - var fcs = FcsShipment.fromMap( - documentSnapshot.data as Map, documentSnapshot.id); + var fcs = + FcsShipment.fromMap(documentSnapshot.data(), documentSnapshot.id); return fcs; }).toList(); } catch (e) { @@ -123,7 +124,7 @@ class FcsShipmentModel extends BaseModel { .collection("/$fcs_shipment_collection") .doc(id) .get(const GetOptions(source: Source.server)); - var fcs = FcsShipment.fromMap(snap.data as Map, snap.id); + var fcs = FcsShipment.fromMap(snap.data()!, snap.id); return fcs; } catch (e) { @@ -141,7 +142,7 @@ class FcsShipmentModel extends BaseModel { .get(const GetOptions(source: Source.server)); fcsShipments = snaps.docs.map((documentSnapshot) { var fcs = FcsShipment.fromMap( - documentSnapshot.data as Map, documentSnapshot.id); + documentSnapshot.data as Map, documentSnapshot.id); return fcs; }).toList(); } catch (e) { @@ -157,7 +158,7 @@ class FcsShipmentModel extends BaseModel { @override logout() async { if (listener != null) await listener!.cancel(); - if (_shipped != null) _shipped.close(); + if (_shipped != null) _shipped!.close(); _fcsShipments = []; } diff --git a/lib/pages/invoice/editor/invoice_discount_list.dart b/lib/pages/invoice/editor/invoice_discount_list.dart index a86a056..cbde9ed 100644 --- a/lib/pages/invoice/editor/invoice_discount_list.dart +++ b/lib/pages/invoice/editor/invoice_discount_list.dart @@ -1,7 +1,6 @@ import 'package:fcs/domain/entities/discount.dart'; import 'package:fcs/helpers/theme.dart'; import 'package:fcs/pages/widgets/local_text.dart'; -import 'package:fcs/pages/widgets/my_data_table.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -37,17 +36,18 @@ class InvoiceDiscountList extends StatelessWidget { } Widget table(BuildContext context) { - return MyDataTable( + return DataTable( headingRowHeight: 40, + showCheckboxColumn: false, columns: [ - MyDataColumn( + DataColumn( label: LocalText( context, "discount.code", color: Colors.grey, ), ), - MyDataColumn( + DataColumn( label: LocalText( context, "discount.amount", @@ -59,19 +59,19 @@ class InvoiceDiscountList extends StatelessWidget { ); } - List getRows(BuildContext context) { + List getRows(BuildContext context) { if (discounts == null) { return []; } var rows = discounts!.map((c) { - return MyDataRow( + return DataRow( onSelectChanged: (value) => Navigator.pop(context, c), cells: [ - MyDataCell(new Text( + DataCell(new Text( c?.code ?? '', style: textStyle, )), - MyDataCell( + DataCell( Row( mainAxisAlignment: MainAxisAlignment.end, children: [ diff --git a/lib/pages/invoice/editor/invoice_handling_fee_list.dart b/lib/pages/invoice/editor/invoice_handling_fee_list.dart index 75d6462..ed06de4 100644 --- a/lib/pages/invoice/editor/invoice_handling_fee_list.dart +++ b/lib/pages/invoice/editor/invoice_handling_fee_list.dart @@ -1,7 +1,6 @@ import 'package:fcs/domain/entities/shipment.dart'; import 'package:fcs/helpers/theme.dart'; import 'package:fcs/pages/widgets/local_text.dart'; -import 'package:fcs/pages/widgets/my_data_table.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -41,17 +40,18 @@ class InvoiceHandlingFeeList extends StatelessWidget { } Widget table(BuildContext context) { - return MyDataTable( + return DataTable( headingRowHeight: 40, + showCheckboxColumn: false, columns: [ - MyDataColumn( + DataColumn( label: LocalText( context, "invoice.shipment.number", color: Colors.grey, ), ), - MyDataColumn( + DataColumn( label: LocalText( context, "invoice.add.handling.fee.menu", @@ -63,19 +63,19 @@ class InvoiceHandlingFeeList extends StatelessWidget { ); } - List getRows(BuildContext context) { + List getRows(BuildContext context) { if (shipments == null) { return []; } var rows = shipments!.map((c) { - return MyDataRow( + return DataRow( onSelectChanged: (value) => Navigator.pop(context, c), cells: [ - MyDataCell(new Text( + DataCell(new Text( c!.shipmentNumber!, style: textStyle, )), - MyDataCell( + DataCell( Row( mainAxisAlignment: MainAxisAlignment.end, children: [ diff --git a/lib/pages/main/util.dart b/lib/pages/main/util.dart index 277bfe1..5018f59 100644 --- a/lib/pages/main/util.dart +++ b/lib/pages/main/util.dart @@ -42,7 +42,7 @@ Future showConfirmDialog( child: LocalText( context, translationKey, - translationVariables: translationVariables!, + translationVariables: translationVariables, color: primaryColor, ), ), diff --git a/lib/pages/package/model/package_model.dart b/lib/pages/package/model/package_model.dart index 4878bc6..a826954 100644 --- a/lib/pages/package/model/package_model.dart +++ b/lib/pages/package/model/package_model.dart @@ -143,7 +143,7 @@ class PackageModel extends BaseModel { await FirebaseFirestore.instance.collection("$path").doc(id).get(); if (snap.exists) { var package = - Package.fromMap(snap.data as Map, snap.id); + Package.fromMap(snap.data() as Map, snap.id); return package; } } catch (e) { diff --git a/lib/pages/package/package_info.dart b/lib/pages/package/package_info.dart index 519d42b..608b1ef 100644 --- a/lib/pages/package/package_info.dart +++ b/lib/pages/package/package_info.dart @@ -56,7 +56,7 @@ class _PackageInfoState extends State { PackageModel packageModel = Provider.of(context, listen: false); Package? package = - await packageModel.getPackageByTrackingID(pkg!.trackingID!); + await packageModel.getPackageByTrackingID(pkg.trackingID!); setState(() { _package = package; multiImgController.setImageUrls = package!.photoUrls; @@ -193,7 +193,6 @@ class _PackageInfoState extends State { } _changeDeliverayAddress(DeliveryAddress deliveryAddress) async { - if (deliveryAddress == null) return; setState(() { _isLoading = true; }); diff --git a/lib/pages/package_search/package_serach.dart b/lib/pages/package_search/package_serach.dart index 566b46c..3ada0bd 100644 --- a/lib/pages/package_search/package_serach.dart +++ b/lib/pages/package_search/package_serach.dart @@ -29,12 +29,16 @@ class PackageSearchDelegate extends SearchDelegate { ThemeData appBarTheme(BuildContext context) { final ThemeData theme = Theme.of(context); return theme.copyWith( + appBarTheme: AppBarTheme(color: primaryColor), inputDecorationTheme: InputDecorationTheme( + border: InputBorder.none, hintStyle: TextStyle( - color: theme.primaryTextTheme.caption!.color, fontSize: 14)), - textTheme: theme.textTheme.copyWith( - title: theme.textTheme.title!.copyWith( - color: theme.primaryTextTheme.title!.color, fontSize: 16)), + color: theme.primaryTextTheme.caption?.color, fontSize: 14)), + textTheme: TextTheme( + headline1: TextStyle( + color: theme.primaryTextTheme.headline1?.color, + fontSize: 16, + backgroundColor: primaryColor)), primaryColor: primaryColor, ); } diff --git a/lib/pages/processing/package_editor.dart b/lib/pages/processing/package_editor.dart index 458e3dc..207f662 100644 --- a/lib/pages/processing/package_editor.dart +++ b/lib/pages/processing/package_editor.dart @@ -44,10 +44,10 @@ class _PackageEditorState extends State { void initState() { super.initState(); _package = Package(); - _loadPackageData(widget.package!.id!); + _loadPackageData(widget.package?.id!); } - _loadPackageData(String id) async { + _loadPackageData(String? id) async { if (id != null) { PackageModel packageModel = Provider.of(context, listen: false); diff --git a/lib/pages/processing/processing_edit_editor.dart b/lib/pages/processing/processing_edit_editor.dart index 4751134..64d9155 100644 --- a/lib/pages/processing/processing_edit_editor.dart +++ b/lib/pages/processing/processing_edit_editor.dart @@ -42,8 +42,8 @@ class _ProcessingEditEditorState extends State { super.initState(); _package = widget.package; selectedMarket = _package!.market ?? ""; - _descCtl.text = _package!.desc!; - _remarkCtl.text = _package!.remark!; + _descCtl.text = _package!.desc ?? ""; + _remarkCtl.text = _package!.remark ?? ""; multiImgController.setImageUrls = _package!.photoUrls; _user = User( fcsID: _package!.fcsID ?? "", diff --git a/lib/pages/processing/processing_info.dart b/lib/pages/processing/processing_info.dart index d15d0c9..2f15404 100644 --- a/lib/pages/processing/processing_info.dart +++ b/lib/pages/processing/processing_info.dart @@ -39,7 +39,8 @@ class _ProcessingInfoState extends State { initPackage(widget.package!); } - initPackage(Package package) { + initPackage(Package? package) { + if (package == null) return; setState(() { _package = package; multiImgController.setImageUrls = package.photoUrls; @@ -69,37 +70,37 @@ class _ProcessingInfoState extends State { iconData: Icons.phone, ); final customerNameBox = DisplayText( - text:_package!=null? _package!.userName:"", + text: _package != null ? _package!.userName : "", labelTextKey: "processing.consignee.name", iconData: Icons.perm_identity, ); var senderFcsIDBox = DisplayText( - text:_package!=null? _package!.senderFCSID:"", + text: _package != null ? _package!.senderFCSID : "", labelTextKey: "processing.fcs.id", icon: FcsIDIcon(), ); final senderPhoneNumberBox = DisplayText( - text: _package!=null?_package!.senderPhoneNumber:"", + text: _package != null ? _package!.senderPhoneNumber : "", labelTextKey: "processing.phone", iconData: Icons.phone, ); final senderNameBox = DisplayText( - text:_package!=null? _package!.senderName:"", + text: _package != null ? _package!.senderName : "", labelTextKey: "processing.shipper.name", iconData: Icons.perm_identity, ); final marketBox = DisplayText( - text:_package!=null? _package!.market : "-", + text: _package != null ? _package!.market : "-", labelTextKey: "processing.market", iconData: Icons.store, ); final descBox = DisplayText( - text:_package!=null? _package!.desc : "-", + text: _package != null ? _package!.desc : "-", labelTextKey: "processing.desc", iconData: MaterialCommunityIcons.message_text_outline, ); final remarkBox = DisplayText( - text:_package!=null? _package!.remark : "-", + text: _package != null ? _package!.remark : "-", labelTextKey: "processing.remark", iconData: Entypo.new_message, ); @@ -175,7 +176,7 @@ class _ProcessingInfoState extends State { _package!.photoUrls.length == 0 ? Container() : img, StatusTree( shipmentHistory: _package!.shipmentHistory, - currentStatus: _package!.status??""), + currentStatus: _package!.status ?? ""), SizedBox( height: 20, ) @@ -223,7 +224,7 @@ class _ProcessingInfoState extends State { PackageModel packageModel = Provider.of(context, listen: false); Package? p = await packageModel.getPackage(_package!.id!); - initPackage(p!); + initPackage(p); } } } diff --git a/lib/pages/rates/shipment_rates.dart b/lib/pages/rates/shipment_rates.dart index 1613d70..2082b6e 100644 --- a/lib/pages/rates/shipment_rates.dart +++ b/lib/pages/rates/shipment_rates.dart @@ -63,7 +63,7 @@ class _ShipmentRatesState extends State { CupertinoPageRoute( builder: (context) => ShipmentRatesEdit())), icon: Icon( - CupertinoIcons.pen, + Icons.edit, color: primaryColor, )) ] diff --git a/lib/pages/receiving/receiving_editor.dart b/lib/pages/receiving/receiving_editor.dart index a120ee0..e542548 100644 --- a/lib/pages/receiving/receiving_editor.dart +++ b/lib/pages/receiving/receiving_editor.dart @@ -231,6 +231,11 @@ class _ReceivingEditorState extends State { showMsgDialog(context, "Error", "Invalid tracking ID!"); return; } + + if (user == null) { + showMsgDialog(context, "Error", "Please select FCS ID"); + return; + } setState(() { _isLoading = true; }); diff --git a/lib/pages/receiving/receiving_info.dart b/lib/pages/receiving/receiving_info.dart index d029bf8..eba05cb 100644 --- a/lib/pages/receiving/receiving_info.dart +++ b/lib/pages/receiving/receiving_info.dart @@ -40,7 +40,8 @@ class _ReceivingInfoState extends State { initPackage(widget.package!); } - initPackage(Package package) { + initPackage(Package? package) { + if (package == null) return; multiImgController.setImageUrls = package.photoUrls; setState(() { _package = package; @@ -150,7 +151,7 @@ class _ReceivingInfoState extends State { PackageModel packageModel = Provider.of(context, listen: false); var pkg = await packageModel.getPackage(widget.package!.id!); - initPackage(pkg!); + initPackage(pkg); } _delete() { diff --git a/lib/pages/shipment/shipment_box_editor.dart b/lib/pages/shipment/shipment_box_editor.dart index 1fd3778..f5b8c91 100644 --- a/lib/pages/shipment/shipment_box_editor.dart +++ b/lib/pages/shipment/shipment_box_editor.dart @@ -13,7 +13,6 @@ import 'package:fcs/pages/widgets/length_picker.dart'; import 'package:fcs/pages/widgets/local_button.dart'; import 'package:fcs/pages/widgets/local_text.dart'; import 'package:fcs/pages/widgets/local_title.dart'; -import 'package:fcs/pages/widgets/my_data_table.dart'; import 'package:fcs/pages/widgets/progress.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -160,17 +159,18 @@ class _ShipmentBoxEditorState extends State { _addCargo(cargo); }), ), - MyDataTable( + DataTable( headingRowHeight: 40, + showCheckboxColumn: false, columns: [ - MyDataColumn( + DataColumn( label: LocalText( context, "cargo.type", color: Colors.grey, ), ), - MyDataColumn( + DataColumn( label: LocalText( context, "cargo.weight", @@ -211,15 +211,15 @@ class _ShipmentBoxEditorState extends State { ); } - List getCargoRows(BuildContext context) { + List getCargoRows(BuildContext context) { if (_box!.cargoTypes == null) { return []; } double total = 0; var rows = _box!.cargoTypes.map((c) { total += c.weight; - return MyDataRow( - onSelectChanged: (bool selected) async { + return DataRow( + onSelectChanged: (bool? selected) async { CargoType? cargo = await Navigator.push( context, CupertinoPageRoute( @@ -230,11 +230,11 @@ class _ShipmentBoxEditorState extends State { _addCargo(cargo); }, cells: [ - MyDataCell(new Text( + DataCell(new Text( c.name == null ? "" : c.name!, style: textStyle, )), - MyDataCell( + DataCell( Row( mainAxisAlignment: MainAxisAlignment.end, children: [ @@ -254,10 +254,10 @@ class _ShipmentBoxEditorState extends State { ); }).toList(); - var totalRow = MyDataRow( - onSelectChanged: (bool selected) {}, + var totalRow = DataRow( + onSelectChanged: (bool? selected) {}, cells: [ - MyDataCell(Align( + DataCell(Align( alignment: Alignment.centerRight, child: LocalText( context, @@ -266,7 +266,7 @@ class _ShipmentBoxEditorState extends State { fontWeight: FontWeight.bold, ), )), - MyDataCell( + DataCell( Padding( padding: const EdgeInsets.only(right: 48.0), child: Align( diff --git a/lib/pages/shipment/shipment_editor.dart b/lib/pages/shipment/shipment_editor.dart index 8dda866..86d0bd9 100644 --- a/lib/pages/shipment/shipment_editor.dart +++ b/lib/pages/shipment/shipment_editor.dart @@ -70,10 +70,11 @@ class _ShipmentEditorState extends State { _fromTimeEditingController.text = "${timeFormatter.format(now)}"; _toTimeEditingController.text = "${timeFormatter.format(now)}"; // _shipment = Shipment(boxes: []); - var shipmentModel = - Provider.of(context, listen: false); - _shipment!.pickupAddress = shipmentModel.defalutAddress; - _shipment!.boxes = []; + + Shipment _s = Shipment( + pickupAddress: context.read().defalutAddress, + boxes: []); + _shipment = _s; _pickupDate.text = dateFormatter.format(now); } } @@ -87,12 +88,12 @@ class _ShipmentEditorState extends State { Widget build(BuildContext context) { MainModel mainModel = Provider.of(context); ShipmentModel pickupModel = Provider.of(context); - final shipmentNumberBox = getShipmentNumberStatus(context, _shipment!); + final shipmentNumberBox = getShipmentNumberStatus(context, _shipment); bool isLocalPickup = _selectedShipmentType == shipment_local_pickup; bool isCourierPickup = _selectedShipmentType == shipment_courier_pickup; bool isLocalDropoff = _selectedShipmentType == shipment_local_dropoff; bool isCourierDropoff = _selectedShipmentType == shipment_courier_dropoff; - var deliveryAddressModel = Provider.of(context); + final fromTimeBox = InputTime( labelTextKey: 'shipment.from', iconData: Icons.timer, @@ -122,7 +123,7 @@ class _ShipmentEditorState extends State { backgroundColor: Colors.white, )); final pickupAddressBox = DefaultDeliveryAddress( - deliveryAddress: _shipment!.pickupAddress, + deliveryAddress: _shipment?.pickupAddress, iconData: Icons.location_on, labelKey: "shipment.location", onTap: () async { @@ -130,12 +131,15 @@ class _ShipmentEditorState extends State { context, CupertinoPageRoute( builder: (context) => DeliveryAddressSelection( - deliveryAddress: _shipment!.pickupAddress, + deliveryAddress: _shipment?.pickupAddress, user: mainModel.user)), ); + if (address == null) return; + setState(() { - _shipment!.pickupAddress = address; + Shipment _s = Shipment(pickupAddress: address); + _shipment = _s; }); }, ); @@ -230,17 +234,18 @@ class _ShipmentEditorState extends State { color: primaryColor, ), onPressed: () async { - Carton box = await Navigator.push( + Carton? box = await Navigator.push( context, CupertinoPageRoute( builder: (context) => ShipmentBoxEditor()), ); + if (box == null) return; _addBox(box); }, ), ), Column( - children: getBoxList(context, _shipment!.boxes), + children: getBoxList(context, _shipment?.boxes ?? []), ), _isNew ? createBtn : updateBtn, ], @@ -324,6 +329,6 @@ class _ShipmentEditorState extends State { } isDataChanged() { - return _shipment!.boxes.isNotEmpty; + return _shipment?.boxes.isNotEmpty; } } diff --git a/lib/pages/shipment/widgets.dart b/lib/pages/shipment/widgets.dart index af2b342..b11d98d 100644 --- a/lib/pages/shipment/widgets.dart +++ b/lib/pages/shipment/widgets.dart @@ -3,21 +3,21 @@ import 'package:fcs/helpers/theme.dart'; import 'package:fcs/pages/widgets/local_text.dart'; import 'package:flutter/material.dart'; -Widget getShipmentNumberStatus(BuildContext context, Shipment shipment) { +Widget getShipmentNumberStatus(BuildContext context, Shipment? shipment) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ LocalText( context, '', - text: shipment.shipmentNumber ?? "", + text: shipment?.shipmentNumber ?? "", color: primaryColor, fontSize: 18, fontWeight: FontWeight.bold, ), Padding( padding: const EdgeInsets.only(left: 8.0), - child: Chip(label: Text(shipment.status ?? "")), + child: Chip(label: Text(shipment?.status ?? "")), ), ], ); diff --git a/lib/pages/signin/signin_page.dart b/lib/pages/signin/signin_page.dart index 6eaeca8..5c72ec9 100644 --- a/lib/pages/signin/signin_page.dart +++ b/lib/pages/signin/signin_page.dart @@ -90,9 +90,7 @@ class _SigninPageState extends State { showCountryOnly: false, showOnlyCountryWhenClosed: false, alignLeft: false, - textStyle: TextStyle( - fontSize: 16, - ), + textStyle: TextStyle(fontSize: 16, color: Colors.black87), ), ), SizedBox( diff --git a/lib/pages/user_search/user_serach.dart b/lib/pages/user_search/user_serach.dart index c61731c..b8e6584 100644 --- a/lib/pages/user_search/user_serach.dart +++ b/lib/pages/user_search/user_serach.dart @@ -29,12 +29,16 @@ class UserSearchDelegate extends SearchDelegate { ThemeData appBarTheme(BuildContext context) { final ThemeData theme = Theme.of(context); return theme.copyWith( + appBarTheme: AppBarTheme(color: primaryColor), inputDecorationTheme: InputDecorationTheme( + border: InputBorder.none, hintStyle: TextStyle( color: theme.primaryTextTheme.caption?.color, fontSize: 14)), - textTheme: theme.textTheme.copyWith( - title: theme.textTheme.title?.copyWith( - color: theme.primaryTextTheme.title?.color, fontSize: 16)), + textTheme: TextTheme( + headline1: TextStyle( + color: theme.primaryTextTheme.headline1?.color, + fontSize: 16, + backgroundColor: primaryColor)), primaryColor: primaryColor, ); } diff --git a/lib/pages/widgets/delivery_address_selection.dart b/lib/pages/widgets/delivery_address_selection.dart index 1f1b0a6..fc490f5 100644 --- a/lib/pages/widgets/delivery_address_selection.dart +++ b/lib/pages/widgets/delivery_address_selection.dart @@ -61,10 +61,10 @@ class _DeliveryAddressSelectionState extends State { ), floatingActionButton: FloatingActionButton.extended( onPressed: () async { - bool updated = await Navigator.of(context).push(CupertinoPageRoute( + bool? updated = await Navigator.of(context).push(CupertinoPageRoute( builder: (context) => DeliveryAddressEditor(user: widget.user))); - if (updated) { + if (updated ?? false) { _getDeliverAddresses(); } }, @@ -114,10 +114,10 @@ class _DeliveryAddressSelectionState extends State { } _edit(BuildContext context, DeliveryAddress deliveryAddress) async { - bool updated = await Navigator.of(context).push(CupertinoPageRoute( + bool? updated = await Navigator.of(context).push(CupertinoPageRoute( builder: (context) => DeliveryAddressEditor( user: widget.user, deliveryAddress: deliveryAddress))); - if (updated) { + if (updated ?? false) { _getDeliverAddresses(); } } diff --git a/lib/pages/widgets/my_data_table.dart b/lib/pages/widgets/my_data_table.dart index f86925f..f198e21 100644 --- a/lib/pages/widgets/my_data_table.dart +++ b/lib/pages/widgets/my_data_table.dart @@ -622,7 +622,6 @@ class MyDataTable extends StatelessWidget { final List tableColumns = (columns.length + (showCheckboxColumn ? 1 : 0)) as List; - final List tableRows = List.generate( rows.length + 1, // the +1 is for the header row (int index) { diff --git a/pubspec.lock b/pubspec.lock index c317df9..5054151 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,14 +7,14 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "22.0.0" + version: "25.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "1.7.1" + version: "2.2.0" args: dependency: transitive description: @@ -28,7 +28,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.6.1" + version: "2.8.1" barcode_scan2: dependency: "direct main" description: @@ -91,7 +91,7 @@ packages: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" cli_util: dependency: transitive description: @@ -434,6 +434,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "9.1.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" glob: dependency: transitive description: @@ -531,7 +538,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.7.0" mime: dependency: transitive description: @@ -893,21 +900,21 @@ packages: name: test url: "https://pub.dartlang.org" source: hosted - version: "1.16.8" + version: "1.17.10" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.4.2" test_core: dependency: transitive description: name: test_core url: "https://pub.dartlang.org" source: hosted - version: "0.3.19" + version: "0.4.0" timeline_list: dependency: "direct main" description: