Merge branch 'master' of phyothandar/fcs.kl into master

This commit is contained in:
2021-09-13 07:56:40 +00:00
committed by Gogs
41 changed files with 272 additions and 235 deletions

View File

@@ -69,6 +69,7 @@ const privilege_delivery = "deli";
const privilege_invoice = "inv"; const privilege_invoice = "inv";
const privilege_processing = "pr"; const privilege_processing = "pr";
const privilege_receiving = "rc"; const privilege_receiving = "rc";
const privilege_pickup = "pku";
// Pickup types // Pickup types
const shipment_local_pickup = "Local pickup"; const shipment_local_pickup = "Local pickup";

View File

@@ -64,9 +64,8 @@ class Carton {
// String get packageNumber => // String get packageNumber =>
// shipmentNumber + "-" + receiverNumber + " #" + boxNumber; // shipmentNumber + "-" + receiverNumber + " #" + boxNumber;
double get actualWeight => cargoTypes == null double get actualWeight =>
? 0 cargoTypes == null ? 0 : cargoTypes.fold(0, (p, e) => e.weight + p);
: cargoTypes.fold(0, (p, e) => e.weight + p);
int getShipmentWeight(double volumetricRatio) { int getShipmentWeight(double volumetricRatio) {
if (length == null || if (length == null ||
@@ -110,13 +109,12 @@ class Carton {
double wd = sw - aw; double wd = sw - aw;
wd = wd - rate.diffDiscountWeight; wd = wd - rate.diffDiscountWeight;
double wdAmount = wd > 0 ? wd * rate.diffWeightRate : 0; double wdAmount = wd > 0 ? wd * rate.diffWeightRate : 0;
DiscountByWeight discountByWeight = rate.getDiscountByWeight(aw); DiscountByWeight discountByWeight = rate.getDiscountByWeight(aw);
double total = 0; double total = 0;
cargoTypes.forEach((e) { cargoTypes.forEach((e) {
double r = e.rate - double r =
(discountByWeight != null ? (discountByWeight.discount) : 0); e.rate - (discountByWeight != null ? (discountByWeight.discount) : 0);
double amount = e.weight * r; double amount = e.weight * r;
total += amount; total += amount;
}); });
@@ -194,7 +192,8 @@ class Carton {
} }
factory Carton.fromMap(Map<String, dynamic> map, String docID) { factory Carton.fromMap(Map<String, dynamic> 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 = map['delivery_address'];
var _da = da != null ? DeliveryAddress.fromMap(da, da["id"]) : null; var _da = da != null ? DeliveryAddress.fromMap(da, da["id"]) : null;
var cargoTypesMaps = var cargoTypesMaps =

View File

@@ -16,10 +16,12 @@ class Rate {
DiscountByWeight getDiscountByWeight(double weight) { DiscountByWeight getDiscountByWeight(double weight) {
discountByWeights.sort((d1, d2) => d2.weight.compareTo(d1.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( Rate(
{this.deliveryFee = 0, {this.deliveryFee = 0,

View File

@@ -52,7 +52,7 @@ class Shipment {
this.pickupDate, this.pickupDate,
this.isCourier = false, this.isCourier = false,
this.radioIndex = 1, this.radioIndex = 1,
required this.pickupAddress, this.pickupAddress,
this.pickupUserID, this.pickupUserID,
this.pickupUserName, this.pickupUserName,
this.pickupUserPhoneNumber, this.pickupUserPhoneNumber,

View File

@@ -43,6 +43,8 @@ class Privilege {
iconData = FontAwesome.dropbox; iconData = FontAwesome.dropbox;
} else if (this.id == privilege_receiving) { } else if (this.id == privilege_receiving) {
iconData = MaterialCommunityIcons.inbox_arrow_down; iconData = MaterialCommunityIcons.inbox_arrow_down;
} else if (this.id == privilege_pickup) {
iconData = SimpleLineIcons.direction;
} else { } else {
iconData = MaterialCommunityIcons.account_question; iconData = MaterialCommunityIcons.account_question;
} }

View File

@@ -22,25 +22,26 @@ class _CargoTableState extends State<CargoTable> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SingleChildScrollView( return SingleChildScrollView(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
child: MyDataTable( child: DataTable(
headingRowHeight: 40, headingRowHeight: 40,
columnSpacing: 50, columnSpacing: 50,
showCheckboxColumn: false,
columns: [ columns: [
MyDataColumn( DataColumn(
label: LocalText( label: LocalText(
context, context,
"cargo.type", "cargo.type",
color: Colors.grey, color: Colors.grey,
), ),
), ),
MyDataColumn( DataColumn(
label: LocalText( label: LocalText(
context, context,
"cargo.qty", "cargo.qty",
color: Colors.grey, color: Colors.grey,
), ),
), ),
MyDataColumn( DataColumn(
label: LocalText( label: LocalText(
context, context,
"cargo.weight", "cargo.weight",
@@ -53,21 +54,21 @@ class _CargoTableState extends State<CargoTable> {
); );
} }
List<MyDataRow> getCargoRows(BuildContext context) { List<DataRow> getCargoRows(BuildContext context) {
if (widget.cargoTypes == null) { if (widget.cargoTypes == null) {
return []; return [];
} }
double total = 0; double total = 0;
var rows = widget.cargoTypes!.map((c) { var rows = widget.cargoTypes!.map((c) {
total += c.weight; total += c.weight;
return MyDataRow( return DataRow(
onSelectChanged: (bool selected) async {}, onSelectChanged: (bool? selected) async {},
cells: [ cells: [
MyDataCell(new Text( DataCell(new Text(
c.name ?? "", c.name ?? "",
style: textStyle, style: textStyle,
)), )),
MyDataCell(c.qty == null || c.qty == 0 DataCell(c.qty == null || c.qty == 0
? Center( ? Center(
child: Text( child: Text(
"-", "-",
@@ -80,7 +81,7 @@ class _CargoTableState extends State<CargoTable> {
style: textStyle, style: textStyle,
), ),
)), )),
MyDataCell( DataCell(
Text(c.weight == null ? "0" : c.weight.toStringAsFixed(2), Text(c.weight == null ? "0" : c.weight.toStringAsFixed(2),
style: textStyle), style: textStyle),
), ),
@@ -88,10 +89,10 @@ class _CargoTableState extends State<CargoTable> {
); );
}).toList(); }).toList();
var totalRow = MyDataRow( var totalRow = DataRow(
onSelectChanged: (bool selected) {}, onSelectChanged: (bool? selected) {},
cells: [ cells: [
MyDataCell(Align( DataCell(Align(
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: LocalText( child: LocalText(
context, context,
@@ -100,8 +101,8 @@ class _CargoTableState extends State<CargoTable> {
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
)), )),
MyDataCell(Text("")), DataCell(Text("")),
MyDataCell( DataCell(
Padding( Padding(
padding: const EdgeInsets.only(right: 48.0), padding: const EdgeInsets.only(right: 48.0),
child: Align( child: Align(

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/widgets/dialog_input.dart'; import 'package:fcs/pages/widgets/dialog_input.dart';
import 'package:fcs/pages/widgets/local_text.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/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -45,25 +44,26 @@ class _CargoTableState extends State<CargoTable> {
return SingleChildScrollView( return SingleChildScrollView(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
child: MyDataTable( child: DataTable(
showCheckboxColumn: false,
headingRowHeight: 40, headingRowHeight: 40,
columnSpacing: 40, columnSpacing: 40,
columns: [ columns: [
MyDataColumn( DataColumn(
label: LocalText( label: LocalText(
context, context,
"cargo.type", "cargo.type",
color: Colors.grey, color: Colors.grey,
), ),
), ),
MyDataColumn( DataColumn(
label: LocalText( label: LocalText(
context, context,
"cargo.qty", "cargo.qty",
color: Colors.grey, color: Colors.grey,
), ),
), ),
MyDataColumn( DataColumn(
label: LocalText( label: LocalText(
context, context,
"cargo.weight", "cargo.weight",
@@ -76,21 +76,21 @@ class _CargoTableState extends State<CargoTable> {
); );
} }
List<MyDataRow> getCargoRows(BuildContext context) { List<DataRow> getCargoRows(BuildContext context) {
if (cargoTypes == null) { if (cargoTypes == null) {
return []; return [];
} }
var rows = cargoTypes!.map((c) { var rows = cargoTypes!.map((c) {
return MyDataRow( return DataRow(
onSelectChanged: (bool selected) async {}, onSelectChanged: (bool? selected) async {},
cells: [ cells: [
MyDataCell( DataCell(
new Text( new Text(
c.name ?? '', c.name ?? '',
style: textStyle, style: textStyle,
), ),
), ),
MyDataCell( DataCell(
c.isCutomDuty! c.isCutomDuty!
? GestureDetector( ? GestureDetector(
onTap: () async { onTap: () async {
@@ -128,7 +128,7 @@ class _CargoTableState extends State<CargoTable> {
), ),
), ),
), ),
MyDataCell( DataCell(
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
@@ -185,10 +185,10 @@ class _CargoTableState extends State<CargoTable> {
); );
}).toList(); }).toList();
var totalRow = MyDataRow( var totalRow = DataRow(
onSelectChanged: (bool selected) {}, onSelectChanged: (bool? selected) {},
cells: [ cells: [
MyDataCell(Align( DataCell(Align(
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: LocalText( child: LocalText(
context, context,
@@ -197,8 +197,8 @@ class _CargoTableState extends State<CargoTable> {
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
)), )),
MyDataCell(Text("")), DataCell(Text("")),
MyDataCell( DataCell(
Padding( Padding(
padding: const EdgeInsets.only(right: 48.0), padding: const EdgeInsets.only(right: 48.0),
child: Align( child: Align(

View File

@@ -28,17 +28,18 @@ class _CargoTableState extends State<CargoTable> {
double remainingWeight = 0; double remainingWeight = 0;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MyDataTable( return DataTable(
headingRowHeight: 40, headingRowHeight: 40,
showCheckboxColumn: false,
columns: [ columns: [
MyDataColumn( DataColumn(
label: LocalText( label: LocalText(
context, context,
"cargo.type", "cargo.type",
color: Colors.grey, color: Colors.grey,
), ),
), ),
MyDataColumn( DataColumn(
label: Row( label: Row(
children: [ children: [
Container( Container(
@@ -57,7 +58,7 @@ class _CargoTableState extends State<CargoTable> {
); );
} }
List<MyDataRow> getCargoRows(BuildContext context) { List<DataRow> getCargoRows(BuildContext context) {
if (widget.cargoTypes == null) { if (widget.cargoTypes == null) {
return []; return [];
} }
@@ -67,10 +68,10 @@ class _CargoTableState extends State<CargoTable> {
var rows = widget.cargoTypes!.map((c) { var rows = widget.cargoTypes!.map((c) {
_total += c.weight; _total += c.weight;
return MyDataRow( return DataRow(
onSelectChanged: (bool selected) async {}, onSelectChanged: (bool? selected) async {},
cells: [ cells: [
MyDataCell(Row( DataCell(Row(
children: [ children: [
new Text( new Text(
c.name ?? "", c.name ?? "",
@@ -82,7 +83,7 @@ class _CargoTableState extends State<CargoTable> {
), ),
], ],
)), )),
MyDataCell( DataCell(
Row( Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
@@ -106,10 +107,10 @@ class _CargoTableState extends State<CargoTable> {
); );
}).toList(); }).toList();
var totalRow = MyDataRow( var totalRow = DataRow(
onSelectChanged: (bool selected) {}, onSelectChanged: (bool? selected) {},
cells: [ cells: [
MyDataCell(Align( DataCell(Align(
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: LocalText( child: LocalText(
context, context,
@@ -118,7 +119,7 @@ class _CargoTableState extends State<CargoTable> {
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
)), )),
MyDataCell( DataCell(
Padding( Padding(
padding: const EdgeInsets.only(right: 40.0), padding: const EdgeInsets.only(right: 40.0),
child: Align( child: Align(
@@ -144,7 +145,8 @@ class _CargoTableState extends State<CargoTable> {
widget.cargoTypes!.forEach((c) { widget.cargoTypes!.forEach((c) {
_types.add(c.name!); _types.add(c.name!);
}); });
if (this._cargos.length == widget.cargoTypes!.length - 1) { if (this._cargos.length ==
widget.cargoTypes!.length - 1) {
_types.forEach((t) { _types.forEach((t) {
if (!_list.contains(t)) { if (!_list.contains(t)) {
widget.cargoTypes!.forEach((c) { widget.cargoTypes!.forEach((c) {

View File

@@ -10,7 +10,6 @@ import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/carton/carton_package_table.dart'; import 'package:fcs/pages/carton/carton_package_table.dart';
import 'package:fcs/pages/carton_search/carton_search.dart'; import 'package:fcs/pages/carton_search/carton_search.dart';
import 'package:fcs/pages/carton_size/carton_size_list.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/fcs_shipment/model/fcs_shipment_model.dart';
import 'package:fcs/pages/main/util.dart'; import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/package/model/package_model.dart'; import 'package:fcs/pages/package/model/package_model.dart';
@@ -40,8 +39,8 @@ import 'package_carton_editor.dart';
import 'widgets.dart'; import 'widgets.dart';
class CartonEditor extends StatefulWidget { class CartonEditor extends StatefulWidget {
final Carton? box; final Carton? carton;
CartonEditor({this.box}); CartonEditor({this.carton});
@override @override
_CartonEditorState createState() => _CartonEditorState(); _CartonEditorState createState() => _CartonEditorState();
@@ -63,7 +62,7 @@ class _CartonEditorState extends State<CartonEditor> {
double volumetricRatio = 0; double volumetricRatio = 0;
double shipmentWeight = 0; double shipmentWeight = 0;
FcsShipment? _fcsShipment; FcsShipment? _fcsShipment;
List<FcsShipment>? _fcsShipments; List<FcsShipment> _fcsShipments = [];
List<Carton> _cartons = []; List<Carton> _cartons = [];
CartonSize? selectedCatonSize; CartonSize? selectedCatonSize;
@@ -90,8 +89,8 @@ class _CartonEditorState extends State<CartonEditor> {
_widthController.addListener(_calShipmentWeight); _widthController.addListener(_calShipmentWeight);
_heightController.addListener(_calShipmentWeight); _heightController.addListener(_calShipmentWeight);
if (widget.box != null) { if (widget.carton != null) {
_carton = widget.box; _carton = widget.carton;
_deliveryAddress = _carton!.deliveryAddress; _deliveryAddress = _carton!.deliveryAddress;
_widthController.text = _carton!.width.toString(); _widthController.text = _carton!.width.toString();
_heightController.text = _carton!.height.toString(); _heightController.text = _carton!.height.toString();
@@ -138,11 +137,13 @@ class _CartonEditorState extends State<CartonEditor> {
FcsShipmentModel fcsShipmentModel = FcsShipmentModel fcsShipmentModel =
Provider.of<FcsShipmentModel>(context, listen: false); Provider.of<FcsShipmentModel>(context, listen: false);
var fcsShipments = await fcsShipmentModel.getActiveFcsShipments(); var fcsShipments = await fcsShipmentModel.getActiveFcsShipments();
var fcsShipment =
fcsShipments.firstWhere((e) => e.id == _carton!.fcsShipmentID); // var fcsShipment =
// fcsShipments.firstWhere((e) => e.id == _carton?.fcsShipmentID);
setState(() { setState(() {
_fcsShipments = fcsShipments; _fcsShipments = fcsShipments;
_fcsShipment = fcsShipment; // _fcsShipment = fcsShipment;
}); });
} }
@@ -195,9 +196,9 @@ class _CartonEditorState extends State<CartonEditor> {
// } // }
_calShipmentWeight() { _calShipmentWeight() {
double l = double.parse(_lengthController.text); double l = double.tryParse(_lengthController.text) ?? 0;
double w = double.parse(_widthController.text); double w = double.tryParse(_widthController.text) ?? 0;
double h = double.parse(_heightController.text); double h = double.tryParse(_heightController.text) ?? 0;
setState(() { setState(() {
shipmentWeight = l * w * h / volumetricRatio; shipmentWeight = l * w * h / volumetricRatio;
}); });
@@ -248,8 +249,8 @@ class _CartonEditorState extends State<CartonEditor> {
labelKey: "shipment.pack.fcs.shipment", labelKey: "shipment.pack.fcs.shipment",
iconData: Ionicons.ios_airplane, iconData: Ionicons.ios_airplane,
display: (u) => u.shipmentNumber, display: (u) => u.shipmentNumber,
selectedValue: _fcsShipment!, selectedValue: _fcsShipment,
values: _fcsShipments!, values: _fcsShipments,
)); ));
final fcsIDBox = Container( final fcsIDBox = Container(

View File

@@ -144,9 +144,9 @@ class _CartonInfoState extends State<CartonInfo> {
} }
_calShipmentWeight() { _calShipmentWeight() {
double l = double.parse(_lengthController.text); double l = double.tryParse(_lengthController.text) ?? 0;
double w = double.parse(_widthController.text); double w = double.tryParse(_widthController.text) ?? 0;
double h = double.parse(_heightController.text); double h = double.tryParse(_heightController.text) ?? 0;
setState(() { setState(() {
shipmentWeight = l * w * h / volumetricRatio; shipmentWeight = l * w * h / volumetricRatio;
}); });
@@ -412,7 +412,7 @@ class _CartonInfoState extends State<CartonInfo> {
_box!.mixCartons = _box!.mixCartons; _box!.mixCartons = _box!.mixCartons;
bool? updated = await Navigator.push<bool>( bool? updated = await Navigator.push<bool>(
context, context,
CupertinoPageRoute(builder: (context) => CartonEditor(box: _box)), CupertinoPageRoute(builder: (context) => CartonEditor(carton: _box)),
); );
if (updated ?? false) { if (updated ?? false) {
var cartonModel = Provider.of<CartonModel>(context, listen: false); var cartonModel = Provider.of<CartonModel>(context, listen: false);

View File

@@ -1,17 +1,12 @@
import 'package:fcs/domain/constants.dart';
import 'package:fcs/domain/entities/carton.dart'; import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/helpers/theme.dart'; import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/carton/model/carton_model.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/barcode_scanner.dart';
import 'package:fcs/pages/widgets/local_popup_menu_button.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_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:fcs/pagination/paginator_listview.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'carton_list_row.dart'; import 'carton_list_row.dart';
@@ -36,12 +31,16 @@ class PartSearchDelegate extends SearchDelegate<Carton> {
ThemeData appBarTheme(BuildContext context) { ThemeData appBarTheme(BuildContext context) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
return theme.copyWith( return theme.copyWith(
appBarTheme: AppBarTheme(color: primaryColor),
inputDecorationTheme: InputDecorationTheme( inputDecorationTheme: InputDecorationTheme(
border: InputBorder.none,
hintStyle: TextStyle( hintStyle: TextStyle(
color: theme.primaryTextTheme.caption!.color, fontSize: 14)), color: theme.primaryTextTheme.caption?.color, fontSize: 14)),
textTheme: theme.textTheme.copyWith( textTheme: TextTheme(
title: theme.textTheme.title!.copyWith( headline1: TextStyle(
color: theme.primaryTextTheme.title!.color, fontSize: 16)), color: theme.primaryTextTheme.headline1?.color,
fontSize: 16,
backgroundColor: primaryColor)),
primaryColor: primaryColor, primaryColor: primaryColor,
); );
} }

View File

@@ -33,9 +33,14 @@ class _ContactEditorState extends State<ContactEditor> {
Contact? _contact; Contact? _contact;
@override @override
void initState() { void initState() {
if (widget.contact != null) _contact = widget.contact!;
super.initState(); super.initState();
isNew = widget.contact == null; if (widget.contact != null) {
isNew = false;
_contact = widget.contact;
initContact();
} else {
isNew = true;
}
} }
initContact() { initContact() {

View File

@@ -52,7 +52,7 @@ class _ContactPageState extends State<ContactPage> {
contact: Contact.fromSetting(setting)), contact: Contact.fromSetting(setting)),
)), )),
icon: Icon( icon: Icon(
CupertinoIcons.pen, Icons.edit,
color: primaryColor, color: primaryColor,
)) ))
] ]

View File

@@ -85,7 +85,8 @@ class _InvitationCreateState extends State<InvitationCreate> {
), ),
Container( Container(
decoration: BoxDecoration( 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))), borderRadius: BorderRadius.all(Radius.circular(12.0))),
child: CountryCodePicker( child: CountryCodePicker(
onChanged: _countryChange, onChanged: _countryChange,
@@ -94,9 +95,7 @@ class _InvitationCreateState extends State<InvitationCreate> {
showCountryOnly: false, showCountryOnly: false,
showOnlyCountryWhenClosed: false, showOnlyCountryWhenClosed: false,
alignLeft: false, alignLeft: false,
textStyle: TextStyle( textStyle: TextStyle(fontSize: 16, color: Colors.black87),
fontSize: 16,
),
), ),
), ),
SizedBox( SizedBox(

View File

@@ -12,8 +12,8 @@ class CustomerModel extends BaseModel {
List<User> customers = []; List<User> customers = [];
List<User> invitations = []; List<User> invitations = [];
late StreamSubscription<QuerySnapshot>? customerListener; StreamSubscription<QuerySnapshot>? customerListener;
late StreamSubscription<QuerySnapshot>? invitationListener; StreamSubscription<QuerySnapshot>? invitationListener;
@override @override
void privilegeChanged() { void privilegeChanged() {

View File

@@ -4,17 +4,17 @@ import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:fcs/data/services/services.dart'; import 'package:fcs/data/services/services.dart';
import 'package:fcs/domain/constants.dart'; import 'package:fcs/domain/constants.dart';
import 'package:fcs/domain/entities/carton.dart'; import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/domain/vo/message.dart';
import 'package:fcs/helpers/paginator.dart'; import 'package:fcs/helpers/paginator.dart';
import 'package:fcs/pages/main/model/base_model.dart'; import 'package:fcs/pages/main/model/base_model.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
class DeliveryModel extends BaseModel { class DeliveryModel extends BaseModel {
final log = Logger('DeliveryModel'); final log = Logger('DeliveryModel');
List<Carton> get cartons => List<Carton> get cartons => _selectedIndex == 1
_selectedIndex == 1 ? _cartons : List<Carton>.from(_delivered.values); ? _cartons
: List<Carton>.from(_delivered?.values ?? []);
late Paginator _delivered; Paginator? _delivered;
int _selectedIndex = 1; int _selectedIndex = 1;
bool isLoading = false; bool isLoading = false;
List<Carton> _cartons = []; List<Carton> _cartons = [];
@@ -31,9 +31,9 @@ class DeliveryModel extends BaseModel {
_selectedIndex = 1; _selectedIndex = 1;
_loadCartons(); _loadCartons();
if (_delivered != null) _delivered.close(); if (_delivered != null) _delivered!.close();
_delivered = _getDelivered(); _delivered = _getDelivered();
_delivered.load(); _delivered!.load();
} }
Future<void> _loadCartons() async { Future<void> _loadCartons() async {
@@ -57,7 +57,8 @@ class DeliveryModel extends BaseModel {
_cartons.clear(); _cartons.clear();
_cartons = snapshot.docs.map((documentSnapshot) { _cartons = snapshot.docs.map((documentSnapshot) {
var s = Carton.fromMap( var s = Carton.fromMap(
documentSnapshot.data as Map<String, dynamic>, documentSnapshot.id); documentSnapshot.data as Map<String, dynamic>,
documentSnapshot.id);
return s; return s;
}).toList(); }).toList();
notifyListeners(); notifyListeners();
@@ -82,10 +83,10 @@ class DeliveryModel extends BaseModel {
} }
Future<void> loadMore() async { Future<void> loadMore() async {
if (_delivered.ended || _selectedIndex == 1) return; if (_delivered!.ended || _selectedIndex == 1) return;
isLoading = true; isLoading = true;
notifyListeners(); notifyListeners();
await _delivered.load(onFinished: () { await _delivered!.load(onFinished: () {
isLoading = false; isLoading = false;
notifyListeners(); notifyListeners();
}); });
@@ -94,7 +95,7 @@ class DeliveryModel extends BaseModel {
Future<void> refresh() async { Future<void> refresh() async {
if (_selectedIndex == 1) return; if (_selectedIndex == 1) return;
await _delivered.refresh(onFinished: () { await _delivered!.refresh(onFinished: () {
notifyListeners(); notifyListeners();
}); });
} }
@@ -106,7 +107,7 @@ class DeliveryModel extends BaseModel {
@override @override
logout() async { logout() async {
if (listener != null) await listener!.cancel(); if (listener != null) await listener!.cancel();
if (_delivered != null) _delivered.close(); if (_delivered != null) _delivered!.close();
_cartons = []; _cartons = [];
} }

View File

@@ -60,7 +60,7 @@ class DeliveryAddressModel extends BaseModel {
Future<DeliveryAddress> getDeliveryAddress(String id) async { Future<DeliveryAddress> getDeliveryAddress(String id) async {
String path = "/$user_collection/${user!.id}/$delivery_address_collection"; String path = "/$user_collection/${user!.id}/$delivery_address_collection";
var snap = await FirebaseFirestore.instance.collection(path).doc(id).get(); var snap = await FirebaseFirestore.instance.collection(path).doc(id).get();
return DeliveryAddress.fromMap(snap.data as Map<String, dynamic>, snap.id); return DeliveryAddress.fromMap(snap.data()!, snap.id);
} }
void initUser(user) { void initUser(user) {
@@ -96,8 +96,7 @@ class DeliveryAddressModel extends BaseModel {
.orderBy("full_name") .orderBy("full_name")
.get(); .get();
return querySnap.docs return querySnap.docs
.map((e) => .map((e) => DeliveryAddress.fromMap(e.data(), e.id))
DeliveryAddress.fromMap(e.data as Map<String, dynamic>, e.id))
.toList(); .toList();
} }
} }

View File

@@ -80,7 +80,7 @@ class _DiscountEditorState extends State<DiscountEditor> {
customerId = u.id ?? ""; customerId = u.id ?? "";
customerName = u.name ?? ""; customerName = u.name ?? "";
}); });
},popPage: true)), }, popPage: true)),
], ],
); );

View File

@@ -14,10 +14,11 @@ class DiscountModel extends BaseModel {
StreamSubscription<QuerySnapshot>? listener; StreamSubscription<QuerySnapshot>? listener;
List<Discount> _discounts = []; List<Discount> _discounts = [];
List<Discount> get discounts => List<Discount> get discounts => _selectedIndex == 1
_selectedIndex == 1 ? _discounts : List<Discount>.from(_used.values); ? _discounts
: List<Discount>.from(_used?.values ?? []);
late Paginator _used; Paginator? _used;
bool isLoading = false; bool isLoading = false;
int _selectedIndex = 1; int _selectedIndex = 1;
set selectedIndex(int index) { set selectedIndex(int index) {
@@ -31,7 +32,7 @@ class DiscountModel extends BaseModel {
_selectedIndex = 1; _selectedIndex = 1;
_load(); _load();
if (_getUsed() != null) _used = _getUsed(); if (_getUsed() != null) _used = _getUsed();
_used.load(); _used?.load();
} }
void initUser(user) { void initUser(user) {
@@ -49,8 +50,7 @@ class DiscountModel extends BaseModel {
.listen((snaps) { .listen((snaps) {
_discounts.clear(); _discounts.clear();
snaps.docs.forEach((d) { snaps.docs.forEach((d) {
_discounts _discounts.add(Discount.fromMap(d.data(), d.id));
.add(Discount.fromMap(d.data() as Map<String, dynamic>, d.id));
}); });
notifyListeners(); notifyListeners();
}); });
@@ -94,10 +94,10 @@ class DiscountModel extends BaseModel {
} }
Future<void> loadMore() async { Future<void> loadMore() async {
if (_used.ended || _selectedIndex == 1) return; if (_used!.ended || _selectedIndex == 1) return;
isLoading = true; isLoading = true;
notifyListeners(); notifyListeners();
await _used.load(onFinished: () { await _used!.load(onFinished: () {
isLoading = false; isLoading = false;
notifyListeners(); notifyListeners();
}); });
@@ -105,7 +105,7 @@ class DiscountModel extends BaseModel {
Future<void> refresh() async { Future<void> refresh() async {
if (_selectedIndex == 1) return; if (_selectedIndex == 1) return;
await _used.refresh(onFinished: () { await _used!.refresh(onFinished: () {
notifyListeners(); notifyListeners();
}); });
} }
@@ -113,7 +113,7 @@ class DiscountModel extends BaseModel {
@override @override
logout() async { logout() async {
if (listener != null) await listener!.cancel(); if (listener != null) await listener!.cancel();
if (_used != null) _used.close(); if (_used != null) _used!.close();
_discounts = []; _discounts = [];
} }

View File

@@ -48,13 +48,14 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
} }
_load() { _load() {
_shipmentNumberController.text = _fcsShipment!.shipmentNumber ?? ""; _shipmentNumberController.text = _fcsShipment?.shipmentNumber ?? "";
if(_fcsShipment!.cutoffDate != null) if (_fcsShipment?.cutoffDate != null)
_cutoffDateController.text = dateFormatter.format(_fcsShipment!.cutoffDate!); _cutoffDateController.text =
if(_fcsShipment!.arrivalDate != null) dateFormatter.format(_fcsShipment!.cutoffDate!);
if (_fcsShipment?.arrivalDate != null)
_arrivalDateController.text = _arrivalDateController.text =
dateFormatter.format(_fcsShipment!.arrivalDate!); dateFormatter.format(_fcsShipment!.arrivalDate!);
if(_fcsShipment!.departureDate != null) if (_fcsShipment?.departureDate != null)
_departureDateControler.text = _departureDateControler.text =
dateFormatter.format(_fcsShipment!.departureDate!); dateFormatter.format(_fcsShipment!.departureDate!);
_shipmentTypeControler.text = _fcsShipment!.shipType ?? ""; _shipmentTypeControler.text = _fcsShipment!.shipType ?? "";
@@ -169,7 +170,7 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
portBox, portBox,
destinationBox, destinationBox,
statusBox, statusBox,
_fcsShipment!.status == fcs_shipment_confirmed_status _fcsShipment?.status == fcs_shipment_confirmed_status
? shipBtn ? shipBtn
: Container(), : Container(),
SizedBox( SizedBox(
@@ -185,7 +186,6 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
} }
_edit() async { _edit() async {
var f;
bool? updated = await Navigator.push<bool>( bool? updated = await Navigator.push<bool>(
context, context,
CupertinoPageRoute( CupertinoPageRoute(
@@ -193,14 +193,16 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
); );
if (updated ?? false) { if (updated ?? false) {
var shipmentModel = Provider.of<FcsShipmentModel>(context, listen: false); var shipmentModel = Provider.of<FcsShipmentModel>(context, listen: false);
if(_fcsShipment != null && _fcsShipment!.id != null ) if (_fcsShipment != null && _fcsShipment!.id != null) {
f = await shipmentModel.getFcsShipment(_fcsShipment!.id!); FcsShipment? f = await shipmentModel.getFcsShipment(_fcsShipment!.id!);
if (f == null) return;
setState(() { setState(() {
_fcsShipment = f; _fcsShipment = f;
}); });
_load(); _load();
} }
} }
}
Widget menuPopWidget(BuildContext context) { Widget menuPopWidget(BuildContext context) {
return PopupMenuButton<PopupMenu>( return PopupMenuButton<PopupMenu>(

View File

@@ -15,9 +15,9 @@ class FcsShipmentModel extends BaseModel {
List<FcsShipment> _fcsShipments = []; List<FcsShipment> _fcsShipments = [];
List<FcsShipment> get fcsShipments => _selectedIndex == 1 List<FcsShipment> get fcsShipments => _selectedIndex == 1
? _fcsShipments ? _fcsShipments
: List<FcsShipment>.from(_shipped.values); : List<FcsShipment>.from(_shipped!.values);
late Paginator _shipped; Paginator? _shipped;
bool isLoading = false; bool isLoading = false;
int _selectedIndex = 1; int _selectedIndex = 1;
set selectedIndex(int index) { set selectedIndex(int index) {
@@ -37,9 +37,9 @@ class FcsShipmentModel extends BaseModel {
_selectedIndex = 1; _selectedIndex = 1;
_loadFcsShipments(); _loadFcsShipments();
if (_shipped != null) _shipped.close(); if (_shipped != null) _shipped!.close();
_shipped = _getShipped(); _shipped = _getShipped();
_shipped.load(); _shipped!.load();
} }
Future<void> _loadFcsShipments() async { Future<void> _loadFcsShipments() async {
@@ -58,7 +58,8 @@ class FcsShipmentModel extends BaseModel {
_fcsShipments.clear(); _fcsShipments.clear();
_fcsShipments = snapshot.docs.map((documentSnapshot) { _fcsShipments = snapshot.docs.map((documentSnapshot) {
var s = FcsShipment.fromMap( var s = FcsShipment.fromMap(
documentSnapshot.data() as Map<String,dynamic>, documentSnapshot.id); documentSnapshot.data() as Map<String, dynamic>,
documentSnapshot.id);
return s; return s;
}).toList(); }).toList();
notifyListeners(); notifyListeners();
@@ -83,10 +84,10 @@ class FcsShipmentModel extends BaseModel {
} }
Future<void> loadMore() async { Future<void> loadMore() async {
if (_shipped.ended || _selectedIndex == 1) return; if (_shipped!.ended || _selectedIndex == 1) return;
isLoading = true; isLoading = true;
notifyListeners(); notifyListeners();
await _shipped.load(onFinished: () { await _shipped!.load(onFinished: () {
isLoading = false; isLoading = false;
notifyListeners(); notifyListeners();
}); });
@@ -94,7 +95,7 @@ class FcsShipmentModel extends BaseModel {
Future<void> refresh() async { Future<void> refresh() async {
if (_selectedIndex == 1) return; if (_selectedIndex == 1) return;
await _shipped.refresh(onFinished: () { await _shipped!.refresh(onFinished: () {
notifyListeners(); notifyListeners();
}); });
} }
@@ -107,8 +108,8 @@ class FcsShipmentModel extends BaseModel {
.where("status", isEqualTo: fcs_shipment_confirmed_status) .where("status", isEqualTo: fcs_shipment_confirmed_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 = FcsShipment.fromMap( var fcs =
documentSnapshot.data as Map<String,dynamic>, documentSnapshot.id); FcsShipment.fromMap(documentSnapshot.data(), documentSnapshot.id);
return fcs; return fcs;
}).toList(); }).toList();
} catch (e) { } catch (e) {
@@ -123,7 +124,7 @@ class FcsShipmentModel extends BaseModel {
.collection("/$fcs_shipment_collection") .collection("/$fcs_shipment_collection")
.doc(id) .doc(id)
.get(const GetOptions(source: Source.server)); .get(const GetOptions(source: Source.server));
var fcs = FcsShipment.fromMap(snap.data as Map<String,dynamic>, snap.id); var fcs = FcsShipment.fromMap(snap.data()!, snap.id);
return fcs; return fcs;
} catch (e) { } catch (e) {
@@ -141,7 +142,7 @@ class FcsShipmentModel extends BaseModel {
.get(const GetOptions(source: Source.server)); .get(const GetOptions(source: Source.server));
fcsShipments = snaps.docs.map((documentSnapshot) { fcsShipments = snaps.docs.map((documentSnapshot) {
var fcs = FcsShipment.fromMap( var fcs = FcsShipment.fromMap(
documentSnapshot.data as Map<String,dynamic>, documentSnapshot.id); documentSnapshot.data as Map<String, dynamic>, documentSnapshot.id);
return fcs; return fcs;
}).toList(); }).toList();
} catch (e) { } catch (e) {
@@ -157,7 +158,7 @@ class FcsShipmentModel extends BaseModel {
@override @override
logout() async { logout() async {
if (listener != null) await listener!.cancel(); if (listener != null) await listener!.cancel();
if (_shipped != null) _shipped.close(); if (_shipped != null) _shipped!.close();
_fcsShipments = []; _fcsShipments = [];
} }

View File

@@ -1,7 +1,6 @@
import 'package:fcs/domain/entities/discount.dart'; import 'package:fcs/domain/entities/discount.dart';
import 'package:fcs/helpers/theme.dart'; import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/widgets/local_text.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/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -37,17 +36,18 @@ class InvoiceDiscountList extends StatelessWidget {
} }
Widget table(BuildContext context) { Widget table(BuildContext context) {
return MyDataTable( return DataTable(
headingRowHeight: 40, headingRowHeight: 40,
showCheckboxColumn: false,
columns: [ columns: [
MyDataColumn( DataColumn(
label: LocalText( label: LocalText(
context, context,
"discount.code", "discount.code",
color: Colors.grey, color: Colors.grey,
), ),
), ),
MyDataColumn( DataColumn(
label: LocalText( label: LocalText(
context, context,
"discount.amount", "discount.amount",
@@ -59,19 +59,19 @@ class InvoiceDiscountList extends StatelessWidget {
); );
} }
List<MyDataRow> getRows(BuildContext context) { List<DataRow> getRows(BuildContext context) {
if (discounts == null) { if (discounts == null) {
return []; return [];
} }
var rows = discounts!.map((c) { var rows = discounts!.map((c) {
return MyDataRow( return DataRow(
onSelectChanged: (value) => Navigator.pop(context, c), onSelectChanged: (value) => Navigator.pop(context, c),
cells: [ cells: [
MyDataCell(new Text( DataCell(new Text(
c?.code ?? '', c?.code ?? '',
style: textStyle, style: textStyle,
)), )),
MyDataCell( DataCell(
Row( Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [

View File

@@ -1,7 +1,6 @@
import 'package:fcs/domain/entities/shipment.dart'; import 'package:fcs/domain/entities/shipment.dart';
import 'package:fcs/helpers/theme.dart'; import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/widgets/local_text.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/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -41,17 +40,18 @@ class InvoiceHandlingFeeList extends StatelessWidget {
} }
Widget table(BuildContext context) { Widget table(BuildContext context) {
return MyDataTable( return DataTable(
headingRowHeight: 40, headingRowHeight: 40,
showCheckboxColumn: false,
columns: [ columns: [
MyDataColumn( DataColumn(
label: LocalText( label: LocalText(
context, context,
"invoice.shipment.number", "invoice.shipment.number",
color: Colors.grey, color: Colors.grey,
), ),
), ),
MyDataColumn( DataColumn(
label: LocalText( label: LocalText(
context, context,
"invoice.add.handling.fee.menu", "invoice.add.handling.fee.menu",
@@ -63,19 +63,19 @@ class InvoiceHandlingFeeList extends StatelessWidget {
); );
} }
List<MyDataRow> getRows(BuildContext context) { List<DataRow> getRows(BuildContext context) {
if (shipments == null) { if (shipments == null) {
return []; return [];
} }
var rows = shipments!.map((c) { var rows = shipments!.map((c) {
return MyDataRow( return DataRow(
onSelectChanged: (value) => Navigator.pop(context, c), onSelectChanged: (value) => Navigator.pop(context, c),
cells: [ cells: [
MyDataCell(new Text( DataCell(new Text(
c!.shipmentNumber!, c!.shipmentNumber!,
style: textStyle, style: textStyle,
)), )),
MyDataCell( DataCell(
Row( Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [

View File

@@ -42,7 +42,7 @@ Future<void> showConfirmDialog(
child: LocalText( child: LocalText(
context, context,
translationKey, translationKey,
translationVariables: translationVariables!, translationVariables: translationVariables,
color: primaryColor, color: primaryColor,
), ),
), ),

View File

@@ -143,7 +143,7 @@ class PackageModel extends BaseModel {
await FirebaseFirestore.instance.collection("$path").doc(id).get(); await FirebaseFirestore.instance.collection("$path").doc(id).get();
if (snap.exists) { if (snap.exists) {
var package = var package =
Package.fromMap(snap.data as Map<String, dynamic>, snap.id); Package.fromMap(snap.data() as Map<String, dynamic>, snap.id);
return package; return package;
} }
} catch (e) { } catch (e) {

View File

@@ -56,7 +56,7 @@ class _PackageInfoState extends State<PackageInfo> {
PackageModel packageModel = PackageModel packageModel =
Provider.of<PackageModel>(context, listen: false); Provider.of<PackageModel>(context, listen: false);
Package? package = Package? package =
await packageModel.getPackageByTrackingID(pkg!.trackingID!); await packageModel.getPackageByTrackingID(pkg.trackingID!);
setState(() { setState(() {
_package = package; _package = package;
multiImgController.setImageUrls = package!.photoUrls; multiImgController.setImageUrls = package!.photoUrls;
@@ -193,7 +193,6 @@ class _PackageInfoState extends State<PackageInfo> {
} }
_changeDeliverayAddress(DeliveryAddress deliveryAddress) async { _changeDeliverayAddress(DeliveryAddress deliveryAddress) async {
if (deliveryAddress == null) return;
setState(() { setState(() {
_isLoading = true; _isLoading = true;
}); });

View File

@@ -29,12 +29,16 @@ class PackageSearchDelegate extends SearchDelegate<Package> {
ThemeData appBarTheme(BuildContext context) { ThemeData appBarTheme(BuildContext context) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
return theme.copyWith( return theme.copyWith(
appBarTheme: AppBarTheme(color: primaryColor),
inputDecorationTheme: InputDecorationTheme( inputDecorationTheme: InputDecorationTheme(
border: InputBorder.none,
hintStyle: TextStyle( hintStyle: TextStyle(
color: theme.primaryTextTheme.caption!.color, fontSize: 14)), color: theme.primaryTextTheme.caption?.color, fontSize: 14)),
textTheme: theme.textTheme.copyWith( textTheme: TextTheme(
title: theme.textTheme.title!.copyWith( headline1: TextStyle(
color: theme.primaryTextTheme.title!.color, fontSize: 16)), color: theme.primaryTextTheme.headline1?.color,
fontSize: 16,
backgroundColor: primaryColor)),
primaryColor: primaryColor, primaryColor: primaryColor,
); );
} }

View File

@@ -44,10 +44,10 @@ class _PackageEditorState extends State<PackageEditor> {
void initState() { void initState() {
super.initState(); super.initState();
_package = Package(); _package = Package();
_loadPackageData(widget.package!.id!); _loadPackageData(widget.package?.id!);
} }
_loadPackageData(String id) async { _loadPackageData(String? id) async {
if (id != null) { if (id != null) {
PackageModel packageModel = PackageModel packageModel =
Provider.of<PackageModel>(context, listen: false); Provider.of<PackageModel>(context, listen: false);

View File

@@ -42,8 +42,8 @@ class _ProcessingEditEditorState extends State<ProcessingEditEditor> {
super.initState(); super.initState();
_package = widget.package; _package = widget.package;
selectedMarket = _package!.market ?? ""; selectedMarket = _package!.market ?? "";
_descCtl.text = _package!.desc!; _descCtl.text = _package!.desc ?? "";
_remarkCtl.text = _package!.remark!; _remarkCtl.text = _package!.remark ?? "";
multiImgController.setImageUrls = _package!.photoUrls; multiImgController.setImageUrls = _package!.photoUrls;
_user = User( _user = User(
fcsID: _package!.fcsID ?? "", fcsID: _package!.fcsID ?? "",

View File

@@ -39,7 +39,8 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
initPackage(widget.package!); initPackage(widget.package!);
} }
initPackage(Package package) { initPackage(Package? package) {
if (package == null) return;
setState(() { setState(() {
_package = package; _package = package;
multiImgController.setImageUrls = package.photoUrls; multiImgController.setImageUrls = package.photoUrls;
@@ -69,37 +70,37 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
iconData: Icons.phone, iconData: Icons.phone,
); );
final customerNameBox = DisplayText( final customerNameBox = DisplayText(
text:_package!=null? _package!.userName:"", text: _package != null ? _package!.userName : "",
labelTextKey: "processing.consignee.name", labelTextKey: "processing.consignee.name",
iconData: Icons.perm_identity, iconData: Icons.perm_identity,
); );
var senderFcsIDBox = DisplayText( var senderFcsIDBox = DisplayText(
text:_package!=null? _package!.senderFCSID:"", text: _package != null ? _package!.senderFCSID : "",
labelTextKey: "processing.fcs.id", labelTextKey: "processing.fcs.id",
icon: FcsIDIcon(), icon: FcsIDIcon(),
); );
final senderPhoneNumberBox = DisplayText( final senderPhoneNumberBox = DisplayText(
text: _package!=null?_package!.senderPhoneNumber:"", text: _package != null ? _package!.senderPhoneNumber : "",
labelTextKey: "processing.phone", labelTextKey: "processing.phone",
iconData: Icons.phone, iconData: Icons.phone,
); );
final senderNameBox = DisplayText( final senderNameBox = DisplayText(
text:_package!=null? _package!.senderName:"", text: _package != null ? _package!.senderName : "",
labelTextKey: "processing.shipper.name", labelTextKey: "processing.shipper.name",
iconData: Icons.perm_identity, iconData: Icons.perm_identity,
); );
final marketBox = DisplayText( final marketBox = DisplayText(
text:_package!=null? _package!.market : "-", text: _package != null ? _package!.market : "-",
labelTextKey: "processing.market", labelTextKey: "processing.market",
iconData: Icons.store, iconData: Icons.store,
); );
final descBox = DisplayText( final descBox = DisplayText(
text:_package!=null? _package!.desc : "-", text: _package != null ? _package!.desc : "-",
labelTextKey: "processing.desc", labelTextKey: "processing.desc",
iconData: MaterialCommunityIcons.message_text_outline, iconData: MaterialCommunityIcons.message_text_outline,
); );
final remarkBox = DisplayText( final remarkBox = DisplayText(
text:_package!=null? _package!.remark : "-", text: _package != null ? _package!.remark : "-",
labelTextKey: "processing.remark", labelTextKey: "processing.remark",
iconData: Entypo.new_message, iconData: Entypo.new_message,
); );
@@ -175,7 +176,7 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
_package!.photoUrls.length == 0 ? Container() : img, _package!.photoUrls.length == 0 ? Container() : img,
StatusTree( StatusTree(
shipmentHistory: _package!.shipmentHistory, shipmentHistory: _package!.shipmentHistory,
currentStatus: _package!.status??""), currentStatus: _package!.status ?? ""),
SizedBox( SizedBox(
height: 20, height: 20,
) )
@@ -223,7 +224,7 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
PackageModel packageModel = PackageModel packageModel =
Provider.of<PackageModel>(context, listen: false); Provider.of<PackageModel>(context, listen: false);
Package? p = await packageModel.getPackage(_package!.id!); Package? p = await packageModel.getPackage(_package!.id!);
initPackage(p!); initPackage(p);
} }
} }
} }

View File

@@ -63,7 +63,7 @@ class _ShipmentRatesState extends State<ShipmentRates> {
CupertinoPageRoute( CupertinoPageRoute(
builder: (context) => ShipmentRatesEdit())), builder: (context) => ShipmentRatesEdit())),
icon: Icon( icon: Icon(
CupertinoIcons.pen, Icons.edit,
color: primaryColor, color: primaryColor,
)) ))
] ]

View File

@@ -231,6 +231,11 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
showMsgDialog(context, "Error", "Invalid tracking ID!"); showMsgDialog(context, "Error", "Invalid tracking ID!");
return; return;
} }
if (user == null) {
showMsgDialog(context, "Error", "Please select FCS ID");
return;
}
setState(() { setState(() {
_isLoading = true; _isLoading = true;
}); });

View File

@@ -40,7 +40,8 @@ class _ReceivingInfoState extends State<ReceivingInfo> {
initPackage(widget.package!); initPackage(widget.package!);
} }
initPackage(Package package) { initPackage(Package? package) {
if (package == null) return;
multiImgController.setImageUrls = package.photoUrls; multiImgController.setImageUrls = package.photoUrls;
setState(() { setState(() {
_package = package; _package = package;
@@ -150,7 +151,7 @@ class _ReceivingInfoState extends State<ReceivingInfo> {
PackageModel packageModel = PackageModel packageModel =
Provider.of<PackageModel>(context, listen: false); Provider.of<PackageModel>(context, listen: false);
var pkg = await packageModel.getPackage(widget.package!.id!); var pkg = await packageModel.getPackage(widget.package!.id!);
initPackage(pkg!); initPackage(pkg);
} }
_delete() { _delete() {

View File

@@ -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_button.dart';
import 'package:fcs/pages/widgets/local_text.dart'; import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/local_title.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:fcs/pages/widgets/progress.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -160,17 +159,18 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
_addCargo(cargo); _addCargo(cargo);
}), }),
), ),
MyDataTable( DataTable(
headingRowHeight: 40, headingRowHeight: 40,
showCheckboxColumn: false,
columns: [ columns: [
MyDataColumn( DataColumn(
label: LocalText( label: LocalText(
context, context,
"cargo.type", "cargo.type",
color: Colors.grey, color: Colors.grey,
), ),
), ),
MyDataColumn( DataColumn(
label: LocalText( label: LocalText(
context, context,
"cargo.weight", "cargo.weight",
@@ -211,15 +211,15 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
); );
} }
List<MyDataRow> getCargoRows(BuildContext context) { List<DataRow> getCargoRows(BuildContext context) {
if (_box!.cargoTypes == null) { if (_box!.cargoTypes == null) {
return []; return [];
} }
double total = 0; double total = 0;
var rows = _box!.cargoTypes.map((c) { var rows = _box!.cargoTypes.map((c) {
total += c.weight; total += c.weight;
return MyDataRow( return DataRow(
onSelectChanged: (bool selected) async { onSelectChanged: (bool? selected) async {
CargoType? cargo = await Navigator.push<CargoType>( CargoType? cargo = await Navigator.push<CargoType>(
context, context,
CupertinoPageRoute( CupertinoPageRoute(
@@ -230,11 +230,11 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
_addCargo(cargo); _addCargo(cargo);
}, },
cells: [ cells: [
MyDataCell(new Text( DataCell(new Text(
c.name == null ? "" : c.name!, c.name == null ? "" : c.name!,
style: textStyle, style: textStyle,
)), )),
MyDataCell( DataCell(
Row( Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
@@ -254,10 +254,10 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
); );
}).toList(); }).toList();
var totalRow = MyDataRow( var totalRow = DataRow(
onSelectChanged: (bool selected) {}, onSelectChanged: (bool? selected) {},
cells: [ cells: [
MyDataCell(Align( DataCell(Align(
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: LocalText( child: LocalText(
context, context,
@@ -266,7 +266,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
)), )),
MyDataCell( DataCell(
Padding( Padding(
padding: const EdgeInsets.only(right: 48.0), padding: const EdgeInsets.only(right: 48.0),
child: Align( child: Align(

View File

@@ -70,10 +70,11 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
_fromTimeEditingController.text = "${timeFormatter.format(now)}"; _fromTimeEditingController.text = "${timeFormatter.format(now)}";
_toTimeEditingController.text = "${timeFormatter.format(now)}"; _toTimeEditingController.text = "${timeFormatter.format(now)}";
// _shipment = Shipment(boxes: []); // _shipment = Shipment(boxes: []);
var shipmentModel =
Provider.of<DeliveryAddressModel>(context, listen: false); Shipment _s = Shipment(
_shipment!.pickupAddress = shipmentModel.defalutAddress; pickupAddress: context.read<DeliveryAddressModel>().defalutAddress,
_shipment!.boxes = []; boxes: []);
_shipment = _s;
_pickupDate.text = dateFormatter.format(now); _pickupDate.text = dateFormatter.format(now);
} }
} }
@@ -87,12 +88,12 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
MainModel mainModel = Provider.of<MainModel>(context); MainModel mainModel = Provider.of<MainModel>(context);
ShipmentModel pickupModel = Provider.of<ShipmentModel>(context); ShipmentModel pickupModel = Provider.of<ShipmentModel>(context);
final shipmentNumberBox = getShipmentNumberStatus(context, _shipment!); final shipmentNumberBox = getShipmentNumberStatus(context, _shipment);
bool isLocalPickup = _selectedShipmentType == shipment_local_pickup; bool isLocalPickup = _selectedShipmentType == shipment_local_pickup;
bool isCourierPickup = _selectedShipmentType == shipment_courier_pickup; bool isCourierPickup = _selectedShipmentType == shipment_courier_pickup;
bool isLocalDropoff = _selectedShipmentType == shipment_local_dropoff; bool isLocalDropoff = _selectedShipmentType == shipment_local_dropoff;
bool isCourierDropoff = _selectedShipmentType == shipment_courier_dropoff; bool isCourierDropoff = _selectedShipmentType == shipment_courier_dropoff;
var deliveryAddressModel = Provider.of<DeliveryAddressModel>(context);
final fromTimeBox = InputTime( final fromTimeBox = InputTime(
labelTextKey: 'shipment.from', labelTextKey: 'shipment.from',
iconData: Icons.timer, iconData: Icons.timer,
@@ -122,7 +123,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
backgroundColor: Colors.white, backgroundColor: Colors.white,
)); ));
final pickupAddressBox = DefaultDeliveryAddress( final pickupAddressBox = DefaultDeliveryAddress(
deliveryAddress: _shipment!.pickupAddress, deliveryAddress: _shipment?.pickupAddress,
iconData: Icons.location_on, iconData: Icons.location_on,
labelKey: "shipment.location", labelKey: "shipment.location",
onTap: () async { onTap: () async {
@@ -130,12 +131,15 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
context, context,
CupertinoPageRoute( CupertinoPageRoute(
builder: (context) => DeliveryAddressSelection( builder: (context) => DeliveryAddressSelection(
deliveryAddress: _shipment!.pickupAddress, deliveryAddress: _shipment?.pickupAddress,
user: mainModel.user)), user: mainModel.user)),
); );
if (address == null) return; if (address == null) return;
setState(() { setState(() {
_shipment!.pickupAddress = address; Shipment _s = Shipment(pickupAddress: address);
_shipment = _s;
}); });
}, },
); );
@@ -230,17 +234,18 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
color: primaryColor, color: primaryColor,
), ),
onPressed: () async { onPressed: () async {
Carton box = await Navigator.push( Carton? box = await Navigator.push(
context, context,
CupertinoPageRoute( CupertinoPageRoute(
builder: (context) => ShipmentBoxEditor()), builder: (context) => ShipmentBoxEditor()),
); );
if (box == null) return;
_addBox(box); _addBox(box);
}, },
), ),
), ),
Column( Column(
children: getBoxList(context, _shipment!.boxes), children: getBoxList(context, _shipment?.boxes ?? []),
), ),
_isNew ? createBtn : updateBtn, _isNew ? createBtn : updateBtn,
], ],
@@ -324,6 +329,6 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
} }
isDataChanged() { isDataChanged() {
return _shipment!.boxes.isNotEmpty; return _shipment?.boxes.isNotEmpty;
} }
} }

View File

@@ -3,21 +3,21 @@ import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/widgets/local_text.dart'; import 'package:fcs/pages/widgets/local_text.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
Widget getShipmentNumberStatus(BuildContext context, Shipment shipment) { Widget getShipmentNumberStatus(BuildContext context, Shipment? shipment) {
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
LocalText( LocalText(
context, context,
'', '',
text: shipment.shipmentNumber ?? "", text: shipment?.shipmentNumber ?? "",
color: primaryColor, color: primaryColor,
fontSize: 18, fontSize: 18,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
Padding( Padding(
padding: const EdgeInsets.only(left: 8.0), padding: const EdgeInsets.only(left: 8.0),
child: Chip(label: Text(shipment.status ?? "")), child: Chip(label: Text(shipment?.status ?? "")),
), ),
], ],
); );

View File

@@ -90,9 +90,7 @@ class _SigninPageState extends State<SigninPage> {
showCountryOnly: false, showCountryOnly: false,
showOnlyCountryWhenClosed: false, showOnlyCountryWhenClosed: false,
alignLeft: false, alignLeft: false,
textStyle: TextStyle( textStyle: TextStyle(fontSize: 16, color: Colors.black87),
fontSize: 16,
),
), ),
), ),
SizedBox( SizedBox(

View File

@@ -29,12 +29,16 @@ class UserSearchDelegate extends SearchDelegate<User> {
ThemeData appBarTheme(BuildContext context) { ThemeData appBarTheme(BuildContext context) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
return theme.copyWith( return theme.copyWith(
appBarTheme: AppBarTheme(color: primaryColor),
inputDecorationTheme: InputDecorationTheme( inputDecorationTheme: InputDecorationTheme(
border: InputBorder.none,
hintStyle: TextStyle( hintStyle: TextStyle(
color: theme.primaryTextTheme.caption?.color, fontSize: 14)), color: theme.primaryTextTheme.caption?.color, fontSize: 14)),
textTheme: theme.textTheme.copyWith( textTheme: TextTheme(
title: theme.textTheme.title?.copyWith( headline1: TextStyle(
color: theme.primaryTextTheme.title?.color, fontSize: 16)), color: theme.primaryTextTheme.headline1?.color,
fontSize: 16,
backgroundColor: primaryColor)),
primaryColor: primaryColor, primaryColor: primaryColor,
); );
} }

View File

@@ -61,10 +61,10 @@ class _DeliveryAddressSelectionState extends State<DeliveryAddressSelection> {
), ),
floatingActionButton: FloatingActionButton.extended( floatingActionButton: FloatingActionButton.extended(
onPressed: () async { onPressed: () async {
bool updated = await Navigator.of(context).push(CupertinoPageRoute( bool? updated = await Navigator.of(context).push(CupertinoPageRoute(
builder: (context) => builder: (context) =>
DeliveryAddressEditor(user: widget.user))); DeliveryAddressEditor(user: widget.user)));
if (updated) { if (updated ?? false) {
_getDeliverAddresses(); _getDeliverAddresses();
} }
}, },
@@ -114,10 +114,10 @@ class _DeliveryAddressSelectionState extends State<DeliveryAddressSelection> {
} }
_edit(BuildContext context, DeliveryAddress deliveryAddress) async { _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( builder: (context) => DeliveryAddressEditor(
user: widget.user, deliveryAddress: deliveryAddress))); user: widget.user, deliveryAddress: deliveryAddress)));
if (updated) { if (updated ?? false) {
_getDeliverAddresses(); _getDeliverAddresses();
} }
} }

View File

@@ -622,7 +622,6 @@ class MyDataTable extends StatelessWidget {
final List<TableColumnWidth> tableColumns = (columns.length + final List<TableColumnWidth> tableColumns = (columns.length +
(showCheckboxColumn ? 1 : 0)) as List<TableColumnWidth>; (showCheckboxColumn ? 1 : 0)) as List<TableColumnWidth>;
final List<TableRow> tableRows = List<TableRow>.generate( final List<TableRow> tableRows = List<TableRow>.generate(
rows.length + 1, // the +1 is for the header row rows.length + 1, // the +1 is for the header row
(int index) { (int index) {

View File

@@ -7,14 +7,14 @@ packages:
name: _fe_analyzer_shared name: _fe_analyzer_shared
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "22.0.0" version: "25.0.0"
analyzer: analyzer:
dependency: transitive dependency: transitive
description: description:
name: analyzer name: analyzer
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.7.1" version: "2.2.0"
args: args:
dependency: transitive dependency: transitive
description: description:
@@ -28,7 +28,7 @@ packages:
name: async name: async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.6.1" version: "2.8.1"
barcode_scan2: barcode_scan2:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -91,7 +91,7 @@ packages:
name: charcode name: charcode
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.3.1"
cli_util: cli_util:
dependency: transitive dependency: transitive
description: description:
@@ -434,6 +434,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "9.1.0" 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: glob:
dependency: transitive dependency: transitive
description: description:
@@ -531,7 +538,7 @@ packages:
name: meta name: meta
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0" version: "1.7.0"
mime: mime:
dependency: transitive dependency: transitive
description: description:
@@ -893,21 +900,21 @@ packages:
name: test name: test
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.16.8" version: "1.17.10"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.3.0" version: "0.4.2"
test_core: test_core:
dependency: transitive dependency: transitive
description: description:
name: test_core name: test_core
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.3.19" version: "0.4.0"
timeline_list: timeline_list:
dependency: "direct main" dependency: "direct main"
description: description: