update processing
This commit is contained in:
@@ -291,6 +291,7 @@
|
|||||||
"box.carton_size.title":"Carton Sizes",
|
"box.carton_size.title":"Carton Sizes",
|
||||||
"box.carton_size_remove.confirm":"Remove this carton size?",
|
"box.carton_size_remove.confirm":"Remove this carton size?",
|
||||||
"box.carton_size.name":"Name",
|
"box.carton_size.name":"Name",
|
||||||
|
"box.cargo_total_title":"Edit Total Weight",
|
||||||
"Boxes End ================================================================":"",
|
"Boxes End ================================================================":"",
|
||||||
|
|
||||||
"Delivery Start ================================================================":"",
|
"Delivery Start ================================================================":"",
|
||||||
|
|||||||
@@ -291,6 +291,7 @@
|
|||||||
"box.carton_size.title":"သေတ္တာ အရွယ်အစားများ",
|
"box.carton_size.title":"သေတ္တာ အရွယ်အစားများ",
|
||||||
"box.carton_size_remove.confirm":"Remove this carton size?",
|
"box.carton_size_remove.confirm":"Remove this carton size?",
|
||||||
"box.carton_size.name":"နာမည်",
|
"box.carton_size.name":"နာမည်",
|
||||||
|
"box.cargo_total_title":"စုစုပေါင်းအလေးချိန် ပြုပြင်မည်",
|
||||||
"Boxes End ================================================================":"",
|
"Boxes End ================================================================":"",
|
||||||
|
|
||||||
"Delivery Start ================================================================":"",
|
"Delivery Start ================================================================":"",
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ class CargoType {
|
|||||||
String name;
|
String name;
|
||||||
double rate;
|
double rate;
|
||||||
double weight;
|
double weight;
|
||||||
|
bool isChecked;
|
||||||
|
|
||||||
double get calAmount => (calRate ?? 0) * (calWeight ?? 0);
|
double get calAmount => (calRate ?? 0) * (calWeight ?? 0);
|
||||||
|
|
||||||
@@ -19,13 +20,15 @@ class CargoType {
|
|||||||
calRate: map['cal_rate']?.toDouble() ?? 0,
|
calRate: map['cal_rate']?.toDouble() ?? 0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
CargoType(
|
CargoType({
|
||||||
{this.id,
|
this.id,
|
||||||
this.name,
|
this.name,
|
||||||
this.rate,
|
this.rate,
|
||||||
this.weight,
|
this.weight,
|
||||||
this.calWeight,
|
this.calWeight,
|
||||||
this.calRate});
|
this.calRate,
|
||||||
|
this.isChecked = false,
|
||||||
|
});
|
||||||
|
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
import 'package:fcs/domain/vo/shipment_status.dart';
|
import 'package:fcs/domain/vo/shipment_status.dart';
|
||||||
@@ -36,14 +38,17 @@ class Package {
|
|||||||
DateTime arrivedDate;
|
DateTime arrivedDate;
|
||||||
DeliveryAddress deliveryAddress;
|
DeliveryAddress deliveryAddress;
|
||||||
|
|
||||||
|
//for packages in processing
|
||||||
|
List<File> photoFiles;
|
||||||
|
|
||||||
int get amount => rate != null && weight != null ? rate * weight : 0;
|
int get amount => rate != null && weight != null ? rate * weight : 0;
|
||||||
|
|
||||||
String get packageNumber =>
|
String get packageNumber =>
|
||||||
shipmentNumber + "-" + receiverNumber + " #" + boxNumber;
|
shipmentNumber + "-" + receiverNumber + " #" + boxNumber;
|
||||||
double get price => rate.toDouble() * weight;
|
double get price => rate.toDouble() * weight;
|
||||||
|
|
||||||
Package(
|
Package({
|
||||||
{this.id,
|
this.id,
|
||||||
this.trackingID,
|
this.trackingID,
|
||||||
this.userID,
|
this.userID,
|
||||||
this.userName,
|
this.userName,
|
||||||
@@ -71,7 +76,9 @@ class Package {
|
|||||||
this.photoUrls,
|
this.photoUrls,
|
||||||
this.desc,
|
this.desc,
|
||||||
this.deliveryAddress,
|
this.deliveryAddress,
|
||||||
this.isChecked = false});
|
this.isChecked = false,
|
||||||
|
this.photoFiles,
|
||||||
|
});
|
||||||
|
|
||||||
factory Package.fromMap(Map<String, dynamic> map, String docID) {
|
factory Package.fromMap(Map<String, dynamic> map, String docID) {
|
||||||
var _currentStatusDate = (map['status_date'] as Timestamp);
|
var _currentStatusDate = (map['status_date'] as Timestamp);
|
||||||
|
|||||||
116
lib/pages/carton/cargo_type_addtion.dart
Normal file
116
lib/pages/carton/cargo_type_addtion.dart
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||||
|
import 'package:fcs/helpers/theme.dart';
|
||||||
|
import 'package:fcs/pages/main/util.dart';
|
||||||
|
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||||
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class CargoTypeAddition extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_CargoTypeAdditionState createState() => _CargoTypeAdditionState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CargoTypeAdditionState extends State<CargoTypeAddition> {
|
||||||
|
bool _isLoading = false;
|
||||||
|
|
||||||
|
List<CargoType> cargos = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
cargos =
|
||||||
|
Provider.of<ShipmentRateModel>(context, listen: false).rate.cargoTypes;
|
||||||
|
cargos.forEach((p) => p.isChecked = false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> showcargoTypeList(BuildContext context) {
|
||||||
|
return this.cargos.map((c) {
|
||||||
|
return new ListTile(
|
||||||
|
contentPadding: EdgeInsets.all(0),
|
||||||
|
title: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
c.isChecked = c.isChecked == null ? true : !c.isChecked;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: new Row(
|
||||||
|
children: <Widget>[
|
||||||
|
new Checkbox(
|
||||||
|
value: c.isChecked == null ? false : c.isChecked,
|
||||||
|
activeColor: primaryColor,
|
||||||
|
onChanged: (bool value) {
|
||||||
|
setState(() {
|
||||||
|
c.isChecked = value;
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
new Text(
|
||||||
|
c.name,
|
||||||
|
style: TextStyle(fontSize: 15.0, color: primaryColor),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final saveBtn = fcsButton(
|
||||||
|
context,
|
||||||
|
getLocalString(context, 'box.cargo.save.btn'),
|
||||||
|
callack: () {
|
||||||
|
this.cargos.forEach((p) => p.weight = 0.00);
|
||||||
|
List<CargoType> _cargos =
|
||||||
|
this.cargos.where((c) => c.isChecked).toList();
|
||||||
|
Navigator.pop(context, _cargos);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return LocalProgress(
|
||||||
|
inAsyncCall: _isLoading,
|
||||||
|
child: Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
centerTitle: true,
|
||||||
|
leading: new IconButton(
|
||||||
|
icon:
|
||||||
|
new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
),
|
||||||
|
shadowColor: Colors.transparent,
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
title: LocalText(
|
||||||
|
context,
|
||||||
|
"cargo.form.title",
|
||||||
|
fontSize: 20,
|
||||||
|
color: primaryColor,
|
||||||
|
)),
|
||||||
|
body: Container(
|
||||||
|
padding: EdgeInsets.all(18),
|
||||||
|
child: ListView(
|
||||||
|
shrinkWrap: true,
|
||||||
|
children: <Widget>[
|
||||||
|
Column(
|
||||||
|
children: showcargoTypeList(context),
|
||||||
|
),
|
||||||
|
SizedBox(height: 30),
|
||||||
|
saveBtn,
|
||||||
|
SizedBox(height: 20),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// List<CargoType> cargoTypeList() {
|
||||||
|
// return this.privileges.where((p) => p.isChecked).map((p) => p.id).toList();
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -31,7 +31,7 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
if (widget.cargo != null) {
|
if (widget.cargo != null) {
|
||||||
_cargo = widget.cargo;
|
_cargo = widget.cargo;
|
||||||
_weightController.text = _cargo.weight.toString();
|
_weightController.text = _cargo.weight.toStringAsFixed(2);
|
||||||
} else {
|
} else {
|
||||||
_loadDefalut();
|
_loadDefalut();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,12 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'cargo_type_editor.dart';
|
import 'cargo_type_editor.dart';
|
||||||
|
import 'total_weight_edit.dart';
|
||||||
|
|
||||||
typedef OnAdd(CargoType cargoType);
|
typedef OnAdd(CargoType cargoType);
|
||||||
typedef OnRemove(CargoType cargoType);
|
typedef OnRemove(CargoType cargoType);
|
||||||
|
|
||||||
class CargoTable extends StatelessWidget {
|
class CargoTable extends StatefulWidget {
|
||||||
final List<CargoType> cargoTypes;
|
final List<CargoType> cargoTypes;
|
||||||
final OnAdd onAdd;
|
final OnAdd onAdd;
|
||||||
final OnRemove onRemove;
|
final OnRemove onRemove;
|
||||||
@@ -18,6 +19,12 @@ class CargoTable extends StatelessWidget {
|
|||||||
const CargoTable({Key key, this.cargoTypes, this.onAdd, this.onRemove})
|
const CargoTable({Key key, this.cargoTypes, this.onAdd, this.onRemove})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_CargoTableState createState() => _CargoTableState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CargoTableState extends State<CargoTable> {
|
||||||
|
double totalWeight = 0;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MyDataTable(
|
return MyDataTable(
|
||||||
@@ -43,12 +50,14 @@ class CargoTable extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<MyDataRow> getCargoRows(BuildContext context) {
|
List<MyDataRow> getCargoRows(BuildContext context) {
|
||||||
if (cargoTypes == null) {
|
if (widget.cargoTypes == null) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
double total = 0;
|
|
||||||
var rows = cargoTypes.map((c) {
|
double _total = 0;
|
||||||
total += c.weight;
|
var rows = widget.cargoTypes.map((c) {
|
||||||
|
_total += c.weight;
|
||||||
|
|
||||||
return MyDataRow(
|
return MyDataRow(
|
||||||
onSelectChanged: (bool selected) async {
|
onSelectChanged: (bool selected) async {
|
||||||
CargoType cargo = await Navigator.push<CargoType>(
|
CargoType cargo = await Navigator.push<CargoType>(
|
||||||
@@ -57,7 +66,7 @@ class CargoTable extends StatelessWidget {
|
|||||||
builder: (context) => CargoTypeEditor(
|
builder: (context) => CargoTypeEditor(
|
||||||
cargo: c,
|
cargo: c,
|
||||||
)));
|
)));
|
||||||
if (onAdd != null) onAdd(cargo);
|
if (widget.onAdd != null) widget.onAdd(cargo);
|
||||||
},
|
},
|
||||||
cells: [
|
cells: [
|
||||||
MyDataCell(new Text(
|
MyDataCell(new Text(
|
||||||
@@ -68,9 +77,8 @@ class CargoTable extends StatelessWidget {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
Text(c.weight == null ? "0" : c.weight.toString(),
|
Text(c.weight.toStringAsFixed(2), style: textStyle),
|
||||||
style: textStyle),
|
widget.onRemove == null
|
||||||
onRemove == null
|
|
||||||
? SizedBox(
|
? SizedBox(
|
||||||
width: 50,
|
width: 50,
|
||||||
)
|
)
|
||||||
@@ -80,7 +88,93 @@ class CargoTable extends StatelessWidget {
|
|||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (onRemove != null) onRemove(c);
|
if (widget.onRemove != null) widget.onRemove(c);
|
||||||
|
})
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
var totalRow = MyDataRow(
|
||||||
|
onSelectChanged: (bool selected) async {
|
||||||
|
double _t = await Navigator.of(context).push<double>(CupertinoPageRoute(
|
||||||
|
builder: (context) => TotalWeightEdit(totalWeight: totalWeight)));
|
||||||
|
if (_t == null) return;
|
||||||
|
setState(() {
|
||||||
|
totalWeight = _t;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
cells: [
|
||||||
|
MyDataCell(Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: LocalText(
|
||||||
|
context,
|
||||||
|
"shipment.cargo.total",
|
||||||
|
color: Colors.black87,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
MyDataCell(
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 48.0),
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: Text(totalWeight.toStringAsFixed(2),
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold))),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
rows.add(totalRow);
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
double getRemainBalance(double total) {
|
||||||
|
double _r = this.totalWeight < total ? 0 : this.totalWeight - total;
|
||||||
|
return _r;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<MyDataRow> _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 {
|
||||||
|
CargoType cargo = await Navigator.push<CargoType>(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (context) => CargoTypeEditor(
|
||||||
|
cargo: c,
|
||||||
|
)));
|
||||||
|
if (widget.onAdd != null) widget.onAdd(cargo);
|
||||||
|
},
|
||||||
|
cells: [
|
||||||
|
MyDataCell(new Text(
|
||||||
|
c.name == null ? "" : c.name,
|
||||||
|
style: textStyle,
|
||||||
|
)),
|
||||||
|
MyDataCell(
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Text(c.weight == null ? "0" : c.weight.toStringAsFixed(2),
|
||||||
|
style: textStyle),
|
||||||
|
widget.onRemove == null
|
||||||
|
? SizedBox(
|
||||||
|
width: 50,
|
||||||
|
)
|
||||||
|
: IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
Icons.remove_circle,
|
||||||
|
color: primaryColor,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
if (widget.onRemove != null) widget.onRemove(c);
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -106,7 +200,7 @@ class CargoTable extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.only(right: 48.0),
|
padding: const EdgeInsets.only(right: 48.0),
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
child: Text(total.toString(),
|
child: Text(total.toStringAsFixed(2),
|
||||||
style: TextStyle(fontWeight: FontWeight.bold))),
|
style: TextStyle(fontWeight: FontWeight.bold))),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -3,31 +3,21 @@ import 'package:fcs/domain/entities/carton.dart';
|
|||||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||||
import 'package:fcs/domain/entities/carton_size.dart';
|
import 'package:fcs/domain/entities/carton_size.dart';
|
||||||
import 'package:fcs/domain/entities/fcs_shipment.dart';
|
import 'package:fcs/domain/entities/fcs_shipment.dart';
|
||||||
import 'package:fcs/domain/entities/market.dart';
|
|
||||||
import 'package:fcs/domain/entities/package.dart';
|
import 'package:fcs/domain/entities/package.dart';
|
||||||
import 'package:fcs/domain/entities/user.dart';
|
import 'package:fcs/domain/entities/user.dart';
|
||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/localization/app_translations.dart';
|
|
||||||
import 'package:fcs/pages/carton/carton_cargo_table.dart';
|
import 'package:fcs/pages/carton/carton_cargo_table.dart';
|
||||||
import 'package:fcs/pages/carton/carton_mix_table.dart';
|
|
||||||
import 'package:fcs/pages/carton/carton_package_table.dart';
|
import 'package:fcs/pages/carton/carton_package_table.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/delivery_address_list.dart';
|
import 'package:fcs/pages/delivery_address/delivery_address_list.dart';
|
||||||
import 'package:fcs/pages/delivery_address/delivery_address_row.dart';
|
import 'package:fcs/pages/delivery_address/delivery_address_row.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/model/language_model.dart';
|
|
||||||
import 'package:fcs/pages/main/model/main_model.dart';
|
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:fcs/pages/market/model/market_model.dart';
|
|
||||||
import 'package:fcs/pages/package/model/package_model.dart';
|
import 'package:fcs/pages/package/model/package_model.dart';
|
||||||
import 'package:fcs/pages/package/tracking_id_page.dart';
|
|
||||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||||
import 'package:fcs/pages/user_search/user_serach.dart';
|
import 'package:fcs/pages/user_search/user_serach.dart';
|
||||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
|
||||||
import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
|
import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
|
||||||
import 'package:fcs/pages/widgets/delivery_address_selection.dart';
|
|
||||||
import 'package:fcs/pages/widgets/display_text.dart';
|
import 'package:fcs/pages/widgets/display_text.dart';
|
||||||
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
||||||
import 'package:fcs/pages/widgets/length_picker.dart';
|
import 'package:fcs/pages/widgets/length_picker.dart';
|
||||||
@@ -36,19 +26,17 @@ import 'package:fcs/pages/widgets/local_dropdown.dart';
|
|||||||
import 'package:fcs/pages/widgets/local_radio_buttons.dart';
|
import 'package:fcs/pages/widgets/local_radio_buttons.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';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_icons/flutter_icons.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
import 'cargo_type_addtion.dart';
|
||||||
import 'cargo_type_editor.dart';
|
import 'cargo_type_editor.dart';
|
||||||
import 'model/carton_model.dart';
|
import 'model/carton_model.dart';
|
||||||
import '../carton_size/model/carton_size_model.dart';
|
import '../carton_size/model/carton_size_model.dart';
|
||||||
import 'widgets.dart';
|
import 'widgets.dart';
|
||||||
|
|
||||||
const MANAGE_CARTONSIZE = "Manage Carton Size";
|
|
||||||
|
|
||||||
class CartonEditor extends StatefulWidget {
|
class CartonEditor extends StatefulWidget {
|
||||||
final Carton box;
|
final Carton box;
|
||||||
CartonEditor({this.box});
|
CartonEditor({this.box});
|
||||||
@@ -102,9 +90,9 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
cargoTypes: [],
|
cargoTypes: [],
|
||||||
packages: [],
|
packages: [],
|
||||||
);
|
);
|
||||||
_lengthController.text = "12";
|
_lengthController.text = "";
|
||||||
_widthController.text = "12";
|
_widthController.text = "";
|
||||||
_heightController.text = "12";
|
_heightController.text = "";
|
||||||
_isNew = true;
|
_isNew = true;
|
||||||
_selectedCartonType = carton_from_packages;
|
_selectedCartonType = carton_from_packages;
|
||||||
_loadFcsShipments();
|
_loadFcsShipments();
|
||||||
@@ -212,7 +200,9 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
labelTextKey: "box.mix.carton",
|
labelTextKey: "box.mix.carton",
|
||||||
iconData: MaterialCommunityIcons.package,
|
iconData: MaterialCommunityIcons.package,
|
||||||
);
|
);
|
||||||
var fcsShipmentsBox = LocalDropdown<FcsShipment>(
|
var fcsShipmentsBox = Container(
|
||||||
|
padding: EdgeInsets.only(top: 10),
|
||||||
|
child: LocalDropdown<FcsShipment>(
|
||||||
callback: (v) {
|
callback: (v) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_fcsShipment = v;
|
_fcsShipment = v;
|
||||||
@@ -224,9 +214,11 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
display: (u) => u.shipmentNumber,
|
display: (u) => u.shipmentNumber,
|
||||||
selectedValue: _fcsShipment,
|
selectedValue: _fcsShipment,
|
||||||
values: _fcsShipments,
|
values: _fcsShipments,
|
||||||
);
|
));
|
||||||
|
|
||||||
var mixCartonsBox = LocalDropdown<Carton>(
|
var mixCartonsBox = Container(
|
||||||
|
padding: EdgeInsets.only(top: 10),
|
||||||
|
child: LocalDropdown<Carton>(
|
||||||
callback: (v) {
|
callback: (v) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_mixCarton = v;
|
_mixCarton = v;
|
||||||
@@ -237,9 +229,11 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
display: (u) => u.cartonNumber,
|
display: (u) => u.cartonNumber,
|
||||||
selectedValue: _mixCarton,
|
selectedValue: _mixCarton,
|
||||||
values: _mixCartons,
|
values: _mixCartons,
|
||||||
);
|
));
|
||||||
|
|
||||||
final fcsIDBox = Row(
|
final fcsIDBox = Container(
|
||||||
|
padding: EdgeInsets.only(top: 10),
|
||||||
|
child: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DisplayText(
|
child: DisplayText(
|
||||||
@@ -250,7 +244,8 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
_isNew
|
_isNew
|
||||||
? IconButton(
|
? IconButton(
|
||||||
icon: Icon(Icons.search, color: primaryColor),
|
icon: Icon(Icons.search, color: primaryColor),
|
||||||
onPressed: () => searchUser(context, callbackUserSelect: (u) {
|
onPressed: () =>
|
||||||
|
searchUser(context, callbackUserSelect: (u) {
|
||||||
setState(() {
|
setState(() {
|
||||||
this._user = u;
|
this._user = u;
|
||||||
_loadPackages();
|
_loadPackages();
|
||||||
@@ -258,7 +253,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
}))
|
}))
|
||||||
: Container(),
|
: Container(),
|
||||||
],
|
],
|
||||||
);
|
));
|
||||||
|
|
||||||
final namebox = DisplayText(
|
final namebox = DisplayText(
|
||||||
text: _user?.name ?? "",
|
text: _user?.name ?? "",
|
||||||
@@ -269,14 +264,17 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
final lengthBox = LengthPicker(
|
final lengthBox = LengthPicker(
|
||||||
controller: _lengthController,
|
controller: _lengthController,
|
||||||
lableKey: "box.length",
|
lableKey: "box.length",
|
||||||
|
isReadOnly: true,
|
||||||
);
|
);
|
||||||
final widthBox = LengthPicker(
|
final widthBox = LengthPicker(
|
||||||
controller: _widthController,
|
controller: _widthController,
|
||||||
lableKey: "box.width",
|
lableKey: "box.width",
|
||||||
|
isReadOnly: true,
|
||||||
);
|
);
|
||||||
final heightBox = LengthPicker(
|
final heightBox = LengthPicker(
|
||||||
controller: _heightController,
|
controller: _heightController,
|
||||||
lableKey: "box.height",
|
lableKey: "box.height",
|
||||||
|
isReadOnly: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
final dimBox = Row(
|
final dimBox = Row(
|
||||||
@@ -293,7 +291,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final shipmentWeightBox = DisplayText(
|
final shipmentWeightBox = DisplayText(
|
||||||
text: shipmentWeight != null ? shipmentWeight.toStringAsFixed(0) : "",
|
text: shipmentWeight != null ? shipmentWeight.toStringAsFixed(2) : "",
|
||||||
labelTextKey: "box.shipment_weight",
|
labelTextKey: "box.shipment_weight",
|
||||||
iconData: MaterialCommunityIcons.weight,
|
iconData: MaterialCommunityIcons.weight,
|
||||||
);
|
);
|
||||||
@@ -326,9 +324,17 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
CargoType cargo = await Navigator.push<CargoType>(context,
|
// CargoType cargo = await Navigator.push<CargoType>(context,
|
||||||
CupertinoPageRoute(builder: (context) => CargoTypeEditor()));
|
// CupertinoPageRoute(builder: (context) => CargoTypeEditor()));
|
||||||
_addCargo(cargo);
|
// _addCargo(cargo);
|
||||||
|
List<CargoType> cargos = await Navigator.push<List<CargoType>>(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(builder: (context) => CargoTypeAddition()));
|
||||||
|
if (cargos == null) return;
|
||||||
|
setState(() {
|
||||||
|
_carton.cargoTypes.clear();
|
||||||
|
_carton.cargoTypes.addAll(cargos);
|
||||||
|
});
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -414,7 +420,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
? Container()
|
? Container()
|
||||||
: LocalTitle(textKey: "box.dimension"),
|
: LocalTitle(textKey: "box.dimension"),
|
||||||
isSmallBag ? Container() : cartonSizeDropdown(),
|
isSmallBag ? Container() : cartonSizeDropdown(),
|
||||||
// isSmallBag ? Container() : dimBox,
|
isSmallBag ? Container() : dimBox,
|
||||||
isSmallBag ? Container() : shipmentWeightBox,
|
isSmallBag ? Container() : shipmentWeightBox,
|
||||||
LocalTitle(textKey: "box.delivery_address"),
|
LocalTitle(textKey: "box.delivery_address"),
|
||||||
DefaultDeliveryAddress(
|
DefaultDeliveryAddress(
|
||||||
@@ -445,16 +451,13 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
String selectedCatonSize;
|
CartonSize selectedCatonSize;
|
||||||
Widget cartonSizeDropdown() {
|
Widget cartonSizeDropdown() {
|
||||||
List<CartonSize> _cartonSizes =
|
List<CartonSize> _cartonSizes =
|
||||||
Provider.of<CartonSizeModel>(context).cartonSizes;
|
Provider.of<CartonSizeModel>(context).getCartonSizes;
|
||||||
|
|
||||||
List<String> cartonSizes = _cartonSizes.map((e) => e.name).toList();
|
|
||||||
cartonSizes.insert(0, MANAGE_CARTONSIZE);
|
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(top: 10, bottom: 10),
|
padding: const EdgeInsets.only(top: 10),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
@@ -474,7 +477,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
DropdownButton<String>(
|
DropdownButton<CartonSize>(
|
||||||
isDense: true,
|
isDense: true,
|
||||||
value: selectedCatonSize,
|
value: selectedCatonSize,
|
||||||
style: TextStyle(color: Colors.black, fontSize: 14),
|
style: TextStyle(color: Colors.black, fontSize: 14),
|
||||||
@@ -482,25 +485,31 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
height: 1,
|
height: 1,
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
),
|
),
|
||||||
onChanged: (String newValue) {
|
onChanged: (CartonSize newValue) {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (newValue == MANAGE_CARTONSIZE) {
|
if (newValue.name == MANAGE_CARTONSIZE) {
|
||||||
selectedCatonSize = null;
|
selectedCatonSize = null;
|
||||||
_manageCartonSize();
|
_manageCartonSize();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
selectedCatonSize = newValue;
|
selectedCatonSize = newValue;
|
||||||
|
_widthController.text =
|
||||||
|
selectedCatonSize.width.toString();
|
||||||
|
_heightController.text =
|
||||||
|
selectedCatonSize.height.toString();
|
||||||
|
_lengthController.text =
|
||||||
|
selectedCatonSize.length.toString();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
items:
|
items: _cartonSizes
|
||||||
cartonSizes.map<DropdownMenuItem<String>>((String value) {
|
.map<DropdownMenuItem<CartonSize>>((CartonSize value) {
|
||||||
return DropdownMenuItem<String>(
|
return DropdownMenuItem<CartonSize>(
|
||||||
value: value,
|
value: value,
|
||||||
child: Text(value ?? "",
|
child: Text(value.name ?? "",
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: value == MANAGE_CARTONSIZE
|
color: value.name == MANAGE_CARTONSIZE
|
||||||
? secondaryColor
|
? secondaryColor
|
||||||
: primaryColor)),
|
: primaryColor)),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final shipmentWeightBox = DisplayText(
|
final shipmentWeightBox = DisplayText(
|
||||||
text: shipmentWeight != null ? shipmentWeight.toStringAsFixed(0) : "",
|
text: shipmentWeight != null ? shipmentWeight.toStringAsFixed(2) : "",
|
||||||
labelTextKey: "box.shipment_weight",
|
labelTextKey: "box.shipment_weight",
|
||||||
iconData: MaterialCommunityIcons.weight,
|
iconData: MaterialCommunityIcons.weight,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class CartonListRow extends StatelessWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new Text(
|
new Text(
|
||||||
"${box.actualWeight?.toString() ?? ''} lb",
|
"${box.actualWeight?.toStringAsFixed(2) ?? ''} lb",
|
||||||
style:
|
style:
|
||||||
new TextStyle(fontSize: 15.0, color: Colors.grey),
|
new TextStyle(fontSize: 15.0, color: Colors.grey),
|
||||||
),
|
),
|
||||||
|
|||||||
86
lib/pages/carton/total_weight_edit.dart
Normal file
86
lib/pages/carton/total_weight_edit.dart
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
import 'package:fcs/helpers/theme.dart';
|
||||||
|
import 'package:fcs/pages/widgets/input_text.dart';
|
||||||
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
import 'package:fcs/pages/main/util.dart';
|
||||||
|
|
||||||
|
typedef void ProfileCallback();
|
||||||
|
|
||||||
|
class TotalWeightEdit extends StatefulWidget {
|
||||||
|
final double totalWeight;
|
||||||
|
|
||||||
|
const TotalWeightEdit({Key key, this.totalWeight}) : super(key: key);
|
||||||
|
@override
|
||||||
|
_TotalWeightEditState createState() => _TotalWeightEditState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _TotalWeightEditState extends State<TotalWeightEdit> {
|
||||||
|
final TextEditingController totalController = new TextEditingController();
|
||||||
|
bool _loading = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
totalController.text = widget.totalWeight.toStringAsFixed(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final totalInputBox = InputText(
|
||||||
|
labelTextKey: 'shipment.cargo.total',
|
||||||
|
iconData: FontAwesomeIcons.weightHanging,
|
||||||
|
textInputType: TextInputType.number,
|
||||||
|
controller: totalController);
|
||||||
|
|
||||||
|
final saveBtn =
|
||||||
|
fcsButton(context, getLocalString(context, "btn.save"), callack: _save);
|
||||||
|
|
||||||
|
return LocalProgress(
|
||||||
|
inAsyncCall: _loading,
|
||||||
|
child: Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
centerTitle: true,
|
||||||
|
title: LocalText(
|
||||||
|
context,
|
||||||
|
"box.cargo_total_title",
|
||||||
|
fontSize: 20,
|
||||||
|
color: primaryColor,
|
||||||
|
),
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
shadowColor: Colors.transparent,
|
||||||
|
leading: IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
CupertinoIcons.back,
|
||||||
|
size: 35,
|
||||||
|
color: primaryColor,
|
||||||
|
),
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: ListView(
|
||||||
|
padding: EdgeInsets.all(18),
|
||||||
|
children: <Widget>[totalInputBox, SizedBox(height: 30), saveBtn],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_save() async {
|
||||||
|
setState(() {
|
||||||
|
_loading = true;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
double total = double.parse(totalController.text, (s) => 0);
|
||||||
|
Navigator.pop<double>(context, total);
|
||||||
|
} catch (e) {
|
||||||
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
} finally {
|
||||||
|
setState(() {
|
||||||
|
_loading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,12 +31,14 @@ class _CartonSizeEditorState extends State<CartonSizeEditor> {
|
|||||||
|
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
CartonSize _cartonSize;
|
CartonSize _cartonSize;
|
||||||
|
bool _isNew;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
if (widget.cartonSize != null) {
|
if (widget.cartonSize != null) {
|
||||||
_cartonSize = widget.cartonSize;
|
_cartonSize = widget.cartonSize;
|
||||||
|
_isNew = false;
|
||||||
_nameController.text = _cartonSize.name;
|
_nameController.text = _cartonSize.name;
|
||||||
_widthController.text = _cartonSize.width.toString();
|
_widthController.text = _cartonSize.width.toString();
|
||||||
_heightController.text = _cartonSize.height.toString();
|
_heightController.text = _cartonSize.height.toString();
|
||||||
@@ -45,6 +47,7 @@ class _CartonSizeEditorState extends State<CartonSizeEditor> {
|
|||||||
_lengthController.text = "12";
|
_lengthController.text = "12";
|
||||||
_widthController.text = "12";
|
_widthController.text = "12";
|
||||||
_heightController.text = "12";
|
_heightController.text = "12";
|
||||||
|
_isNew = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,9 +107,20 @@ class _CartonSizeEditorState extends State<CartonSizeEditor> {
|
|||||||
double w = double.parse(_widthController.text, (s) => 0);
|
double w = double.parse(_widthController.text, (s) => 0);
|
||||||
double h = double.parse(_heightController.text, (s) => 0);
|
double h = double.parse(_heightController.text, (s) => 0);
|
||||||
|
|
||||||
|
if (_isNew) {
|
||||||
CartonSize _cartonSize = CartonSize(
|
CartonSize _cartonSize = CartonSize(
|
||||||
name: _nameController.text, length: l, width: w, height: h);
|
name: _nameController.text, length: l, width: w, height: h);
|
||||||
await cartonSizeModel.addCartonSize(_cartonSize);
|
await cartonSizeModel.addCartonSize(_cartonSize);
|
||||||
|
} else {
|
||||||
|
CartonSize _cartonSize = CartonSize(
|
||||||
|
id: widget.cartonSize.id,
|
||||||
|
name: _nameController.text,
|
||||||
|
length: l,
|
||||||
|
width: w,
|
||||||
|
height: h);
|
||||||
|
await cartonSizeModel.updateCartonSize(_cartonSize);
|
||||||
|
}
|
||||||
|
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ class _CartonSizeListState extends State<CartonSizeList> {
|
|||||||
BuildContext context, List<CartonSize> cartonSizes) {
|
BuildContext context, List<CartonSize> cartonSizes) {
|
||||||
return cartonSizes.map((p) {
|
return cartonSizes.map((p) {
|
||||||
return new ListTile(
|
return new ListTile(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).push<void>(CupertinoPageRoute(
|
||||||
|
builder: (context) => CartonSizeEditor(cartonSize: p)));
|
||||||
|
},
|
||||||
title: new Row(
|
title: new Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
|
|||||||
@@ -5,12 +5,19 @@ import 'package:fcs/domain/entities/carton_size.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';
|
||||||
|
|
||||||
|
const MANAGE_CARTONSIZE = "Manage Carton Size";
|
||||||
|
|
||||||
class CartonSizeModel extends BaseModel {
|
class CartonSizeModel extends BaseModel {
|
||||||
List<CartonSize> cartonSizes = [];
|
List<CartonSize> cartonSizes = [];
|
||||||
final log = Logger('CartonSizeModel');
|
final log = Logger('CartonSizeModel');
|
||||||
|
|
||||||
StreamSubscription<QuerySnapshot> listener;
|
StreamSubscription<QuerySnapshot> listener;
|
||||||
|
|
||||||
|
List<CartonSize> get getCartonSizes {
|
||||||
|
var _cartonSizes = new List<CartonSize>.from(cartonSizes);
|
||||||
|
return _cartonSizes..insert(0, CartonSize(name: MANAGE_CARTONSIZE));
|
||||||
|
}
|
||||||
|
|
||||||
void initUser(user) {
|
void initUser(user) {
|
||||||
super.initUser(user);
|
super.initUser(user);
|
||||||
cartonSizes = [
|
cartonSizes = [
|
||||||
@@ -32,5 +39,7 @@ class CartonSizeModel extends BaseModel {
|
|||||||
|
|
||||||
Future<void> addCartonSize(CartonSize cartonSize) async {}
|
Future<void> addCartonSize(CartonSize cartonSize) async {}
|
||||||
|
|
||||||
|
Future<void> updateCartonSize(CartonSize cartonSize) async {}
|
||||||
|
|
||||||
Future<void> deleteCartonSize(String id) async {}
|
Future<void> deleteCartonSize(String id) async {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,14 +24,7 @@ class ProcessingModel extends BaseModel {
|
|||||||
processings = [];
|
processings = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> createProcessing(Processing carton) {}
|
Future<void> createProcessing(Processing processing) {}
|
||||||
|
|
||||||
Future<void> updateProcessing(Processing carton) {}
|
Future<void> updateProcessing(Processing processing) {}
|
||||||
|
|
||||||
Future<void> createPackage(Package package, List<File> files) {}
|
|
||||||
|
|
||||||
Future<void> updatePackage(
|
|
||||||
Package package, List<File> files, List<String> deletedUrls) {}
|
|
||||||
|
|
||||||
Future<void> deletePackage(String id) {}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import 'package:fcs/domain/entities/package.dart';
|
|||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/market/market_editor.dart';
|
import 'package:fcs/pages/market/market_editor.dart';
|
||||||
import 'package:fcs/pages/market/model/market_model.dart';
|
import 'package:fcs/pages/market/model/market_model.dart';
|
||||||
import 'package:fcs/pages/package/model/package_model.dart';
|
|
||||||
import 'package:fcs/pages/package/tracking_id_page.dart';
|
import 'package:fcs/pages/package/tracking_id_page.dart';
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:fcs/pages/widgets/barcode_scanner.dart';
|
import 'package:fcs/pages/widgets/barcode_scanner.dart';
|
||||||
@@ -18,8 +17,6 @@ import 'package:flutter_icons/flutter_icons.dart';
|
|||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import 'model/processing_model.dart';
|
|
||||||
|
|
||||||
class PackageEditor extends StatefulWidget {
|
class PackageEditor extends StatefulWidget {
|
||||||
final Package package;
|
final Package package;
|
||||||
PackageEditor({this.package});
|
PackageEditor({this.package});
|
||||||
@@ -36,7 +33,7 @@ class _PackageEditorState extends State<PackageEditor> {
|
|||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
bool _isNew;
|
bool _isNew;
|
||||||
MultiImgController multiImgController = MultiImgController();
|
MultiImgController multiImgController = MultiImgController();
|
||||||
Package _package;
|
Package _package = Package();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -45,10 +42,11 @@ class _PackageEditorState extends State<PackageEditor> {
|
|||||||
_isNew = false;
|
_isNew = false;
|
||||||
_package = widget.package;
|
_package = widget.package;
|
||||||
_trackingIDCtl.text = _package.trackingID;
|
_trackingIDCtl.text = _package.trackingID;
|
||||||
multiImgController.setImageUrls = _package.photoUrls;
|
|
||||||
selectedMarket = _package.market ?? "";
|
selectedMarket = _package.market ?? "";
|
||||||
_descCtl.text = _package.desc;
|
_descCtl.text = _package.desc;
|
||||||
_remarkCtl.text = _package.remark;
|
_remarkCtl.text = _package.remark;
|
||||||
|
multiImgController.setImageFiles = _package.photoFiles;
|
||||||
} else {
|
} else {
|
||||||
_isNew = true;
|
_isNew = true;
|
||||||
}
|
}
|
||||||
@@ -259,26 +257,20 @@ class _PackageEditorState extends State<PackageEditor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_selectPackage() async {
|
_selectPackage() async {
|
||||||
Package package = Package();
|
|
||||||
package.id = _package.id;
|
|
||||||
package.trackingID = _package.trackingID;
|
|
||||||
package.market = selectedMarket;
|
|
||||||
package.desc = _descCtl.text;
|
|
||||||
package.remark = _remarkCtl.text;
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
});
|
});
|
||||||
ProcessingModel processingModel =
|
|
||||||
Provider.of<ProcessingModel>(context, listen: false);
|
|
||||||
try {
|
try {
|
||||||
if (_isNew) {
|
this._package.trackingID = _trackingIDCtl.text;
|
||||||
await processingModel.createPackage(
|
this._package.market = selectedMarket;
|
||||||
package, multiImgController.getAddedFile);
|
this._package.desc = _descCtl.text;
|
||||||
} else {
|
this._package.remark = _remarkCtl.text;
|
||||||
await processingModel.updatePackage(package,
|
this._package.photoFiles = _isNew
|
||||||
multiImgController.getAddedFile, multiImgController.getDeletedUrl);
|
? multiImgController.getAddedFile
|
||||||
}
|
: multiImgController.getUpdatedFile;
|
||||||
Navigator.pop(context, true);
|
|
||||||
|
Navigator.pop<Package>(context, this._package);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import 'package:fcs/pages/package/model/package_model.dart';
|
|||||||
import 'package:fcs/pages/package/tracking_id_page.dart';
|
import 'package:fcs/pages/package/tracking_id_page.dart';
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:fcs/pages/user_search/user_serach.dart';
|
import 'package:fcs/pages/user_search/user_serach.dart';
|
||||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
|
||||||
import 'package:fcs/pages/widgets/display_text.dart';
|
import 'package:fcs/pages/widgets/display_text.dart';
|
||||||
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
||||||
import 'package:fcs/pages/widgets/input_text.dart';
|
import 'package:fcs/pages/widgets/input_text.dart';
|
||||||
@@ -22,15 +21,15 @@ import 'package:flutter_icons/flutter_icons.dart';
|
|||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class ProcessingEditor extends StatefulWidget {
|
class ProcessingEditEditor extends StatefulWidget {
|
||||||
final Package package;
|
final Package package;
|
||||||
ProcessingEditor({this.package});
|
ProcessingEditEditor({this.package});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_ProcessingEditorState createState() => _ProcessingEditorState();
|
_ProcessingEditEditorState createState() => _ProcessingEditEditorState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ProcessingEditorState extends State<ProcessingEditor> {
|
class _ProcessingEditEditorState extends State<ProcessingEditEditor> {
|
||||||
TextEditingController _remarkCtl = new TextEditingController();
|
TextEditingController _remarkCtl = new TextEditingController();
|
||||||
TextEditingController _descCtl = new TextEditingController();
|
TextEditingController _descCtl = new TextEditingController();
|
||||||
|
|
||||||
@@ -1,12 +1,8 @@
|
|||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:fcs/domain/entities/package.dart';
|
import 'package:fcs/domain/entities/package.dart';
|
||||||
import 'package:fcs/domain/entities/processing.dart';
|
import 'package:fcs/domain/entities/processing.dart';
|
||||||
import 'package:fcs/domain/entities/user.dart';
|
import 'package:fcs/domain/entities/user.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/carton/carton_package_table.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/user_search/user_serach.dart';
|
import 'package:fcs/pages/user_search/user_serach.dart';
|
||||||
import 'package:fcs/pages/widgets/display_text.dart';
|
import 'package:fcs/pages/widgets/display_text.dart';
|
||||||
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
||||||
@@ -50,13 +46,6 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
name: processing.shipperName,
|
name: processing.shipperName,
|
||||||
phoneNumber: processing.shipperPhoneNumber);
|
phoneNumber: processing.shipperPhoneNumber);
|
||||||
packages = processing.packages;
|
packages = processing.packages;
|
||||||
} else {
|
|
||||||
packages = [
|
|
||||||
Package(trackingID: "REC 4", market: "New Market"),
|
|
||||||
Package(trackingID: "REC 3", market: "Macy"),
|
|
||||||
Package(trackingID: "REC 2", market: "New Market"),
|
|
||||||
Package(trackingID: "REC 1", market: "New Market")
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,10 +146,12 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
Navigator.push(
|
Package _package = await Navigator.push<Package>(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(builder: (context) => PackageEditor()),
|
CupertinoPageRoute(builder: (context) => PackageEditor()),
|
||||||
);
|
);
|
||||||
|
_addPackage(_package);
|
||||||
|
// _savePackage(_package);
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -172,12 +163,6 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
callack: _save,
|
callack: _save,
|
||||||
);
|
);
|
||||||
|
|
||||||
final updateButton = fcsButton(
|
|
||||||
context,
|
|
||||||
getLocalString(context, 'processing.edit.complete.btn'),
|
|
||||||
callack: _save,
|
|
||||||
);
|
|
||||||
|
|
||||||
return LocalProgress(
|
return LocalProgress(
|
||||||
inAsyncCall: _isLoading,
|
inAsyncCall: _isLoading,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
@@ -219,7 +204,7 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
_isNew ? createButton : updateButton,
|
createButton,
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 10,
|
height: 10,
|
||||||
),
|
),
|
||||||
@@ -238,9 +223,14 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () async {
|
||||||
Navigator.of(context).push(CupertinoPageRoute(
|
Package _package = await Navigator.of(context).push<Package>(
|
||||||
|
CupertinoPageRoute(
|
||||||
builder: (context) => PackageEditor(package: p)));
|
builder: (context) => PackageEditor(package: p)));
|
||||||
|
// setState(() {
|
||||||
|
// _savePackage(_package);
|
||||||
|
// });
|
||||||
|
_savePackage(_package);
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@@ -276,7 +266,7 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.remove, color: primaryColor),
|
icon: Icon(Icons.remove, color: primaryColor),
|
||||||
onPressed: () => _remove(p),
|
onPressed: () => _removePackage(p),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -289,30 +279,22 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
_remove(Package package) {
|
_addPackage(Package package) {
|
||||||
if (package == null) {
|
if (package == null) return;
|
||||||
showMsgDialog(context, "Esrror", "Invalid package!");
|
|
||||||
return;
|
this.packages.add(package);
|
||||||
}
|
setState(() {});
|
||||||
showConfirmDialog(context, "processing.package.delete_confirm",
|
|
||||||
() => _removePackage(package));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_removePackage(Package package) async {
|
_savePackage(Package package) {
|
||||||
setState(() {
|
if (package == null) return;
|
||||||
_isLoading = true;
|
setState(() {});
|
||||||
});
|
|
||||||
ProcessingModel processingModel =
|
|
||||||
Provider.of<ProcessingModel>(context, listen: false);
|
|
||||||
try {
|
|
||||||
await processingModel.deletePackage(package.id);
|
|
||||||
} catch (e) {
|
|
||||||
showMsgDialog(context, "Error", e.toString());
|
|
||||||
} finally {
|
|
||||||
setState(() {
|
|
||||||
_isLoading = false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_removePackage(Package package) {
|
||||||
|
if (package == null) return;
|
||||||
|
this.packages.removeWhere((p) => p.trackingID == package.trackingID);
|
||||||
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
_save() async {
|
_save() async {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import 'package:flutter_icons/flutter_icons.dart';
|
|||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import 'processing_editor_old.dart';
|
import 'processing_edit_editor.dart';
|
||||||
|
|
||||||
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
|
|||||||
bool deleted = await Navigator.push<bool>(
|
bool deleted = await Navigator.push<bool>(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => ProcessingEditor(
|
builder: (context) => ProcessingEditEditor(
|
||||||
package: widget.package,
|
package: widget.package,
|
||||||
)));
|
)));
|
||||||
if (deleted ?? false) {
|
if (deleted ?? false) {
|
||||||
|
|||||||
@@ -82,7 +82,8 @@ class _DiscountByWeightListState extends State<DiscountByWeightList> {
|
|||||||
discountByWeight: discountByWeight)));
|
discountByWeight: discountByWeight)));
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
child: _row("${discountByWeight.weight.toString()} lb",
|
child: _row(
|
||||||
|
"${discountByWeight.weight.toStringAsFixed(2)} lb",
|
||||||
"\$ " + discountByWeight.discount.toString()),
|
"\$ " + discountByWeight.discount.toString()),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
if (widget.discountByWeight != null) {
|
if (widget.discountByWeight != null) {
|
||||||
_discountByWeight = widget.discountByWeight;
|
_discountByWeight = widget.discountByWeight;
|
||||||
_weightController.text = _discountByWeight.weight.toString();
|
_weightController.text = _discountByWeight.weight.toStringAsFixed(2);
|
||||||
_discountController.text = _discountByWeight.discount.toString();
|
_discountController.text = _discountByWeight.discount.toString();
|
||||||
_isNew = false;
|
_isNew = false;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -196,8 +196,8 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
|||||||
if (discounts == null) return [];
|
if (discounts == null) return [];
|
||||||
return discounts.map((d) {
|
return discounts.map((d) {
|
||||||
return Container(
|
return Container(
|
||||||
child: _row(
|
child: _row("${d.weight.toStringAsFixed(2)} lb",
|
||||||
"${d.weight.toString()} lb", "\$ " + d.discount.toString(), ''),
|
"\$ " + d.discount.toString(), ''),
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
|||||||
Provider.of<ShipmentRateModel>(context, listen: false);
|
Provider.of<ShipmentRateModel>(context, listen: false);
|
||||||
Rate rate = shipmentRateModel.rate;
|
Rate rate = shipmentRateModel.rate;
|
||||||
|
|
||||||
_minWeight.text = rate.freeDeliveryWeight?.toString() ?? "";
|
_minWeight.text = rate.freeDeliveryWeight?.toStringAsFixed(2) ?? "";
|
||||||
_deliveryFee.text = rate.deliveryFee?.toString() ?? "";
|
_deliveryFee.text = rate.deliveryFee?.toString() ?? "";
|
||||||
_volumetricRatio.text = rate.volumetricRatio?.toString() ?? "";
|
_volumetricRatio.text = rate.volumetricRatio?.toString() ?? "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ class BoxRow extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
"Actual Weight:${box.actualWeight.toString()}lb",
|
"Actual Weight:${box.actualWeight.toStringAsFixed(2)}lb",
|
||||||
style: new TextStyle(fontSize: 14.0, color: Colors.grey),
|
style: new TextStyle(fontSize: 14.0, color: Colors.grey),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
Text(c.weight == null ? "0" : c.weight.toString(),
|
Text(c.weight == null ? "0" : c.weight.toStringAsFixed(2),
|
||||||
style: textStyle),
|
style: textStyle),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
@@ -265,7 +265,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
|||||||
padding: const EdgeInsets.only(right: 48.0),
|
padding: const EdgeInsets.only(right: 48.0),
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
child: Text(total.toString(),
|
child: Text(total.toStringAsFixed(2),
|
||||||
style: TextStyle(fontWeight: FontWeight.bold))),
|
style: TextStyle(fontWeight: FontWeight.bold))),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'display_image_source.dart';
|
|||||||
|
|
||||||
class MultiImgController {
|
class MultiImgController {
|
||||||
List<String> imageUrls = [];
|
List<String> imageUrls = [];
|
||||||
|
List<File> imageFiles = [];
|
||||||
List<DisplayImageSource> addedFiles = [];
|
List<DisplayImageSource> addedFiles = [];
|
||||||
List<DisplayImageSource> removedFiles = [];
|
List<DisplayImageSource> removedFiles = [];
|
||||||
|
|
||||||
@@ -29,6 +30,22 @@ class MultiImgController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set setImageFiles(List<File> imageFiles) {
|
||||||
|
if (imageFiles == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fileContainers.clear();
|
||||||
|
|
||||||
|
this.imageFiles = imageFiles;
|
||||||
|
imageFiles.forEach((e) {
|
||||||
|
fileContainers.add(DisplayImageSource(file: e));
|
||||||
|
});
|
||||||
|
if (callback != null) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void onChange(CallBack callBack) {
|
void onChange(CallBack callBack) {
|
||||||
this.callback = callBack;
|
this.callback = callBack;
|
||||||
}
|
}
|
||||||
@@ -51,11 +68,22 @@ class MultiImgController {
|
|||||||
if (imageUrls.contains(fileContainer.url)) {
|
if (imageUrls.contains(fileContainer.url)) {
|
||||||
removedFiles.add(fileContainer);
|
removedFiles.add(fileContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (imageFiles.contains(fileContainer.file)) {
|
||||||
|
this.imageFiles.remove(fileContainer.file);
|
||||||
|
}
|
||||||
|
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<File> get getUpdatedFile {
|
||||||
|
List<File> _addfiles = getAddedFile;
|
||||||
|
this.imageFiles.addAll(_addfiles);
|
||||||
|
return this.imageFiles;
|
||||||
|
}
|
||||||
|
|
||||||
List<File> get getAddedFile {
|
List<File> get getAddedFile {
|
||||||
return addedFiles.map((e) => e.file).toList();
|
return addedFiles.map((e) => e.file).toList();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user