Files
fcs/lib/pages/rates/discount_by_weight_editor.dart
2020-10-15 10:53:41 +06:30

88 lines
2.7 KiB
Dart

import 'package:fcs/domain/entities/discount_by_weight.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/widgets/input_text.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class DiscountByWeightEditor extends StatefulWidget {
final DiscountByWeight discountByWeight;
DiscountByWeightEditor({this.discountByWeight});
@override
_DiscountByWeightEditorState createState() => _DiscountByWeightEditorState();
}
class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
TextEditingController _weightController = new TextEditingController();
TextEditingController _rateController = new TextEditingController();
bool _isLoading = false;
DiscountByWeight _discountByWeight = new DiscountByWeight();
@override
void initState() {
super.initState();
if (widget.discountByWeight != null) {
_discountByWeight = widget.discountByWeight;
_weightController.text = _discountByWeight.weight.toString();
_rateController.text = _discountByWeight.discount.toString();
}
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
final weightBox = InputText(
labelTextKey: 'rate.discount.weight',
iconData: FontAwesomeIcons.weightHanging,
controller: _weightController);
final discountRateBox = InputText(
labelTextKey: 'rate.discount.rate',
iconData: Icons.attach_money,
controller: _rateController);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(CupertinoIcons.back),
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>[
weightBox,
discountRateBox,
SizedBox(height: 30),
],
),
),
widget.discountByWeight == null
? fcsButton(context, "Create", callack: () {})
: fcsButton(context, "Save", callack: () {}),
SizedBox(height: 10)
],
),
),
),
);
}
}