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,133 @@
import 'package:fcs/model/discount_model.dart';
import 'package:fcs/pages/util.dart';
import 'package:fcs/vo/discount.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
import 'package:fcs/widget/localization/app_translations.dart';
import 'package:fcs/widget/progress.dart';
import '../theme/theme.dart';
class DiscountEditor extends StatefulWidget {
final Discount discount;
const DiscountEditor({Key key, this.discount}) : super(key: key);
@override
_DiscountEditorState createState() => _DiscountEditorState();
}
class _DiscountEditorState extends State<DiscountEditor> {
bool _isLoading = false;
Discount _discount = new Discount();
TextEditingController _codeController = new TextEditingController();
TextEditingController _amountController = new TextEditingController();
TextEditingController _statusController = new TextEditingController();
TextEditingController _customerController = new TextEditingController();
bool isNew = false;
@override
void initState() {
super.initState();
if (widget.discount != null) {
_discount = widget.discount;
_codeController.text = _discount.code;
_amountController.text = _discount.amount.toString();
_statusController.text = _discount.status;
_customerController.text = 'Ko Nyi';
} else {
isNew = true;
_customerController.text = '';
}
}
@override
Widget build(BuildContext context) {
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: Text(
AppTranslations.of(context).text("discount.new"),
),
backgroundColor: primaryColor,
actions: <Widget>[],
),
body: Padding(
padding: const EdgeInsets.only(left: 20.0),
child: Column(
children: <Widget>[
Expanded(
child: ListView(
children: <Widget>[
fcsInput('Code', FontAwesomeIcons.algolia,
controller: _codeController),
fcsInput('Customer Name', Feather.user,
controller: _customerController),
fcsInput('Amount', FontAwesomeIcons.moneyBill,
controller: _amountController),
widget.discount == 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,
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
icon: Icon(
Icons.av_timer,
color: primaryColor,
),
)),
),
],
),
),
widget.discount == null
? Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Add Discount'),
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

@@ -0,0 +1,122 @@
import 'package:fcs/model/discount_model.dart';
import 'package:fcs/pages/discount_editor.dart';
import 'package:fcs/pages/util.dart';
import 'package:fcs/widget/bottom_up_page_route.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:fcs/widget/localization/app_translations.dart';
import 'package:fcs/widget/progress.dart';
import '../theme/theme.dart';
class DiscountList extends StatefulWidget {
@override
_DiscountListState createState() => _DiscountListState();
}
class _DiscountListState extends State<DiscountList> {
bool _isLoading = false;
@override
Widget build(BuildContext context) {
var discountModel = Provider.of<DiscountModel>(context);
print('discounts => ${discountModel.discounts}');
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
title: Text(
AppTranslations.of(context).text("discount.title"),
),
backgroundColor: primaryColor,
actions: <Widget>[
IconButton(
icon: Icon(Icons.search),
onPressed: () {},
)
],
),
body: ListView.separated(
separatorBuilder: (context, index) => Divider(
color: Colors.black,
),
itemCount: discountModel.discounts.length,
itemBuilder: (BuildContext context, int index) {
var discount = discountModel.discounts[index];
return InkWell(
onTap: () {
Navigator.push(
context,
BottomUpPageRoute(DiscountEditor(
discount: discount,
)),
);
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
discount.code,
style: TextStyle(
color: primaryColor,
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
Row(
children: <Widget>[
Text(
discount.customer,
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.normal,
fontSize: 15),
),
],
),
],
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
getStatus(discount.status),
Padding(
padding: const EdgeInsets.only(left: 10.0),
child: Text(
'\$${discount.amount.toString()}',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.normal,
fontSize: 15),
),
),
],
),
],
),
),
);
},
),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
Navigator.push(
context,
BottomUpPageRoute(DiscountEditor()),
);
},
icon: Icon(Icons.add),
label: Text(AppTranslations.of(context).text("discount.new")),
backgroundColor: primaryColor,
),
),
);
}
}

View File

