update shipment rate

This commit is contained in:
Thinzar Win
2020-06-25 16:19:23 +06:30
parent fd63f30cb4
commit 869142ec66
18 changed files with 797 additions and 300 deletions

View File

@@ -1,6 +1,7 @@
import 'package:fcs/model/main_model.dart';
import 'package:fcs/model/pickup_model.dart';
import 'package:fcs/pages/util.dart';
import 'package:fcs/vo/cargo.dart';
import 'package:fcs/vo/pickup.dart';
import 'package:fcs/widget/fcs_text_field.dart';
import 'package:fcs/widget/fcs_text_field_readonly.dart';
@@ -70,6 +71,12 @@ class _PickUpEditorState extends State<PickUpEditor> {
mainModel.recipient.shippingAddress;
} else {
isNew = true;
List<Cargo> _cargoTypes = [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
];
_pickUp = PickUp(cargoTypes: _cargoTypes);
}
}
@@ -319,50 +326,56 @@ class _PickUpEditorState extends State<PickUpEditor> {
],
),
// ExpansionTile(
// title: Text('Recipient Information'),
// title: Text('Box Information'),
// children: <Widget>[
// Padding(
// padding: const EdgeInsets.only(left: 20.0),
// child: widget.pickUp == null
// ? fcsInput("Name", FontAwesomeIcons.user,
// controller: _recipientNameEditingController)
// : widget.pickUp.status == 'Pending'
// ? fcsInput("Name", FontAwesomeIcons.user,
// controller:
// _recipientNameEditingController)
// : fcsInputReadOnly(
// "Name", FontAwesomeIcons.user,
// controller:
// _recipientNameEditingController)),
// Padding(
// padding: const EdgeInsets.only(left: 20.0),
// child: widget.pickUp == null
// ? fcsInput("Phone Number", Icons.phone,
// controller: _recipientPhoneEditingController)
// : widget.pickUp.status == 'Pending'
// ? fcsInput("Phone Number", Icons.phone,
// controller:
// _recipientPhoneEditingController)
// : fcsInputReadOnly(
// "Phone Number", Icons.phone,
// controller:
// _recipientPhoneEditingController)),
// Padding(
// padding: const EdgeInsets.only(left: 20.0),
// child: widget.pickUp == null
// ? fcsInput("Address", Icons.location_on,
// controller:
// _recipientAddressEditingController)
// : widget.pickUp.status == 'Pending'
// ? fcsInput("Address", Icons.location_on,
// controller:
// _recipientAddressEditingController)
// : fcsInputReadOnly(
// "Address", Icons.location_on,
// controller:
// _recipientAddressEditingController)),
// SizedBox(height: 10.0),
// ],
// ),
ExpansionTile(
title: Text('Shipping Address'),
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 20.0),
child: widget.pickUp == null
? fcsInput("Name", FontAwesomeIcons.user,
controller: _recipientNameEditingController)
: widget.pickUp.status == 'Pending'
? fcsInput("Name", FontAwesomeIcons.user,
controller:
_recipientNameEditingController)
: fcsInputReadOnly(
"Name", FontAwesomeIcons.user,
controller:
_recipientNameEditingController)),
Padding(
padding: const EdgeInsets.only(left: 20.0),
child: widget.pickUp == null
? fcsInput("Phone Number", Icons.phone,
controller: _recipientPhoneEditingController)
: widget.pickUp.status == 'Pending'
? fcsInput("Phone Number", Icons.phone,
controller:
_recipientPhoneEditingController)
: fcsInputReadOnly(
"Phone Number", Icons.phone,
controller:
_recipientPhoneEditingController)),
Padding(
padding: const EdgeInsets.only(left: 20.0),
child: widget.pickUp == null
? fcsInput("Address", Icons.location_on,
controller:
_recipientAddressEditingController)
: widget.pickUp.status == 'Pending'
? fcsInput("Address", Icons.location_on,
controller:
_recipientAddressEditingController)
: fcsInputReadOnly(
"Address", Icons.location_on,
controller:
_recipientAddressEditingController)),
],
),
mainModel.isCustomer()
? Container()
: ExpansionTile(
@@ -421,7 +434,7 @@ class _PickUpEditorState extends State<PickUpEditor> {
child: Container(
width: 250,
child: FlatButton(
child: Text('Update'),
child: Text('Assign'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
@@ -429,6 +442,20 @@ class _PickUpEditorState extends State<PickUpEditor> {
},
),
))),
Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Complete Pickup '),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
))),
Align(
alignment: Alignment.bottomCenter,
child: Center(

View File

@@ -4,6 +4,7 @@ import 'package:fcs/widget/bottom_up_page_route.dart';
import 'package:fcs/widget/local_text.dart';
import 'package:fcs/widget/my_data_table.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:package_info/package_info.dart';
import 'package:provider/provider.dart';
import 'package:fcs/model/language_model.dart';
@@ -214,52 +215,55 @@ class _ProfileState extends State<Profile> {
),
));
final logoutbutton = Padding(
padding: EdgeInsets.symmetric(vertical: 10.0),
child: Card(
elevation: 23,
child: Container(
height: 45.0,
child: ButtonTheme(
minWidth: 900.0,
height: 100.0,
child: FlatButton.icon(
onPressed: () {
showConfirmDialog(context, "profile.logout.confirm",
() async {
setState(() {
_isLoading = true;
});
await mainModel.logout();
Navigator.of(context).pushNamedAndRemoveUntil(
"/home", ModalRoute.withName('/home'));
Future.delayed(Duration(seconds: 1), () {
if (mounted) {
final logoutbutton = Container(
padding: EdgeInsets.only( left: 20.0, right: 24.0),
child: Padding(
padding: EdgeInsets.symmetric(vertical: 10.0),
child: Card(
elevation: 23,
child: Container(
height: 45.0,
child: ButtonTheme(
minWidth: 900.0,
height: 100.0,
child: FlatButton.icon(
onPressed: () {
showConfirmDialog(context, "profile.logout.confirm",
() async {
setState(() {
_isLoading = false;
_isLoading = true;
});
}
});
});
},
label: Text(AppTranslations.of(context).text("profile.logout"),
style: languageModel.isEng
? TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
fontStyle: FontStyle.normal)
: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
fontStyle: FontStyle.normal,
fontFamily: "MyanmarUnicode")),
icon: Icon(
Icons.exit_to_app,
await mainModel.logout();
Navigator.of(context).pushNamedAndRemoveUntil(
"/home", ModalRoute.withName('/home'));
Future.delayed(Duration(seconds: 1), () {
if (mounted) {
setState(() {
_isLoading = false;
});
}
});
});
},
label: Text(
AppTranslations.of(context).text("profile.logout"),
style: languageModel.isEng
? TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
fontStyle: FontStyle.normal)
: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
fontStyle: FontStyle.normal,
fontFamily: "MyanmarUnicode")),
icon: Icon(
Icons.exit_to_app,
),
),
),
),
),
),
));
)));
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
@@ -270,32 +274,37 @@ class _ProfileState extends State<Profile> {
backgroundColor: primaryColor,
actions: <Widget>[],
),
body: ListView(
// padding: EdgeInsets.only(left: 25.0, right: 25.0),
shrinkWrap: true,
body: Column(
children: <Widget>[
Row(
children: <Widget>[
namebox,
Padding(
padding: const EdgeInsets.only(left: 18.0),
child: Icon(Icons.edit),
)
],
),
mainModel.isBuyer() ? Container() : getPrivilegeBox(context),
phonenumberbox,
mainModel.user == null
? Container()
: mainModel.user.email == null || mainModel.user.email == ''
? Container()
: emailBox,
languageBox,
getShippingAddressList(context),
SizedBox(
height: 50,
Expanded(
child: ListView(
// padding: EdgeInsets.only(left: 25.0, right: 25.0),
shrinkWrap: true,
children: <Widget>[
Row(
children: <Widget>[
namebox,
Padding(
padding: const EdgeInsets.only(left: 18.0),
child: Icon(Icons.edit),
)
],
),
mainModel.isBuyer() ? Container() : getPrivilegeBox(context),
phonenumberbox,
mainModel.user == null
? Container()
: mainModel.user.email == null ||
mainModel.user.email == ''
? Container()
: emailBox,
languageBox,
getShippingAddressList(context),
],
),
),
logoutbutton,
SizedBox(height: 25)
],
),
),
@@ -313,41 +322,8 @@ class _ProfileState extends State<Profile> {
fontWeight: FontWeight.bold, fontStyle: FontStyle.normal),
),
children: <Widget>[
Container(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: MyDataTable(
headingRowHeight: 40,
columnSpacing: 50,
columns: [
MyDataColumn(
label: Text(
"Full Name",
style: TextStyle(
fontSize: 15,
color: Colors.grey[600],
),
)),
MyDataColumn(
label: Text(
"Phone Number",
style: TextStyle(
fontSize: 15,
color: Colors.grey[600],
),
)),
MyDataColumn(
label: Text(
"Delete",
style: TextStyle(
fontSize: 15,
color: Colors.grey[600],
),
)),
],
rows: getAddressRows(shipmentModel.shippingAddresses),
),
),
Column(
children: getAddressList(context, shipmentModel.shippingAddresses),
),
Container(
padding: EdgeInsets.only(top: 20, bottom: 15, right: 15),
@@ -378,30 +354,75 @@ class _ProfileState extends State<Profile> {
);
}
List<MyDataRow> getAddressRows(List<ShippingAddress> addresses) {
return addresses.map((s) {
return MyDataRow(
onSelectChanged: (selected) {
Navigator.push(
context,
BottomUpPageRoute(ShippingAddressEditor(shippingAddress: s)),
);
},
cells: [
MyDataCell(
new Text(
s.fullName,
style: textStyle,
),
List<Widget> getAddressList(
BuildContext context, List<ShippingAddress> addresses) {
return addresses.asMap().entries.map((s) {
return Container(
padding: EdgeInsets.only(left: 10, right: 10),
child: InkWell(
onTap: () {
Navigator.push(
context,
BottomUpPageRoute(
ShippingAddressEditor(shippingAddress: s.value)),
);
},
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Expanded(
child: new Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: Row(
children: <Widget>[
Padding(
padding: EdgeInsets.all(5.0),
child: Icon(
SimpleLineIcons.location_pin,
color: primaryColor,
)),
new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
s.value.fullName == null
? ''
: s.value.fullName,
style: new TextStyle(
fontSize: 15.0, color: Colors.black),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
s.value.phoneNumber == null
? ''
: s.value.phoneNumber,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
],
),
],
),
),
),
IconButton(
padding: EdgeInsets.only(right: 30),
icon: Icon(Icons.delete, color: Colors.black45),
onPressed: null)
],
),
s.key == addresses.length - 1
? Container()
: Divider(color: Colors.black)
],
),
MyDataCell(
new Text(
s.phoneNumber,
style: textStyle,
),
),
MyDataCell(IconButton(icon: Icon(Icons.delete), onPressed: null)),
],
),
);
}).toList();
}

