This commit is contained in:
PhyoThandar
2020-10-09 19:02:35 +06:30
6 changed files with 690 additions and 448 deletions

View File

@@ -234,6 +234,26 @@
"box.length":"Length", "box.length":"Length",
"box.width":"Width", "box.width":"Width",
"box.height":"Height", "box.height":"Height",
"box.shipment_info":"Shipment Information",
"box.cargo_type":"Cargo Types",
"box.dimension":"Box Dimension",
"box.delivery_address":"Delivery Address",
"box.fcs_shipment_num":"FCS Shipment Number",
"box.fcs.id":"FCS ID",
"box.name":"Customer Name",
"box.phone":"Phone Number",
"box.actual_weight":"Actual Weight",
"box.add_cargo":"Add Cargo",
"box.shipment_weight":"Shipment Weight",
"box.change_address":"Change\nAddress",
"box.status":"Status",
"box.create.btn":"Create New Box",
"box.complete.btn":"Complete packing",
"box.deliver.btn":"Deliver",
"box.packages":"Packages",
"box.tracking.id":"Tracking ID",
"box.market":"Market",
"box.cargo.save.btn":"Save",
"Boxes End ================================================================":"", "Boxes End ================================================================":"",
"Delivery Start ================================================================":"", "Delivery Start ================================================================":"",
@@ -293,7 +313,7 @@
"Rate End ================================================================":"", "Rate End ================================================================":"",
"Cargo Start ================================================================":"", "Cargo Start ================================================================":"",
"cargo.form.title":"CARGO", "cargo.form.title":"Cargo",
"cargo.type":"Cargo Type", "cargo.type":"Cargo Type",
"cargo.weight":"Weight", "cargo.weight":"Weight",
"cargo.rate":"Rate", "cargo.rate":"Rate",

View File

@@ -222,10 +222,10 @@
"Message End ================================================================":"", "Message End ================================================================":"",
"Boxes Start ================================================================":"", "Boxes Start ================================================================":"",
"boxes.name":"Boxes", "boxes.name":"သေတ္တာများ",
"boxes.title":"Boxes", "boxes.title":"Boxes",
"boxes.new":"New Box", "boxes.new":"သေတ္တာအသစ်",
"box.edit.title":"Edit Box", "box.edit.title":"သေတ္တာ ပြင်ဆင်ခြင်း",
"box.package.id":"Package ID", "box.package.id":"Package ID",
"box.package.desc":"Description", "box.package.desc":"Description",
"box.package.market":"Market", "box.package.market":"Market",
@@ -234,6 +234,26 @@
"box.length":"အလျား", "box.length":"အလျား",
"box.width":"အနံ", "box.width":"အနံ",
"box.height":"အမြင့်", "box.height":"အမြင့်",
"box.shipment_info":"တင်ပို့သတင်းအချက်အလက်",
"box.cargo_type":"ကုန်ပစ္စည်းအမျိုးအစားများ",
"box.dimension":"သေတ္တာအရွယ်အစား",
"box.delivery_address":"ပို့ဆောင်ရမည့်လိပ်စာ",
"box.fcs_shipment_num":"FCS တင်ပို့နံပါတ်",
"box.fcs.id":"FCS ID",
"box.name":"နာမည်",
"box.phone":"ဖုန်းနံပါတ်",
"box.actual_weight":"အမှန်အလေးချိန်",
"box.add_cargo":"ကုန်ပစ္စည်း\nထည့်ရန်",
"box.shipment_weight":"တင်ပို့အလေးချိန်",
"box.change_address":"လိပ်စာ\nပြောင်းရန်",
"box.status":"အခြေအနေ",
"box.create.btn":"သေတ္တာအသစ်ပြုလုပ်မည်",
"box.complete.btn":"ထုပ်ပိုးခြင်းပြီးဆုံးမည်",
"box.deliver.btn":"ပေးပို့မည်",
"box.packages":"အထုပ်များ",
"box.tracking.id":"Tracking ID",
"box.market":"အွန်လိုင်စျေးဆိုင်",
"box.cargo.save.btn":"သိမ်းဆည်းမည်",
"Boxes End ================================================================":"", "Boxes End ================================================================":"",
"Delivery Start ================================================================":"", "Delivery Start ================================================================":"",
@@ -293,7 +313,7 @@
"Rate End ================================================================":"", "Rate End ================================================================":"",
"Cargo Start ================================================================":"", "Cargo Start ================================================================":"",
"cargo.form.title":"ကုန်ပစ္စည်းအမျိုးအစား", "cargo.form.title":"ကုန်ပစ္စည်း",
"cargo.type":"ကုန်ပစ္စည်းအမျိုးအစား", "cargo.type":"ကုန်ပစ္စည်းအမျိုးအစား",
"cargo.weight":"အလေးချိန်", "cargo.weight":"အလေးချိန်",
"cargo.rate":"စျေးနှုန်း", "cargo.rate":"စျေးနှုန်း",

