modify ui

This commit is contained in:
PhyoThandar
2020-06-26 16:04:40 +06:30
parent 59cb172713
commit e8d5f24a99
18 changed files with 1238 additions and 189 deletions

View File

@@ -0,0 +1,108 @@
import 'package:fcs/model_fcs/box_model.dart';
import 'package:fcs/model_fcs/package_model.dart';
import 'package:fcs/theme/theme.dart';
import 'package:fcs/vo/box.dart';
import 'package:fcs/widget/localization/app_translations.dart';
import 'package:fcs/widget/progress.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class BoxAddition extends StatefulWidget {
final Box box;
BoxAddition({this.box});
@override
_BoxAdditionState createState() => _BoxAdditionState();
}
class _BoxAdditionState extends State<BoxAddition> {
Box _box = new Box();
bool _isLoading = false;
@override
void initState() {
super.initState();
if (widget.box != null) {
_box = widget.box;
}
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
var boxModel = Provider.of<BoxModel>(context);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
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>[
Expanded(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: ListView(children: <Widget>[
DropdownButtonFormField(
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Box Number',
icon: Icon(Icons.pages)),
items: boxModel.processed
.map((e) => DropdownMenuItem(
child: Text('${e.shipmentNumber}-${e.receiverNumber} #${e.boxNumber}'), value: e))
.toList(),
onChanged: (map) => {},
),
]),
)),
widget.box == null
? Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Add box'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
)))
: Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Save box'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
))),
SizedBox(
height: 30,
)
],
),
),
),
);
}
}

View File