View File

@@ -157,6 +157,24 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
var shipmentModel = Provider.of<ShipmentModel>(context);
MainModel mainModel = Provider.of<MainModel>(context);
final cargoBtn = Container(
padding: EdgeInsets.only(top: 5),
child: Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Download Cargo Manifest'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
))),
);
final commercialBtn = Container(
padding: EdgeInsets.only(top: 20),
child: Align(
@@ -296,7 +314,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
Container(
padding:
EdgeInsets.only(top: widget.shipment == null ? 5 : 0),
child: fcsInput('Arrival Date', Icons.date_range,
child: fcsInput('ETA', Icons.date_range,
controller: _arrivalDateController),
),
Container(
@@ -378,6 +396,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
widget.shipment == null ? Container() : commercialBtn,
widget.shipment == null ? Container() : packingBtn,
widget.shipment == null ? Container() : dmsBtn,
widget.shipment == null ? Container() : cargoBtn,
widget.shipment == null ? createBtn : updateBtn,
SizedBox(height: 15)
]),

View File

@@ -105,6 +105,7 @@ class _ShipmentRatesState extends State<ShipmentRates> {
_row("Free delivery within Yangon \nfor shipments over", "10",
"pounds"),
_row("Delivery fees", "\$ 5", "below 10 pounds"),
_row("Volumetric Ratio", "\$ 166.36", "per pound"),
fcsButton(context, "Terms & Conditions", callack: () {
Navigator.of(context)
.push(MaterialPageRoute(builder: (_) => Term()));

View File

@@ -1,7 +1,4 @@
import 'package:fcs/model/pickup_model.dart';
import 'package:fcs/model/shipment_rate_model.dart';
import 'package:fcs/pages/shipment_rates_calculate.dart';
import 'package:fcs/pages/shipment_rates_edit.dart';
import 'package:fcs/vo/pickup.dart';
import 'package:provider/provider.dart';
import 'package:fcs/widget/localization/app_translations.dart';
@@ -10,7 +7,6 @@ import 'package:flutter/material.dart';
import 'package:fcs/widget/progress.dart';
import '../theme/theme.dart';
import 'util.dart';
class ShipmentRatesCal extends StatefulWidget {
final PickUp pickUp;
@@ -31,6 +27,7 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
PickUp _pickUp;
bool _isLoading = false;
String cargoType;
@override
void initState() {
@@ -53,6 +50,7 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
@override
Widget build(BuildContext context) {
var shipmentRateModel = Provider.of<ShipmentRateModel>(context);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
@@ -70,33 +68,74 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
body: Padding(
padding: const EdgeInsets.all(8.0),
child: ListView(
// crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
height: 185,
child: ListView.builder(
itemCount: shipmentRateModel.rates.length,
itemBuilder: (context, index) {
return _row(
shipmentRateModel.rates[index].description +
"\n\$ " +
shipmentRateModel.rates[index].price.toString() +
" per pound",
'',
"",
input: true);
}),
padding: EdgeInsets.only(top: 5, left: 25),
child: Row(
children: <Widget>[
Expanded(
child:
Text('Cargo Type', style: TextStyle(fontSize: 15))),
Container(
width: 150.0,
child: DropdownButtonFormField(
decoration: InputDecoration(
fillColor: Colors.white,
hintText: shipmentRateModel.rates[0].description,
hintStyle: TextStyle(color: Colors.black87)),
items: shipmentRateModel.rates
.map((e) => DropdownMenuItem(
child: Text(e.description),
value: e.description))
.toList(),
onChanged: (selected) => {
setState(() {
cargoType = selected;
})
},
),
),
],
),
),
_row('Width (inches)', "", "", "10", input: true),
_row('Height', "", "", "10", input: true),
_row('Length', "", "", "10", input: true),
Container(
padding: EdgeInsets.only(left: 25, top: 15, bottom: 5),
child: Row(
children: <Widget>[
Text('Shipment Weight', style: TextStyle(fontSize: 15)),
Spacer(),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(bottom: 3.0),
child: Text(
'6',
style:
TextStyle(color: primaryColor, fontSize: 16),
),
),
Text(
'pounds',
style: TextStyle(color: Colors.grey, fontSize: 16),
),
],
),
],
)),
SizedBox(height: 50),
Center(
child: Text(
"Delivery fee:\$ 0",
"Delivery fee:\$ 5",
style: TextStyle(color: primaryColor, fontSize: 16),
)),
SizedBox(height: 20),
Center(
child: Text(
"Total estimated amount:\$ 95",
"Total estimated amount:\$ 41",
style: TextStyle(color: primaryColor, fontSize: 20),
))
],
@@ -106,7 +145,7 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
);
}
_row(String desc, String price, String unit, {bool input}) {
_row(String desc, String price, String unit, String value, {bool input}) {
return Container(
padding: EdgeInsets.only(left: 25, top: 5, bottom: 5),
child: Row(
@@ -134,8 +173,9 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
width: 50,
),
Container(
width: 70,
child: TextField(
width: 150,
child: TextFormField(
initialValue: value,
textAlign: TextAlign.end,
)),
],

View File

@@ -1,6 +1,11 @@
import 'package:fcs/model/pickup_model.dart';
import 'package:fcs/model/shipment_rate_model.dart';
import 'package:fcs/pages_fcs/cargo_editor.dart';
import 'package:fcs/vo/pickup.dart';
import 'package:fcs/vo/rate.dart';
import 'package:fcs/widget/bottom_up_page_route.dart';
import 'package:fcs/widget/local_text.dart';
import 'package:fcs/widget/my_data_table.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
import 'package:fcs/widget/localization/app_translations.dart';
@@ -69,26 +74,88 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
),
body: Container(
padding: EdgeInsets.all(18),
child: ListView(
child: Column(
children: <Widget>[
Container(
height: 190,
child: ListView.builder(
itemCount: shipmentRateModel.rates.length,
itemBuilder: (context, index) {
return fcsInput(
shipmentRateModel.rates[index].description,
Icons.attach_money,
value:
shipmentRateModel.rates[index].price.toString());
}),
Expanded(
child: ListView(
children: <Widget>[
fcsInput("Min Weight for Free delivery within Yangon",
FontAwesomeIcons.weightHanging,
value: "10"),
fcsInput("Delivery fees", Icons.attach_money, value: "5"),
SizedBox(height: 10),
fcsInput("Volumetric Ratio", Icons.attach_money,
value: "166.36"),
SizedBox(height: 10),
ExpansionTile(
title: Text(
'Cargo Types',
style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold),
),
children: <Widget>[
Container(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: MyDataTable(
headingRowHeight: 40,
columnSpacing: 50,
columns: [
MyDataColumn(
label: Text("Cargo Type",
style: TextStyle(
fontSize: 15,
color: Colors.grey[600]))),
MyDataColumn(
label: Text("Rate",
style: TextStyle(
fontSize: 15,
color: Colors.grey[600]))),
MyDataColumn(
label: Text("Delete",
style: TextStyle(
fontSize: 15,
color: Colors.grey[600]))),
],
rows: getCargoRows(shipmentRateModel.rates),
),
),
),
Container(
padding:
EdgeInsets.only(top: 20, bottom: 15, right: 15),
child: Align(
alignment: Alignment.bottomRight,
child: Container(
width: 120,
height: 40,
child: FloatingActionButton.extended(
materialTapTargetSize:
MaterialTapTargetSize.shrinkWrap,
icon: Icon(Icons.add),
onPressed: () {
Navigator.push(
context,
BottomUpPageRoute(CargoEditor()),
);
},
label: Text(
'Add Cargo',
style: TextStyle(fontSize: 12),
),
backgroundColor: primaryColor,
),
),
),
)
],
),
],
),
),
fcsInput("Min Weight for Free delivery within Yangon",
FontAwesomeIcons.weightHanging,
value: "10"),
fcsInput("Delivery fees", Icons.attach_money, value: "5"),
SizedBox(height: 10),
fcsButton(context, "Save", callack: () {}),
fcsButton(context, "Save", callack: () {
Navigator.pop(context);
}),
SizedBox(height: 10)
],
),
@@ -97,6 +164,34 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
);
}
List<MyDataRow> getCargoRows(List<Rate> rates) {
return rates.map((r) {
return MyDataRow(
onSelectChanged: (selected) {
Navigator.push(
context,
BottomUpPageRoute(CargoEditor(rate: r)),
);
},
cells: [
MyDataCell(
new Text(
r.description,
style: textStyle,
),
),
MyDataCell(
new Text(
r.price.toString(),
style: textStyle,
),
),
MyDataCell(IconButton(icon: Icon(Icons.delete), onPressed: null)),
],
);
}).toList();
}
_row(String desc, String price, String unit) {
return Container(
padding: EdgeInsets.only(left: 25, top: 5, bottom: 5),

View File

@@ -85,7 +85,7 @@ class _ShippingAddressEditorState extends State<ShippingAddressEditor> {
children: <Widget>[
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 20.0),
padding: const EdgeInsets.only(left: 10.0,right: 10),
child: ListView(children: <Widget>[
usaAddress,
SizedBox(height: 10),

View File

@@ -50,8 +50,12 @@ class _SplashScreenState extends State<SplashScreen> {
if (_loaded) {
timer.cancel();
if (this._isLogin) {
Navigator.of(context).pushReplacementNamed('/homeLogin');
} else {
Navigator.of(context).pushReplacementNamed('/home');
}
Navigator.of(context).pushReplacementNamed('/home');
// if (_isSupport) {
// if (_isLogin) {
// if (!_isAgree) {