add home screen and shipping addresses

This commit is contained in:
Thinzar Win
2020-06-24 16:06:40 +06:30
parent 752e38edf2
commit 6f6bd20e3e
17 changed files with 698 additions and 169 deletions

View File

@@ -1,3 +1,8 @@
import 'package:fcs/model/shipment_model.dart';
import 'package:fcs/vo/shipping_address.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:flutter/material.dart';
import 'package:package_info/package_info.dart';
import 'package:provider/provider.dart';
@@ -13,6 +18,7 @@ import 'package:fcs/widget/progress.dart';
import '../theme/theme.dart';
import 'profile_setting.dart';
import 'shipping_address_editor.dart';
typedef void ProfileCallback();
@@ -49,7 +55,7 @@ class _ProfileState extends State<Profile> {
var languageModel = Provider.of<LanguageModel>(context);
MainModel mainModel = Provider.of<MainModel>(context);
buildLanguage(languageModel);
// buildLanguage(languageModel);
_selectedDropdown(String selected) {
setState(() {
selectedLanguage = selected;
@@ -58,7 +64,8 @@ class _ProfileState extends State<Profile> {
}
final namebox = Container(
padding: EdgeInsets.only(top: 10),
// padding: EdgeInsets.only(left: 25.0, right: 25.0),
padding: EdgeInsets.only(top: 10, left: 25.0, right: 25.0),
child: Container(
height: 45.0,
child: Row(
@@ -94,8 +101,9 @@ class _ProfileState extends State<Profile> {
],
),
));
final phonenumberbox = Container(
padding: EdgeInsets.only(left: 25.0, right: 25.0),
height: 45.0,
child: Row(
children: <Widget>[
@@ -132,7 +140,7 @@ class _ProfileState extends State<Profile> {
),
);
final emailBox = Container(
padding: EdgeInsets.only(top: 10, left: 0),
padding: EdgeInsets.only(top: 10, left: 25.0, right: 25.0),
child: Row(
children: <Widget>[
Text(
@@ -163,7 +171,7 @@ class _ProfileState extends State<Profile> {
),
);
final languageBox = Container(
padding: EdgeInsets.only(bottom: 15, top: 7),
padding: EdgeInsets.only(bottom: 0, top: 7, left: 25.0, right: 25.0),
child: Container(
height: 45.0,
child: Row(
@@ -223,10 +231,8 @@ class _ProfileState extends State<Profile> {
_isLoading = true;
});
await mainModel.logout();
Navigator.pop(context);
// Navigator.of(context)
// .pushNamedAndRemoveUntil("/", ModalRoute.withName('/'));
Navigator.of(context).pushNamedAndRemoveUntil(
"/home", ModalRoute.withName('/home'));
Future.delayed(Duration(seconds: 1), () {
if (mounted) {
setState(() {
@@ -262,22 +268,17 @@ class _ProfileState extends State<Profile> {
AppTranslations.of(context).text("profile.title"),
),
backgroundColor: primaryColor,
actions: <Widget>[
],
actions: <Widget>[],
),
body: ListView(
padding: EdgeInsets.only(
left: 25.0,
right: 25.0,
),
// 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),
padding: const EdgeInsets.only(left: 18.0),
child: Icon(Icons.edit),
)
],
@@ -290,7 +291,10 @@ class _ProfileState extends State<Profile> {
? Container()
: emailBox,
languageBox,
SizedBox(height: 50,),
getShippingAddressList(context),
SizedBox(
height: 50,
),
logoutbutton,
],
),
@@ -298,6 +302,110 @@ class _ProfileState extends State<Profile> {
);
}
Widget getShippingAddressList(BuildContext context) {
var shipmentModel = Provider.of<ShipmentModel>(context);
return Container(
padding: EdgeInsets.only(top: 5, left: 10),
child: ExpansionTile(
title: Text(
"Shipping Addresses",
style: TextStyle(
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),
),
),
),
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,
onPressed: () {
Navigator.push(
context,
BottomUpPageRoute(ShippingAddressEditor()),
);
},
label: Text(
'Add Shipping\nAddress',
style: TextStyle(fontSize: 12),
),
backgroundColor: primaryColor,
),
),
),
)
],
),
);
}
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,
),
),
MyDataCell(
new Text(
s.phoneNumber,
style: textStyle,
),
),
MyDataCell(IconButton(icon: Icon(Icons.delete), onPressed: null)),
],
);
}).toList();
}
Widget getPrivilegeBox(BuildContext context) {
var languageModel = Provider.of<LanguageModel>(context);
var userModel = Provider.of<UserModel>(context);