@@ -1,5 +1,7 @@
import 'package:country_code_picker/country_code.dart';
import 'package:fcs/model/main_model.dart';
import 'package:fcs/pages/discount_list.dart';
import 'package:fcs/pages/payment_method_page.dart';
import 'package:fcs/pages/shipment_list.dart';
import 'package:fcs/pages_fcs/box_list.dart';
import 'package:fcs/pages_fcs/package_list.dart';
@@ -174,6 +176,16 @@ class _HomePageState extends State<HomePage> {
btnCallback: () =>
Navigator.of(context).push(BottomUpPageRoute(InvoiceList())));
final paymentMethodBtn = _buildBtn2("payment.method.btn",
icon: FontAwesomeIcons.creditCard,
btnCallback: () =>
Navigator.of(context).push(BottomUpPageRoute(PaymentMethodPage())));
final discountBtn = _buildBtn2("discount.btn",
icon: FontAwesomeIcons.percent,
btnCallback: () =>
Navigator.of(context).push(BottomUpPageRoute(DiscountList())));
final termBtn = _buildBtn2("term.btn",
icon: FontAwesomeIcons.info,
btnCallback: () =>
@@ -191,6 +203,8 @@ class _HomePageState extends State<HomePage> {
customer || owner ? widgets.add(boxesBtn) : "";
owner ? widgets.add(customersBtn) : "";
customer || owner ? widgets.add(invoicesBtn) : "";
customer || owner ? widgets.add(paymentMethodBtn) : "";
customer || owner ? widgets.add(discountBtn) : "";
widgets.add(termBtn);
return OfflineRedirect(
@@ -318,7 +332,8 @@ class _HomePageState extends State<HomePage> {
children: <Widget>[
// _buildSmallButton(
// "Policies", FontAwesomeIcons.fileContract),
_buildSmallButton("Contact Us", SimpleLineIcons.support),
_buildSmallButton(
"Contact Us", SimpleLineIcons.support),
],
)
],

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

View File

@@ -0,0 +1,120 @@
import 'package:fcs/model/discount_model.dart';
import 'package:fcs/pages/util.dart';
import 'package:fcs/vo/discount.dart';
import 'package:fcs/vo/payment_method.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
import 'package:fcs/widget/localization/app_translations.dart';
import 'package:fcs/widget/progress.dart';
import '../theme/theme.dart';
class PaymentMethodEditor extends StatefulWidget {
final PaymentMethod paymentMethod;
const PaymentMethodEditor({Key key, this.paymentMethod}) : super(key: key);
@override
_PaymentMethodEditorState createState() => _PaymentMethodEditorState();
}
class _PaymentMethodEditorState extends State<PaymentMethodEditor> {
bool _isLoading = false;
PaymentMethod _paymentMethod = new PaymentMethod();
TextEditingController _nameController = new TextEditingController();
TextEditingController _accountNameController = new TextEditingController();
TextEditingController _accountNumberController = new TextEditingController();
TextEditingController _mailController = new TextEditingController();
TextEditingController _phoneController = new TextEditingController();
bool isNew = false;
@override
void initState() {
super.initState();
if (widget.paymentMethod != null) {
_paymentMethod = widget.paymentMethod;
_nameController.text = _paymentMethod.name;
_accountNameController.text = _paymentMethod.accountName;
_accountNumberController.text = _paymentMethod.account;
_mailController.text = _paymentMethod.mail;
_phoneController.text = _paymentMethod.phone;
} else {
isNew = true;
_nameController.text = '';
}
}
@override
Widget build(BuildContext context) {
var discountModel = Provider.of<DiscountModel>(context);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: Text(
AppTranslations.of(context).text("payment.method.new"),
),
backgroundColor: primaryColor,
actions: <Widget>[],
),
body: Padding(
padding: const EdgeInsets.only(left: 20.0),
child: Column(
children: <Widget>[
Expanded(
child: ListView(
children: <Widget>[
fcsInput('Name', FontAwesomeIcons.algolia,
controller: _nameController),
fcsInput('Account Name', Feather.user,
controller: _accountNameController),
fcsInput('Account Number', FontAwesomeIcons.moneyBill,
controller: _accountNumberController),
fcsInput('E-mail', Icons.mail,
controller: _mailController),
fcsInput('Phone', Icons.phone,
controller: _phoneController)
],
),
),
widget.paymentMethod == null
? Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Add Payment Method'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
)))
: Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Save Payment Method'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
))),
SizedBox(
height: 30,
)
],
),
)),
);
}
}

View File

