add discount api

This commit is contained in:
Sai Naw Wun
2020-10-15 10:53:41 +06:30
parent 47c07a6c88
commit 37289e42c0
7 changed files with 122 additions and 64 deletions

View File

@@ -1,4 +1,4 @@
import 'package:fcs/domain/entities/discount.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';
@@ -9,8 +9,8 @@ import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class DiscountByWeightEditor extends StatefulWidget {
final Discount discount;
DiscountByWeightEditor({this.discount});
final DiscountByWeight discountByWeight;
DiscountByWeightEditor({this.discountByWeight});
@override
_DiscountByWeightEditorState createState() => _DiscountByWeightEditorState();
@@ -21,15 +21,15 @@ class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
TextEditingController _rateController = new TextEditingController();
bool _isLoading = false;
Discount _discount = new Discount();
DiscountByWeight _discountByWeight = new DiscountByWeight();
@override
void initState() {
super.initState();
if (widget.discount != null) {
_discount = widget.discount;
_weightController.text = _discount.weight.toString();
_rateController.text = _discount.discountRate.toString();
if (widget.discountByWeight != null) {
_discountByWeight = widget.discountByWeight;
_weightController.text = _discountByWeight.weight.toString();
_rateController.text = _discountByWeight.discount.toString();
}
}
@@ -74,7 +74,7 @@ class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
],
),
),
widget.discount == null
widget.discountByWeight == null
? fcsButton(context, "Create", callack: () {})
: fcsButton(context, "Save", callack: () {}),
SizedBox(height: 10)