82 lines
2.4 KiB
Dart
82 lines
2.4 KiB
Dart
import 'package:fcs/pages/util.dart';
|
|
import 'package:fcs/vo/custom.dart';
|
|
import 'package:fcs/vo/discount.dart';
|
|
import 'package:fcs/widget/localization/app_translations.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:fcs/widget/progress.dart';
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
import '../theme/theme.dart';
|
|
|
|
class DiscountByWeightEditor extends StatefulWidget {
|
|
final Discount discount;
|
|
DiscountByWeightEditor({this.discount});
|
|
|
|
@override
|
|
_DiscountByWeightEditorState createState() => _DiscountByWeightEditorState();
|
|
}
|
|
|
|
class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
|
|
TextEditingController _weightController = new TextEditingController();
|
|
TextEditingController _rateController = new TextEditingController();
|
|
|
|
bool _isLoading = false;
|
|
Discount _discount = new Discount();
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
if (widget.discount != null) {
|
|
_discount = widget.discount;
|
|
_weightController.text = _discount.weight.toString();
|
|
_rateController.text = _discount.discountRate.toString();
|
|
}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext 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("discount.new")),
|
|
),
|
|
body: Container(
|
|
padding: EdgeInsets.all(18),
|
|
child: Column(
|
|
children: <Widget>[
|
|
Expanded(
|
|
child: ListView(
|
|
children: <Widget>[
|
|
fcsInput("Weight", FontAwesomeIcons.weightHanging,
|
|
controller: _weightController),
|
|
fcsInput("Discount Rate", Icons.attach_money,
|
|
controller: _rateController),
|
|
SizedBox(height: 30),
|
|
],
|
|
),
|
|
),
|
|
widget.discount == null
|
|
? fcsButton(context, "Create", callack: () {})
|
|
: fcsButton(context, "Save", callack: () {}),
|
|
SizedBox(height: 10)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|