2020-06-26 16:04:40 +06:30
|
|
|
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';
|
|
|
|
|
|
2020-08-30 21:26:37 +06:30
|
|
|
import '../fcs/common/theme.dart';
|
2020-06-26 16:04:40 +06:30
|
|
|
|
|
|
|
|
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(
|
2020-06-30 16:11:58 +06:30
|
|
|
centerTitle: true,
|
2020-06-26 16:04:40 +06:30
|
|
|
title: Text(
|
2020-06-30 16:11:58 +06:30
|
|
|
AppTranslations.of(context).text("discount.form"),
|
|
|
|
|
),
|
|
|
|
|
leading: new IconButton(
|
|
|
|
|
icon: new Icon(Icons.close),
|
|
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
2020-06-26 16:04:40 +06:30
|
|
|
),
|
|
|
|
|
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,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|