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_processing = "pr";
const privilege_receiving = "rc";
const privilege_pickup = "pku";
// Pickup types
const shipment_local_pickup = "Local pickup";

View File

@@ -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<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 = da != null ? DeliveryAddress.fromMap(da, da["id"]) : null;
var cargoTypesMaps =

View File

@@ -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,

View File

@@ -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,

View File

@@ -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;
}

View File

@@ -22,25 +22,26 @@ class _CargoTableState extends State<CargoTable> {
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<CargoTable> {
);
}
List<MyDataRow> getCargoRows(BuildContext context) {
List<DataRow> 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<CargoTable> {
style: textStyle,
),
)),
MyDataCell(
DataCell(
Text(c.weight == null ? "0" : c.weight.toStringAsFixed(2),
style: textStyle),
),
@@ -88,10 +89,10 @@ class _CargoTableState extends State<CargoTable> {
);
}).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<CargoTable> {
fontWeight: FontWeight.bold,
),
)),
MyDataCell(Text("")),
MyDataCell(
DataCell(Text("")),
DataCell(
Padding(
padding: const EdgeInsets.only(right: 48.0),
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/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<CargoTable> {
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<CargoTable> {
);
}
List<MyDataRow> getCargoRows(BuildContext context) {
List<DataRow> 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<CargoTable> {
),
),
),
MyDataCell(
DataCell(
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
@@ -185,10 +185,10 @@ class _CargoTableState extends State<CargoTable> {
);
}).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<CargoTable> {
fontWeight: FontWeight.bold,
),
)),
MyDataCell(Text("")),
MyDataCell(
DataCell(Text("")),
DataCell(
Padding(
padding: const EdgeInsets.only(right: 48.0),
child: Align(

View File

@@ -28,17 +28,18 @@ class _CargoTableState extends State<CargoTable> {
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<CargoTable> {
);
}
List<MyDataRow> getCargoRows(BuildContext context) {
List<DataRow> getCargoRows(BuildContext context) {
if (widget.cargoTypes == null) {
return [];
}
@@ -67,10 +68,10 @@ class _CargoTableState extends State<CargoTable> {
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<CargoTable> {
),
],
)),
MyDataCell(
DataCell(
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
@@ -106,10 +107,10 @@ class _CargoTableState extends State<CargoTable> {
);
}).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<CargoTable> {
fontWeight: FontWeight.bold,
),
)),
MyDataCell(
DataCell(
Padding(
padding: const EdgeInsets.only(right: 40.0),
child: Align(
@@ -144,7 +145,8 @@ class _CargoTableState extends State<CargoTable> {
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) {

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_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<CartonEditor> {
double volumetricRatio = 0;
double shipmentWeight = 0;
FcsShipment? _fcsShipment;
List<FcsShipment>? _fcsShipments;
List<FcsShipment> _fcsShipments = [];
List<Carton> _cartons = [];
CartonSize? selectedCatonSize;
@@ -90,8 +89,8 @@ class _CartonEditorState extends State<CartonEditor> {
_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<CartonEditor> {
FcsShipmentModel fcsShipmentModel =
Provider.of<FcsShipmentModel>(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<CartonEditor> {
// }
_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<CartonEditor> {
labelKey: "shipment.pack.fcs.shipment",
iconData: Ionicons.ios_airplane,
display: (u) => u.shipmentNumber,
selectedValue: _fcsShipment!,
values: _fcsShipments!,
selectedValue: _fcsShipment,
values: _fcsShipments,
));
final fcsIDBox = Container(

View File

@@ -144,9 +144,9 @@ class _CartonInfoState extends State<CartonInfo> {
}
_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<CartonInfo> {
_box!.mixCartons = _box!.mixCartons;
bool? updated = await Navigator.push<bool>(
context,
CupertinoPageRoute(builder: (context) => CartonEditor(box: _box)),
CupertinoPageRoute(builder: (context) => CartonEditor(carton: _box)),
);
if (updated ?? 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/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<Carton> {
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,
);
}

View File

@@ -33,9 +33,14 @@ class _ContactEditorState extends State<ContactEditor> {
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() {

View File

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

View File

@@ -85,7 +85,8 @@ class _InvitationCreateState extends State<InvitationCreate> {
),
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<InvitationCreate> {
showCountryOnly: false,
showOnlyCountryWhenClosed: false,
alignLeft: false,
textStyle: TextStyle(
fontSize: 16,
),
textStyle: TextStyle(fontSize: 16, color: Colors.black87),
),
),
SizedBox(

View File

@@ -12,8 +12,8 @@ class CustomerModel extends BaseModel {
List<User> customers = [];
List<User> invitations = [];
late StreamSubscription<QuerySnapshot>? customerListener;
late StreamSubscription<QuerySnapshot>? invitationListener;
StreamSubscription<QuerySnapshot>? customerListener;
StreamSubscription<QuerySnapshot>? invitationListener;
@override
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/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<Carton> get cartons =>
_selectedIndex == 1 ? _cartons : List<Carton>.from(_delivered.values);
List<Carton> get cartons => _selectedIndex == 1
? _cartons
: List<Carton>.from(_delivered?.values ?? []);
late Paginator _delivered;
Paginator? _delivered;
int _selectedIndex = 1;
bool isLoading = false;
List<Carton> _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<void> _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<String, dynamic>, documentSnapshot.id);
documentSnapshot.data as Map<String, dynamic>,
documentSnapshot.id);
return s;
}).toList();
notifyListeners();
@@ -82,10 +83,10 @@ class DeliveryModel extends BaseModel {
}
Future<void> 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<void> 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 = [];
}

View File

@@ -60,7 +60,7 @@ class DeliveryAddressModel extends BaseModel {
Future<DeliveryAddress> 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<String, dynamic>, 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<String, dynamic>, e.id))
.map((e) => DeliveryAddress.fromMap(e.data(), e.id))
.toList();
}
}

View File

@@ -14,10 +14,11 @@ class DiscountModel extends BaseModel {
StreamSubscription<QuerySnapshot>? listener;
List<Discount> _discounts = [];
List<Discount> get discounts =>
_selectedIndex == 1 ? _discounts : List<Discount>.from(_used.values);
List<Discount> get discounts => _selectedIndex == 1
? _discounts
: List<Discount>.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<String, dynamic>, d.id));
_discounts.add(Discount.fromMap(d.data(), d.id));
});
notifyListeners();
});
@@ -94,10 +94,10 @@ class DiscountModel extends BaseModel {
}
Future<void> 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<void> 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 = [];
}

View File

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

View File

@@ -15,9 +15,9 @@ class FcsShipmentModel extends BaseModel {
List<FcsShipment> _fcsShipments = [];
List<FcsShipment> get fcsShipments => _selectedIndex == 1
? _fcsShipments
: List<FcsShipment>.from(_shipped.values);
: List<FcsShipment>.from(_shipped!.values);
late Paginator _shipped;
Paginator? _shipped;
bool isLoading = false;
int _selectedIndex = 1;
set selectedIndex(int index) {
@@ -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<void> _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<String,dynamic>, documentSnapshot.id);
documentSnapshot.data() as Map<String, dynamic>,
documentSnapshot.id);
return s;
}).toList();
notifyListeners();
@@ -83,10 +84,10 @@ class FcsShipmentModel extends BaseModel {
}
Future<void> 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<void> 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<String,dynamic>, 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<String,dynamic>, snap.id);
var fcs = FcsShipment.fromMap(snap.data()!, snap.id);
return fcs;
} 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 = [];
}