@@ -0,0 +1,169 @@
import 'package:fcs/pages/payment_editor.dart';
import 'package:fcs/widget/bottom_up_page_route.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:fcs/model/main_model.dart';
import 'package:fcs/widget/localization/app_translations.dart';
import 'package:fcs/widget/progress.dart';
import '../theme/theme.dart';
class PaymentMethodPage extends StatefulWidget {
@override
_PaymentMethodPageState createState() => _PaymentMethodPageState();
}
class _PaymentMethodPageState extends State<PaymentMethodPage> {
bool _isLoading = false;
@override
Widget build(BuildContext context) {
MainModel mainModel = Provider.of<MainModel>(context);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
title: Text(
AppTranslations.of(context).text("payment.method.title"),
),
backgroundColor: primaryColor,
actions: <Widget>[],
),
body: ListView.separated(
separatorBuilder: (context, index) => Divider(
color: Colors.black,
),
itemCount: mainModel.paymentMethods.length,
itemBuilder: (BuildContext context, int index) {
var method = mainModel.paymentMethods[index];
return InkWell(
onTap: () {
Navigator.push(
context,
BottomUpPageRoute(PaymentMethodEditor(
paymentMethod: method,
)),
);
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
method.name,
style: TextStyle(
color: primaryColor,
fontWeight: FontWeight.bold,
fontSize: 18),
),
Padding(
padding: const EdgeInsets.only(left: 8.0, top: 8.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// Text(
// 'Account Name: ',
// style: TextStyle(
// color: Colors.black,
// fontWeight: FontWeight.normal,
// fontSize: 15),
// ),
Text(
method.accountName,
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.normal,
fontSize: 15),
),
],
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0, top: 8.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// Text(
// 'Account Number: ',
// style: TextStyle(
// color: Colors.black,
// fontWeight: FontWeight.normal,
// fontSize: 15),
// ),
Text(
method.account,
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.normal,
fontSize: 15),
),
],
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0, top: 8.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// Text(
// 'Email: ',
// style: TextStyle(
// color: Colors.black,
// fontWeight: FontWeight.normal,
// fontSize: 15),
// ),
Text(
method.mail,
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.normal,
fontSize: 15),
),
],
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0, top: 8.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// Text(
// 'Phone: ',
// style: TextStyle(
// color: Colors.black,
// fontWeight: FontWeight.normal,
// fontSize: 15),
// ),
Text(
method.phone,
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.normal,
fontSize: 15),
),
],
),
),
],
),
),
);
},
),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
Navigator.push(
context,
BottomUpPageRoute(PaymentMethodEditor()),
);
},
icon: Icon(Icons.add),
label: Text(AppTranslations.of(context).text("discount.new")),
backgroundColor: primaryColor,
),
),
);
}
}

View File

@@ -268,36 +268,44 @@ Widget getStatus(String status) {
fontSize: 18,
fontWeight: FontWeight.bold),
)
: status == "Delivered"
: status == "Delivered" || status == "Avaliable"
? Text(
status,
style: TextStyle(
color: Colors.green, fontSize: 12),
color: Colors.green, fontSize: 18),
)
: status == "Paid"
? Row(
children: <Widget>[
Padding(
padding:
const EdgeInsets.all(8.0),
child: Icon(Icons.check),
),
Text(
: status == "Used"
? Text(
status,
style: TextStyle(
color: Colors.red,
fontSize: 18),
)
: status == "Paid"
? Row(
children: <Widget>[
Padding(
padding:
const EdgeInsets.all(8.0),
child: Icon(Icons.check),
),
Text(
status,
style: TextStyle(
color: primaryColor,
fontSize: 18,
fontWeight:
FontWeight.bold),
)
],
)
: Text(
status,
style: TextStyle(
color: primaryColor,
fontSize: 18,
fontWeight: FontWeight.bold),
)
],
)
: Text(
status,
style: TextStyle(
color: primaryColor,
fontSize: 18,
fontWeight: FontWeight.bold),
);
);
}
call(BuildContext context, String phone) {
@@ -381,7 +389,7 @@ Widget nameWidget(String name) {
child: Text(
name,
style: TextStyle(
color: Colors.black87, fontSize: 18, fontWeight: FontWeight.bold),
color: Colors.black87, fontSize: 18, fontWeight: FontWeight.bold),
),
),
);