View File

@@ -25,6 +25,7 @@ class Package {
String boxNumber; String boxNumber;
String cargoDesc; String cargoDesc;
String market; String market;
bool isChecked;
int rate; int rate;
int weight; int weight;
@@ -40,8 +41,8 @@ class Package {
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,
@@ -69,7 +70,7 @@ class Package {
this.currentStatusDate, this.currentStatusDate,
this.photoUrls, this.photoUrls,
this.desc, this.desc,
}); this.isChecked =false});
factory Package.fromMap(Map<String, dynamic> map, String docID) { factory Package.fromMap(Map<String, dynamic> map, String docID) {
var _currentStatusDate = (map['current_status_date'] as Timestamp); var _currentStatusDate = (map['current_status_date'] as Timestamp);

View File

@@ -1,13 +1,20 @@
import 'package:fcs/domain/entities/box.dart'; import 'package:fcs/domain/entities/box.dart';
import 'package:fcs/domain/entities/cargo.dart'; import 'package:fcs/domain/entities/cargo.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/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/localization/app_translations.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/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/package/model/package_model.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/fcs_id_icon.dart';
import 'package:fcs/pages/widgets/input_text.dart';
import 'package:fcs/pages/widgets/local_text.dart'; import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/my_data_table.dart'; import 'package:fcs/pages/widgets/my_data_table.dart';
import 'package:fcs/pages/widgets/progress.dart'; import 'package:fcs/pages/widgets/progress.dart';
@@ -19,6 +26,8 @@ import 'package:provider/provider.dart';
import 'package:timeline_list/timeline.dart'; import 'package:timeline_list/timeline.dart';
import 'package:timeline_list/timeline_model.dart'; import 'package:timeline_list/timeline_model.dart';
import 'cargo_type_editor.dart';
class BoxEditor extends StatefulWidget { class BoxEditor extends StatefulWidget {
final Box box; final Box box;
BoxEditor({this.box}); BoxEditor({this.box});
@@ -28,53 +37,54 @@ class BoxEditor extends StatefulWidget {
} }
class _BoxEditorState extends State<BoxEditor> { class _BoxEditorState extends State<BoxEditor> {
TextEditingController _addressEditingController = new TextEditingController(); TextEditingController _widthController = new TextEditingController();
TextEditingController _fromTimeEditingController = TextEditingController _heightController = new TextEditingController();
new TextEditingController(); TextEditingController _lengthController = new TextEditingController();
TextEditingController _toTimeEditingController = new TextEditingController();
TextEditingController _noOfPackageEditingController =
new TextEditingController();
TextEditingController _weightEditingController = new TextEditingController();
Box _box; Box _box;
bool _isLoading = false; bool _isLoading = false;
List<String> _images = [
"assets/photos/1.jpg",
"assets/photos/2.jpg",
"assets/photos/3.jpg"
];
bool isNew; bool isNew;
bool isMixBox = false; bool isMixBox = false;
DeliveryAddress _shippingAddress = new DeliveryAddress(); DeliveryAddress _deliveryAddress = new DeliveryAddress();
User user;
String selectShipmentNumber;
List<Package> _packages = [];
@override @override
void initState() { void initState() {
super.initState(); super.initState();
var packageModel = Provider.of<PackageModel>(context, listen: false);
_packages = [
packageModel.packages[0],
packageModel.packages[1],
packageModel.packages[2],
packageModel.packages[8]
];
_packages.forEach((p) {
p.isChecked = false;
});
if (widget.box != null) { if (widget.box != null) {
_box = widget.box; _box = widget.box;
_shippingAddress = _box.shippingAddress; _deliveryAddress = _box.shippingAddress;
isNew = false; isNew = false;
// _addressEditingController.text = _pickUp.address; selectShipmentNumber = _box.shipmentNumber;
// _fromTimeEditingController.text = _pickUp.fromTime; _widthController.text = _box.width.toString();
// _toTimeEditingController.text = _pickUp.toTime; _heightController.text = _box.height.toString();
// _noOfPackageEditingController.text = _pickUp.numberOfPackage.toString(); _lengthController.text = _box.length.toString();
// _weightEditingController.text = _pickUp.weight.toString();
} else { } else {
List<Package> packages = [
// PackageModel.packages[0],
// PackageModel.packages[1],
// PackageModel.packages[2]
];
List<Cargo> _cargoTypes = [ List<Cargo> _cargoTypes = [
Cargo(type: 'General Cargo', weight: 25), Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20), Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30) Cargo(type: 'Dangerous Cargo', weight: 30)
]; ];
var shipmentModel = _deliveryAddress = DeliveryAddress(
Provider.of<DeliveryAddressModel>(context, listen: false); fullName: 'U Nyi Nyi',
_shippingAddress = shipmentModel.deliveryAddresses[1]; addressLine1: '154-19 64th Ave.',
addressLine2: 'Flushing',
city: 'NY',
state: 'NY',
phoneNumber: '+1 (292)215-2247');
isNew = true; isNew = true;
_box = Box( _box = Box(
@@ -83,7 +93,6 @@ class _BoxEditorState extends State<BoxEditor> {
width: 0, width: 0,
height: 0, height: 0,
length: 0, length: 0,
packages: packages,
cargoTypes: _cargoTypes, cargoTypes: _cargoTypes,
shipmentWeight: 0); shipmentWeight: 0);
} }
@@ -136,57 +145,41 @@ class _BoxEditorState extends State<BoxEditor> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var mainModel = Provider.of<MainModel>(context); var languageModel = Provider.of<LanguageModel>(context);
return LocalProgress(
inAsyncCall: _isLoading, var shipmentBox = Container(
child: Scaffold( child: Padding(
appBar: AppBar( padding: const EdgeInsets.only(left: 10.0),
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,
title: Text(AppTranslations.of(context).text("box.edit.title")),
),
body: Card(
child: Column(
children: <Widget>[
widget.box == null
? Center(
child: Container(
padding: EdgeInsets.all(8), child: Text("New Box")))
: Center(child: nameWidget(_box.packageNumber)),
Expanded(
child: ListView(
children: [
ExpansionTile(
title: Text(
'Shipment Information',
style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold),
),
children: [
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: DropdownButtonFormField( child: DropdownButtonFormField(
value: _box.shipmentNumber, value: selectShipmentNumber,
decoration: InputDecoration( decoration: InputDecoration(
fillColor: Colors.white, fillColor: Colors.white,
labelText: 'FCS Shipment Number', labelText:
icon: Icon(Ionicons.ios_airplane, AppTranslations.of(context).text("box.fcs_shipment_num"),
color: primaryColor) labelStyle: languageModel.isEng
// prefixIcon: Icon(Icons.play_arrow) ? TextStyle(fontWeight: FontWeight.w500)
), : TextStyle(
fontWeight: FontWeight.w500, fontFamily: "Myanmar3"),
icon: Icon(
Ionicons.ios_airplane,
color: primaryColor,
)),
items: ["A102", "A103", "A201", "A202"] items: ["A102", "A103", "A201", "A202"]
.map((e) => .map((e) => DropdownMenuItem(
DropdownMenuItem(child: Text(e), value: e)) child: Text(
e,
style: TextStyle(color: primaryColor),
),
value: e))
.toList(), .toList(),
onChanged: (map) => {}, onChanged: (value) {
), setState(() {
), selectShipmentNumber = value;
Padding( });
padding: const EdgeInsets.only(left: 8.0, right: 20), },
)));
final mixBox = Container(
child: new Row( child: new Row(
children: <Widget>[ children: <Widget>[
new Checkbox( new Checkbox(
@@ -211,216 +204,375 @@ class _BoxEditorState extends State<BoxEditor> {
), ),
], ],
), ),
);
final fcsIDBox = Container(
padding: EdgeInsets.only(left: 10),
child: Row(
children: <Widget>[
Expanded(
child: DisplayText(
text: user != null ? user.fcsID : "",
labelTextKey: "box.fcs.id",
icon: FcsIDIcon(),
)),
IconButton(
icon: Icon(Icons.search, color: primaryColor),
onPressed: () => searchUser(context, callbackUserSelect: (u) {
setState(() {
this.user = u;
});
})),
],
));
final phoneNumberBox = Container(
padding: EdgeInsets.only(left: 10),
child: DisplayText(
text: user != null ? user.phoneNumber : "",
labelTextKey: "box.phone",
iconData: Icons.phone,
));
final namebox = Container(
padding: EdgeInsets.only(left: 10),
child: DisplayText(
text: user != null ? user.name : "",
labelTextKey: "box.name",
iconData: Icons.person,
));
final packageTitle = Container(
padding: EdgeInsets.only(right: 10.0, top: 20),
child: Row(
children: <Widget>[
Container(
width: 50,
), ),
Padding( Expanded(
padding: const EdgeInsets.only(left: 20.0, right: 20), child: LocalText(context, 'box.tracking.id', color: Colors.grey),
child: TextFormField( ),
initialValue: LocalText(context, 'box.market', color: Colors.grey),
isNew ? "FCS-0203-390-2" : "FCS-0203-390-2", ],
decoration: InputDecoration( ),
fillColor: Colors.white, );
labelText: 'FCS_ID',
hintText: 'FCS_ID', List<Widget> getPackageRowList() {
filled: true, return _packages.asMap().entries.map((p) {
icon: Icon(Feather.user, color: primaryColor), return Container(
suffixIcon: IconButton( color: p.value.isChecked
icon: Icon(Icons.search), ? Colors.grey.withOpacity(0.2)
onPressed: () {})), : Colors.grey[50].withOpacity(0.2),
child: Container(
padding:
EdgeInsets.only(left: 0.0, right: 10.0, top: 3.0, bottom: 3.0),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: p.key == _packages.length - 1
? Colors.white
: Colors.grey[350],
width: 1),
), ),
), ),
Padding( child: Row(
padding: const EdgeInsets.only(left: 20.0, right: 20), children: <Widget>[
child: TextFormField( Checkbox(
initialValue: _box.receiverName, value: p.value.isChecked,
decoration: InputDecoration( activeColor: primaryColor,
fillColor: Colors.white, onChanged: (bool check) {
labelText: 'Customer Name', setState(() {
filled: true, p.value.isChecked = check;
icon: Icon(Feather.user, color: Colors.white), });
suffixIcon: IconButton( }),
icon: Icon(Icons.search), Expanded(
onPressed: () {})), child: new Text(
), p.value.trackingID,
), style: textStyle,
SizedBox( )),
height: 30, new Text(
p.value.market == null ? "" : p.value.market,
style: textStyle,
) )
], ],
), ),
ExpansionTile(
title: Text(
'Cargo Types',
style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold),
),
children: [
// Padding(
// padding: const EdgeInsets.only(left: 20.0, right: 20),
// child: DropdownButtonFormField(
// value: _box.packageType,
// decoration: InputDecoration(
// fillColor: Colors.white,
// labelText: 'Cargo Type',
// icon: Icon(Entypo.box, color: primaryColor)),
// items: ["General", "Medicine", "Dangerous"]
// .map((e) =>
// DropdownMenuItem(child: Text(e), value: e))
// .toList(),
// onChanged: (map) => {},
// ),
// ),
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: TextFormField(
initialValue: _box.weight.toString(),
textAlign: TextAlign.end,
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Actual Weight',
filled: true,
icon: Icon(FontAwesomeIcons.weightHanging,
color: primaryColor),
)),
),
// Padding(
// padding: const EdgeInsets.only(left: 20.0, right: 20),
// child: TextFormField(
// initialValue: _box.rate.toString(),
// textAlign: TextAlign.end,
// decoration: InputDecoration(
// fillColor: Colors.white,
// labelText: 'Rate',
// filled: true,
// icon: Icon(FontAwesomeIcons.tag,
// color: primaryColor),
// )),
// ),
// Padding(
// padding: const EdgeInsets.only(left: 20.0, right: 20),
// child: TextFormField(
// initialValue: _box.amount.toString(),
// textAlign: TextAlign.end,
// decoration: InputDecoration(
// fillColor: Colors.white,
// labelText: 'Total Amount',
// filled: true,
// icon: Icon(FontAwesomeIcons.moneyBill,
// color: primaryColor),
// )),
// ),
Container(
padding: EdgeInsets.only(top: 10),
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: MyDataTable(
headingRowHeight: 40,
columnSpacing: 120,
columns: [
MyDataColumn(
label: LocalText(
context,
"cargo.type",
color: Colors.grey,
),
),
MyDataColumn(
label: LocalText(
context,
"cargo.weight",
color: Colors.grey,
), ),
);
}).toList();
}
final actualWeightBox = Container(
padding: EdgeInsets.only(left: 10),
child: DisplayText(
text: _box.weight != null ? _box.weight.toString() : "",
labelTextKey: "box.actual_weight",
iconData: FontAwesomeIcons.weightHanging,
));
final cargoTitle = Container(
padding: EdgeInsets.only(left: 15, right: 0.0, top: 20),
child: Row(
children: <Widget>[
Expanded(
child: LocalText(context, 'cargo.type', color: Colors.grey),
), ),
LocalText(context, 'cargo.weight', color: Colors.grey),
],
),
);
List<Widget> getCargoRowList() {
return _box.cargoTypes.asMap().entries.map((c) {
return InkWell(
onTap: () {
Navigator.push(
context,
BottomUpPageRoute(CargoTypeEditor(cargo: c.value)),
);
},
child: Container(
color: Colors.grey[50].withOpacity(0.2),
child: Container(
padding: EdgeInsets.only(
left: 15.0, right: 10.0, top: 15.0, bottom: 15.0),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(color: Colors.grey[350], width: 1),
),
),
child: Row(
children: <Widget>[
Expanded(
child: new Text(
c.value.type,
style: textStyle,
)),
new Text(
c.value.weight == null ? "0" : c.value.weight.toString(),
style: textStyle,
)
], ],
rows: getCargoRows(context),
), ),
), ),
), ),
true );
? Container( }).toList();
padding: EdgeInsets.only(top: 20), }
final shipmentWeightBox = Container(
padding: EdgeInsets.only(left: 10),
child: DisplayText(
text:
_box.shipmentWeight != null ? _box.shipmentWeight.toString() : "",
labelTextKey: "box.shipment_weight",
iconData: FontAwesomeIcons.weightHanging,
));
final widthBox = InputText(
labelTextKey: 'box.width',
iconData: FontAwesomeIcons.arrowCircleRight,
controller: _widthController);
final heightBox = InputText(
labelTextKey: 'box.height',
iconData: FontAwesomeIcons.arrowAltCircleUp,
controller: _heightController);
final lengthBox = InputText(
labelTextKey: 'box.length',
iconData: FontAwesomeIcons.arrowCircleUp,
controller: _lengthController);
final createBtn = fcsButton(
context,
getLocalString(context, 'box.create.btn'),
callack: () {},
);
final completeBtn = fcsButton(
context,
getLocalString(context, 'box.complete.btn'),
callack: () {},
);
final deliveryBtn = fcsButton(
context,
getLocalString(context, 'box.deliver.btn'),
callack: () {},
);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close, color: primaryColor, size: 30),
onPressed: () => Navigator.of(context).pop(),
),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,
title: widget.box == null
? LocalText(
context,
"boxes.new",
fontSize: 20,
color: primaryColor,
)
: LocalText(
context,
"box.edit.title",
fontSize: 20,
color: primaryColor,
),
),
body: Padding(
padding: const EdgeInsets.only(left: 12.0, right: 12),
child: ListView(
shrinkWrap: true,
children: [
widget.box == null
? Container()
: Center(child: nameWidget(_box.packageNumber)),
Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: LocalText(
context,
"box.shipment_info",
color: primaryColor,
fontSize: 16,
fontWeight: FontWeight.w700,
),
),
),
Column(
children: [
shipmentBox,
SizedBox(
height: 10,
),
fcsIDBox,
phoneNumberBox,
namebox,
mixBox,
],
),
Divider(),
Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: LocalText(
context,
"box.packages",
color: primaryColor,
fontSize: 16,
fontWeight: FontWeight.w700,
),
),
),
Column(
children: [
packageTitle,
Divider(
color: Colors.grey[400],
),
Column(
children: getPackageRowList(),
),
SizedBox(height: 15),
],
),
Divider(),
Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: LocalText(
context,
"box.cargo_type",
color: primaryColor,
fontSize: 16,
fontWeight: FontWeight.w700,
),
),
),
Column(
children: [
actualWeightBox,
cargoTitle,
Divider(
color: Colors.grey[400],
),
Column(
children: _box == null || _box.cargoTypes == null
? []
: getCargoRowList(),
),
Container(
padding: EdgeInsets.only(top: 25),
child: Align( child: Align(
alignment: Alignment.bottomRight, alignment: Alignment.bottomRight,
child: FloatingActionButton.extended( child: FloatingActionButton.extended(
icon: Icon(Icons.add), icon: Icon(Icons.add),
label: Text("Add Cargo"), heroTag: "add cargo",
label: LocalText(
context,
"box.add_cargo",
color: Colors.white,
),
backgroundColor: primaryColor, backgroundColor: primaryColor,
onPressed: () { onPressed: () {
// Navigator.of(context).push( Navigator.push(
// BottomUpPageRoute(PackageAddition())); context,
BottomUpPageRoute(CargoTypeEditor()),
);
}, },
), ),
), ),
)
: Container(),
SizedBox(height: 25),
],
),
ExpansionTile(
title: Text(
'Box Dimension',
style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold),
),
children: [
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: fcsInputReadOnly(
"Shipment Weight", FontAwesomeIcons.weightHanging,
value: _box.shipmentWeight.toString()),
),
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: TextFormField(
initialValue: _box.width.toString(),
textAlign: TextAlign.end,
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Width',
filled: true,
icon: Icon(FontAwesomeIcons.arrowCircleRight,
color: primaryColor),
)),
),
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: TextFormField(
initialValue: _box.height.toString(),
textAlign: TextAlign.end,
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Height',
filled: true,
icon: Icon(FontAwesomeIcons.arrowAltCircleUp,
color: primaryColor),
)),
),
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: TextFormField(
initialValue: _box.length.toString(),
textAlign: TextAlign.end,
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Length',
filled: true,
icon: Icon(FontAwesomeIcons.arrowCircleUp,
color: primaryColor),
)),
), ),
SizedBox(height: 25), SizedBox(height: 25),
], ],
), ),
ExpansionTile( Divider(),
title: Text( Center(
'Shipping Address', child: Padding(
style: TextStyle( padding: const EdgeInsets.all(8.0),
color: primaryColor, fontWeight: FontWeight.bold), child: LocalText(
context,
"box.dimension",
color: primaryColor,
fontSize: 16,
fontWeight: FontWeight.w700,
), ),
),
),
Column(
children: [ children: [
DeliveryAddressRow(shippingAddress: _shippingAddress), shipmentWeightBox,
widthBox,
heightBox,
lengthBox,
SizedBox(height: 25),
],
),
Divider(),
Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: LocalText(
context,
"box.delivery_address",
color: primaryColor,
fontSize: 16,
fontWeight: FontWeight.w700,
),
),
),
Column(
children: [
DeliveryAddressRow(shippingAddress: _deliveryAddress),
Container( Container(
padding: padding: EdgeInsets.only(top: 20, bottom: 15, right: 15),
EdgeInsets.only(top: 20, bottom: 15, right: 15),
child: Align( child: Align(
alignment: Alignment.bottomRight, alignment: Alignment.bottomRight,
child: Container( child: Container(
@@ -429,33 +581,46 @@ class _BoxEditorState extends State<BoxEditor> {
child: FloatingActionButton.extended( child: FloatingActionButton.extended(
materialTapTargetSize: materialTapTargetSize:
MaterialTapTargetSize.shrinkWrap, MaterialTapTargetSize.shrinkWrap,
onPressed: () {}, onPressed: () async {
DeliveryAddress deliveryAddress =
await Navigator.push(
context,
BottomUpPageRoute(DeliveryAddressList(
deliveryAddress: _deliveryAddress)),
);
setState(() {
_deliveryAddress = deliveryAddress;
});
},
icon: Icon(Icons.add), icon: Icon(Icons.add),
label: Text( label: LocalText(context, "box.change_address",
'Select \nAddress', color: Colors.white),
style: TextStyle(fontSize: 12),
),
backgroundColor: primaryColor, backgroundColor: primaryColor,
), ),
), ),
), ),
), ),
SizedBox(height: 25), SizedBox(height: 10),
], ],
), ),
Divider(),
isNew isNew
? Container() ? Container()
: ExpansionTile( : Column(
title: Text( children: [
'Status', Padding(
style: TextStyle( padding: const EdgeInsets.all(8.0),
child: LocalText(
context,
"box.status",
color: primaryColor, color: primaryColor,
fontWeight: FontWeight.bold), fontSize: 16,
fontWeight: FontWeight.w700,
),
), ),
children: <Widget>[
Container( Container(
height: 500, height: 230,
padding: EdgeInsets.only(left: 20), padding: EdgeInsets.only(left: 10),
child: isNew child: isNew
? Container() ? Container()
: Timeline( : Timeline(
@@ -463,60 +628,25 @@ class _BoxEditorState extends State<BoxEditor> {
position: TimelinePosition.Left), position: TimelinePosition.Left),
), ),
], ],
)
],
), ),
isNew ? Container() : Divider(),
SizedBox(
height: 10,
), ),
widget.box == null widget.box == null
? Align( ? createBtn
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Create New Box'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
)))
: Container( : Container(
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
Align( completeBtn,
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Complete packing'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
))),
widget.box.status == 'Arrived' widget.box.status == 'Arrived'
? Align( ? deliveryBtn
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Deliver'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
)))
: Container(), : Container(),
], ],
)), )),
SizedBox(
height: 20,
),
], ],
), ),
), ),
@@ -524,27 +654,6 @@ class _BoxEditorState extends State<BoxEditor> {
); );
} }
List<MyDataRow> getCargoRows(BuildContext context) {
if (_box == null || _box.cargoTypes == null) {
return [];
}
return _box.cargoTypes.map((c) {
return MyDataRow(
onSelectChanged: (bool selected) {},
cells: [
MyDataCell(new Text(
c.type == null ? "" : c.type,
style: textStyle,
)),
MyDataCell(
new Text(c.weight == null ? "0" : c.weight.toString(),
style: textStyle),
),
],
);
}).toList();
}
List<Widget> getAddressList( List<Widget> getAddressList(
BuildContext context, List<DeliveryAddress> addresses) { BuildContext context, List<DeliveryAddress> addresses) {
return addresses.asMap().entries.map((s) { return addresses.asMap().entries.map((s) {

View File

@@ -2,6 +2,7 @@ import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart'; import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/box/model/box_model.dart'; import 'package:fcs/pages/box/model/box_model.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart'; import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/progress.dart'; import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@@ -41,7 +42,8 @@ class _BoxListState extends State<BoxList> {
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
), ),
backgroundColor: primaryColor, backgroundColor: primaryColor,
title: Text(AppTranslations.of(context).text("boxes.title")), title: LocalText(context, "boxes.name",
color: Colors.white, fontSize: 20),
actions: <Widget>[ actions: <Widget>[
IconButton( IconButton(
icon: Icon( icon: Icon(

View File

@@ -0,0 +1,90 @@
import 'package:fcs/domain/entities/cargo.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/main/util.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/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class CargoTypeEditor extends StatefulWidget {
final Cargo cargo;
CargoTypeEditor({this.cargo});
@override
_CargoTypeEditorState createState() => _CargoTypeEditorState();
}
class _CargoTypeEditorState extends State<CargoTypeEditor> {
TextEditingController _typeController = new TextEditingController();
TextEditingController _weightController = new TextEditingController();
bool _isLoading = false;
Cargo _cargo;
@override
void initState() {
super.initState();
if (widget.cargo != null) {
_cargo = widget.cargo;
_typeController.text = _cargo.type;
_weightController.text = _cargo.weight.toString();
}
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
final typeBox = InputText(
labelTextKey: 'cargo.type',
iconData: Icons.text_format,
controller: _typeController);
final rateBox = InputText(
labelTextKey: 'cargo.weight',
iconData: FontAwesomeIcons.weightHanging,
textInputType: TextInputType.number,
controller: _weightController);
final saveBtn = fcsButton(
context,
getLocalString(context, 'box.cargo.save.btn'),
callack: () {},
);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close, 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(
children: <Widget>[
typeBox,
rateBox,
SizedBox(height: 40),
saveBtn,
SizedBox(height: 20),
],
),
),
),
);
}
}