View File

@@ -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<MyDataRow> getRows(BuildContext context) {
List<DataRow> 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: [

View File

@@ -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<MyDataRow> getRows(BuildContext context) {
List<DataRow> 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: [

View File

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

View File

@@ -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<String, dynamic>, snap.id);
Package.fromMap(snap.data() as Map<String, dynamic>, snap.id);
return package;
}
} catch (e) {

View File

@@ -56,7 +56,7 @@ class _PackageInfoState extends State<PackageInfo> {
PackageModel packageModel =
Provider.of<PackageModel>(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<PackageInfo> {
}
_changeDeliverayAddress(DeliveryAddress deliveryAddress) async {
if (deliveryAddress == null) return;
setState(() {
_isLoading = true;
});

View File

@@ -29,12 +29,16 @@ class PackageSearchDelegate extends SearchDelegate<Package> {
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,
);
}

View File

@@ -44,10 +44,10 @@ class _PackageEditorState extends State<PackageEditor> {
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<PackageModel>(context, listen: false);

View File

@@ -42,8 +42,8 @@ class _ProcessingEditEditorState extends State<ProcessingEditEditor> {
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 ?? "",

View File

@@ -39,7 +39,8 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
initPackage(widget.package!);
}
initPackage(Package package) {
initPackage(Package? package) {
if (package == null) return;
setState(() {
_package = package;
multiImgController.setImageUrls = package.photoUrls;
@@ -223,7 +224,7 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
PackageModel packageModel =
Provider.of<PackageModel>(context, listen: false);
Package? p = await packageModel.getPackage(_package!.id!);
initPackage(p!);
initPackage(p);
}
}
}

View File

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

View File

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

View File

@@ -40,7 +40,8 @@ class _ReceivingInfoState extends State<ReceivingInfo> {
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<ReceivingInfo> {
PackageModel packageModel =
Provider.of<PackageModel>(context, listen: false);
var pkg = await packageModel.getPackage(widget.package!.id!);
initPackage(pkg!);
initPackage(pkg);
}
_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_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<ShipmentBoxEditor> {
_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<ShipmentBoxEditor> {
);
}
List<MyDataRow> getCargoRows(BuildContext context) {
List<DataRow> 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<CargoType>(
context,
CupertinoPageRoute(
@@ -230,11 +230,11 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
_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<ShipmentBoxEditor> {
);
}).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<ShipmentBoxEditor> {
fontWeight: FontWeight.bold,
),
)),
MyDataCell(
DataCell(
Padding(
padding: const EdgeInsets.only(right: 48.0),
child: Align(

View File

@@ -70,10 +70,11 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
_fromTimeEditingController.text = "${timeFormatter.format(now)}";
_toTimeEditingController.text = "${timeFormatter.format(now)}";
// _shipment = Shipment(boxes: []);
var shipmentModel =
Provider.of<DeliveryAddressModel>(context, listen: false);
_shipment!.pickupAddress = shipmentModel.defalutAddress;
_shipment!.boxes = [];
Shipment _s = Shipment(
pickupAddress: context.read<DeliveryAddressModel>().defalutAddress,
boxes: []);
_shipment = _s;
_pickupDate.text = dateFormatter.format(now);
}
}
@@ -87,12 +88,12 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
Widget build(BuildContext context) {
MainModel mainModel = Provider.of<MainModel>(context);
ShipmentModel pickupModel = Provider.of<ShipmentModel>(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<DeliveryAddressModel>(context);
final fromTimeBox = InputTime(
labelTextKey: 'shipment.from',
iconData: Icons.timer,
@@ -122,7 +123,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
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<ShipmentEditor> {
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<ShipmentEditor> {
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<ShipmentEditor> {
}
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: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 ?? "")),
),
],
);

View File

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

View File

@@ -29,12 +29,16 @@ class UserSearchDelegate extends SearchDelegate<User> {
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,
);
}

View File

@@ -61,10 +61,10 @@ class _DeliveryAddressSelectionState extends State<DeliveryAddressSelection> {
),
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<DeliveryAddressSelection> {
}
_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();
}
}

View File

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

View File

@@ -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: