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

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