@@ -1,6 +1,10 @@
import 'package:fcs/model/discount_model.dart';
import 'package:fcs/model/main_model.dart';
import 'package:fcs/model_fcs/box_model.dart';
import 'package:fcs/pages/invoice/package_addition.dart';
import 'package:fcs/theme/theme.dart';
import 'package:fcs/vo/box.dart';
import 'package:fcs/vo/cargo.dart';
import 'package:fcs/vo/invoice.dart';
import 'package:fcs/vo/package.dart';
import 'package:fcs/widget/bottom_up_page_route.dart';
@@ -17,6 +21,7 @@ import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import '../util.dart';
import 'box_addition.dart';
class InvoiceEditor extends StatefulWidget {
final Invoice invoice;
@@ -39,7 +44,9 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
Invoice _invoice;
bool _isLoading = false;
List<Package> _packages = [];
List<Box> _boxes = [];
bool isSwitched = false;
String deliveryfee = '\$0';
@override
void initState() {
@@ -52,32 +59,55 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
_phoneController.text = _invoice.customerPhoneNumber;
_amountController.text = _invoice.getAmount.toString();
_statusController.text = _invoice.status.toString();
_packages = _invoice.packages;
} else {
_packages = [
Package(
// _boxes = _invoice.packages;
} else {}
_boxes = [
Box(
shipmentNumber: "A202",
receiverNumber: "3",
receiverName: "Ko Myo Min",
boxNumber: "1",
rate: 7,
packageType: "General",
weight: 25,
status: "Received",
weight: 75,
status: "Packed",
receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon',
cargoDesc: "Clothes",
arrivedDate: DateTime(2020, 6, 1),
),
Package(
shipmentNumber: "A202",
receiverNumber: "3",
boxNumber: "2",
rate: 7,
packageType: "General",
weight: 20,
status: "Received",
arrivedDate: DateTime(2020, 6, 1),
receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon'),
];
}
width: 10,
height: 10,
length: 10,
// packages: packages,
// statusHistory: statusHistory,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
Box(
shipmentNumber: "A202",
receiverNumber: "3",
receiverName: "Ko Myo Min",
boxNumber: "2",
rate: 7,
packageType: "General",
weight: 75,
status: "Packed",
cargoDesc: "Clothes",
arrivedDate: DateTime(2020, 6, 1),
width: 10,
height: 10,
length: 10,
// statusHistory: statusHistory,
// packages: packages,
receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon',
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
])
];
}
@override
@@ -88,6 +118,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
@override
Widget build(BuildContext context) {
var mainModel = Provider.of<MainModel>(context);
var discountModel = Provider.of<DiscountModel>(context);
return LocalProgress(
inAsyncCall: _isLoading,
@@ -170,8 +201,8 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Customer Name',
labelStyle:
TextStyle(fontSize: 16, color: primaryColor),
labelStyle: TextStyle(
fontSize: 16, color: primaryColor),
filled: true,
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
@@ -199,31 +230,131 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
// color: Colors.grey,
// ),
// )),
Container(
padding: EdgeInsets.only(top: 0),
child: fcsInput('Amount', FontAwesomeIcons.moneyBill,
controller: _amountController),
),
Container(
padding: EdgeInsets.only(top: 5),
child: fcsInput('Discount', FontAwesomeIcons.tag,
controller: _discountController),
),
// Container(
// padding: EdgeInsets.only(top: 0),
// child: fcsInput('Amount', FontAwesomeIcons.moneyBill,
// controller: _amountController),
// ),
widget.invoice == null
? Container()
: Container(
padding: EdgeInsets.only(top: 0),
child: TextFormField(
controller: _amountController,
readOnly: true,
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Amount',
labelStyle: TextStyle(
fontSize: 16, color: primaryColor),
filled: true,
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
icon: Icon(
FontAwesomeIcons.moneyBill,
color: primaryColor,
),
)),
),
widget.invoice == null
? Container()
: Container(
padding: EdgeInsets.only(top: 5),
child: TextFormField(
controller: _statusController,
readOnly: true,
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Status',
labelStyle: TextStyle(
fontSize: 16, color: primaryColor),
filled: true,
icon: Icon(Icons.av_timer,color: primaryColor,),
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
icon: Icon(
Icons.av_timer,
color: primaryColor,
),
)),
),
Container(
padding: EdgeInsets.only(top: 20, left: 18),
child: Row(
children: <Widget>[
Expanded(
child: Text('Discounts',
style: TextStyle(fontSize: 16))),
Container(
width: 150.0,
child: DropdownButtonFormField(
items: discountModel.discounts
.map((e) => DropdownMenuItem(
child: Text(e.code), value: e.code))
.toList(),
onChanged: (selected) => {},
),
),
],
),
),
Container(
padding: EdgeInsets.only(top: 5, left: 18),
child: Row(
children: <Widget>[
Expanded(
child: Text('Payment Method',
style: TextStyle(fontSize: 16))),
Container(
width: 150.0,
child: DropdownButtonFormField(
items: mainModel.paymentMethods
.map((e) => DropdownMenuItem(
child: Text(e.name), value: e.name))
.toList(),
onChanged: (selected) => {},
),
),
],
),
),
Container(
padding: EdgeInsets.only(top: 5),
child: Row(
children: <Widget>[
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 18.0),
child: Text(
'Delivery fee:',
style: TextStyle(fontSize: 16),
),
)),
Switch(
value: isSwitched,
onChanged: (value) {
setState(() {
isSwitched = value;
if (value) {
deliveryfee = '\$5';
} else {
deliveryfee = '\$0';
}
print(isSwitched);
});
},
activeTrackColor: primaryColor.withOpacity(0.8),
activeColor: primaryColor,
),
Text('(Delivery fee : $deliveryfee)',style: TextStyle(color: primaryColor,fontWeight: FontWeight.bold),),
],
),
),
SizedBox(
height: 20,
height: 10,
),
ExpansionTile(
title: Text('Payment Attachment'),
@@ -249,7 +380,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
],
),
ExpansionTile(
title: Text('Package Information'),
title: Text('Box Information'),
children: <Widget>[
Container(
child: SingleChildScrollView(
@@ -261,55 +392,63 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
MyDataColumn(
label: LocalText(
context,
"package.number",
"box.number",
color: Colors.grey,
),
),
MyDataColumn(
label: LocalText(
context,
"package.rate",
"box.length",
color: Colors.grey,
),
),
MyDataColumn(
label: LocalText(
context,
"package.weight",
"box.width",
color: Colors.grey,
),
),
MyDataColumn(
label: LocalText(
context,
"package.amount",
"box.height",
color: Colors.grey,
),
),
],
rows: getPackageRow(context),
rows: getBoxRow(context),
),
),
),
mainModel.isOwner()?Container(
padding: EdgeInsets.only(top: 20),
child: Align(
alignment: Alignment.bottomRight,
child: FloatingActionButton.extended(
icon: Icon(Icons.add),
label: Text(AppTranslations.of(context)
.text("invoice.add_package")),
backgroundColor: primaryColor,
onPressed: () {
Navigator.of(context)
.push(BottomUpPageRoute(PackageAddition()));
},
),
),
):Container(),
mainModel.isOwner()
? Container(
padding: EdgeInsets.only(top: 20),
child: Align(
alignment: Alignment.bottomRight,
child: FloatingActionButton.extended(
icon: Icon(Icons.add),
label: Text(AppTranslations.of(context)
.text("invoice.add_box")),
backgroundColor: primaryColor,
onPressed: () {
Navigator.of(context)
.push(BottomUpPageRoute(BoxAddition()));
},
),
),
)
: Container(),
SizedBox(height: 25),
],
),
//Cargo Table
ExpansionTile(
title: Text('Cargo Table'),
children: getCargoTableByBox(context),
),
]),
)),
widget.invoice == null
@@ -327,25 +466,27 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
},
),
)))
:mainModel.isCustomer()?Container():Container(
child: Column(
children: <Widget>[
Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Save invoice'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
))),
],
)),
: mainModel.isCustomer()
? Container()
: Container(
child: Column(
children: <Widget>[
Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Save invoice'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
))),
],
)),
widget.invoice == null
? Container()
: Align(
@@ -369,25 +510,120 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
);
}
List<MyDataRow> getPackageRow(BuildContext context) {
return _packages.map((p) {
getCargoTableByBox(BuildContext context) {
return _boxes.map((b) {
return Padding(
padding: const EdgeInsets.all(5.0),
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey[100],
width: 1,
),
),
child: Row(
children: <Widget>[
Expanded(
child: Container(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: MyDataTable(
headingRowHeight: 40,
columnSpacing: 20,
columns: [
MyDataColumn(
label: LocalText(
context,
"cargo.type",
color: Colors.grey,
),
),
MyDataColumn(
label: LocalText(
context,
"cargo.weight",
color: Colors.grey,
),
),
MyDataColumn(
label: LocalText(
context,
"cargo.rate",
color: Colors.grey,
),
),
MyDataColumn(
label: LocalText(
context,
"cargo.amount",
color: Colors.grey,
),
),
],
rows: getCargoDataRow(context, b),
),
),
),
)
],
),
),
);
}).toList();
}
List<MyDataRow> getBoxRow(BuildContext context) {
return _boxes.map((p) {
return MyDataRow(
onSelectChanged: (bool selected) {},
cells: [
MyDataCell(new Text(
p.packageNumber == null ? "" : p.packageNumber,
p.boxNumber == null
? ""
: '${p.shipmentNumber}-${p.receiverNumber} #${p.boxNumber}',
style: textStyle,
)),
MyDataCell(new Text(
p.length == null ? "" : p.length.toString(),
style: textStyle,
)),
MyDataCell(new Text(
p.width == null ? "" : p.width.toString(),
style: textStyle,
)),
MyDataCell(new Text(
p.height == null ? "" : p.height.toString(),
style: textStyle,
)),
],
);
}).toList();
}
List<MyDataRow> getCargoDataRow(BuildContext context, Box box) {
var rate = 5;
return box.cargoTypes.map((p) {
rate++;
var amt = p.weight * rate;
return MyDataRow(
onSelectChanged: (bool selected) {},
cells: [
MyDataCell(new Text(
p.type,
style: textStyle,
)),
MyDataCell(new Text(
p.weight.toString(),
style: textStyle,
)),
MyDataCell(new Text(
'\$${rate}',
style: textStyle,
)),
MyDataCell(new Text(
"\$$amt",
style: textStyle,
)),
MyDataCell(
new Text(p.rate.toString(), style: textStyle),
),
MyDataCell(
new Text("${p.weight.toString()} lb", style: textStyle),
),
MyDataCell(
new Text(p.price == null ? "" : "\$ " + p.price.toString(),
style: textStyle),
),
],
);
}).toList();