2020-05-29 07:45:27 +06:30
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:fcs/model/language_model.dart';
|
2020-09-04 15:30:10 +06:30
|
|
|
import 'package:fcs/fcs/common/helpers/theme.dart';
|
2020-05-29 07:45:27 +06:30
|
|
|
import 'package:fcs/vo/buyer.dart';
|
|
|
|
|
import 'package:fcs/widget/local_text.dart';
|
|
|
|
|
import 'package:fcs/widget/localization/app_translations.dart';
|
|
|
|
|
import 'package:fcs/widget/progress.dart';
|
|
|
|
|
|
|
|
|
|
class QuotaForm extends StatefulWidget {
|
|
|
|
|
final BuyerProduct buyerProduct;
|
|
|
|
|
const QuotaForm({Key key, this.buyerProduct}) : super(key: key);
|
|
|
|
|
@override
|
|
|
|
|
_QuotaFormState createState() => _QuotaFormState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _QuotaFormState extends State<QuotaForm> {
|
|
|
|
|
final _formKey = GlobalKey<FormState>();
|
|
|
|
|
TextEditingController _product = new TextEditingController();
|
|
|
|
|
TextEditingController _storageQty = new TextEditingController();
|
|
|
|
|
TextEditingController _saleQty = new TextEditingController();
|
|
|
|
|
TextEditingController _dailyQuota = new TextEditingController();
|
|
|
|
|
TextEditingController _maxQuota = new TextEditingController();
|
|
|
|
|
|
|
|
|
|
BuyerProduct buyerProduct;
|
|
|
|
|
bool _isLoading = false;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
if (widget.buyerProduct != null) {
|
|
|
|
|
this.buyerProduct = widget.buyerProduct;
|
|
|
|
|
_product.text = widget.buyerProduct.productName;
|
|
|
|
|
_storageQty.text = widget.buyerProduct.storageCapacityQty == null
|
|
|
|
|
? ""
|
|
|
|
|
: widget.buyerProduct.storageCapacityQty.toString();
|
|
|
|
|
_saleQty.text = widget.buyerProduct.dailySaleQty == null
|
|
|
|
|
? ""
|
|
|
|
|
: widget.buyerProduct.dailySaleQty.toString();
|
|
|
|
|
_dailyQuota.text = widget.buyerProduct.dailyQuota == null
|
|
|
|
|
? ""
|
|
|
|
|
: widget.buyerProduct.dailyQuota.toString();
|
|
|
|
|
_maxQuota.text = widget.buyerProduct.maxQuota == null
|
|
|
|
|
? ""
|
|
|
|
|
: widget.buyerProduct.maxQuota.toString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
var language = Provider.of<LanguageModel>(context);
|
|
|
|
|
final productbox = Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 10),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
LocalText(context, "reg.table_product"),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 30,
|
|
|
|
|
),
|
|
|
|
|
Text(_product.text, style: textStyle)
|
|
|
|
|
],
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
final storageQtybox = Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 10),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
LocalText(context, "reg.table_storage_vol"),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 30,
|
|
|
|
|
),
|
|
|
|
|
Text(_storageQty.text, style: textStyle)
|
|
|
|
|
],
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
final saleQtybox = Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 10),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
LocalText(context, "reg.table_sale_vol"),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 25,
|
|
|
|
|
),
|
|
|
|
|
Text(_saleQty.text, style: textStyle)
|
|
|
|
|
],
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
final dailyQuotaBox = Container(
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _dailyQuota,
|
|
|
|
|
autofocus: false,
|
|
|
|
|
cursorColor: primaryColor,
|
|
|
|
|
style: textStyle,
|
|
|
|
|
decoration: new InputDecoration(
|
|
|
|
|
labelText: AppTranslations.of(context).text('buyer.quota'),
|
|
|
|
|
labelStyle: language.isEng ? labelStyle : labelStyleMM,
|
|
|
|
|
icon: Icon(
|
|
|
|
|
FontAwesomeIcons.sortNumericUpAlt,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
),
|
|
|
|
|
enabledBorder: UnderlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: primaryColor, width: 1.0)),
|
|
|
|
|
focusedBorder: UnderlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: primaryColor, width: 1.0)),
|
|
|
|
|
),
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if (value.isEmpty) {
|
|
|
|
|
return "Please enter quota";
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final maxQuotaBox = Container(
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _maxQuota,
|
|
|
|
|
autofocus: false,
|
|
|
|
|
cursorColor: primaryColor,
|
|
|
|
|
style: textStyle,
|
|
|
|
|
decoration: new InputDecoration(
|
|
|
|
|
labelText: AppTranslations.of(context).text('buyer.max.quota'),
|
|
|
|
|
labelStyle: language.isEng ? labelStyle : labelStyleMM,
|
|
|
|
|
icon: Icon(
|
|
|
|
|
FontAwesomeIcons.sortNumericUpAlt,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
),
|
|
|
|
|
enabledBorder: UnderlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: primaryColor, width: 1.0)),
|
|
|
|
|
focusedBorder: UnderlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: primaryColor, width: 1.0)),
|
|
|
|
|
),
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if (value.isEmpty) {
|
|
|
|
|
return "Please enter quota";
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return LocalProgress(
|
|
|
|
|
inAsyncCall: _isLoading,
|
|
|
|
|
child: Scaffold(
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
backgroundColor: primaryColor,
|
|
|
|
|
title: Text("Quota"),
|
|
|
|
|
actions: <Widget>[
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: Icon(Icons.save),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
if (!_formKey.currentState.validate()) return;
|
|
|
|
|
buyerProduct.dailyQuota = int.parse(_dailyQuota.text);
|
|
|
|
|
buyerProduct.maxQuota = int.parse(_maxQuota.text);
|
|
|
|
|
Navigator.pop(context, buyerProduct);
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
body: Form(
|
|
|
|
|
key: _formKey,
|
|
|
|
|
child: Container(
|
|
|
|
|
child: ListView(
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
padding: EdgeInsets.only(left: 24.0, right: 24.0),
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
productbox,
|
|
|
|
|
storageQtybox,
|
|
|
|
|
saleQtybox,
|
|
|
|
|
dailyQuotaBox,
|
|
|
|
|
maxQuotaBox
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|