Files
fcs/lib/pages/rates/custom_editor.dart

89 lines
2.5 KiB
Dart
Raw Normal View History

2020-10-07 02:33:06 +06:30
import 'package:fcs/domain/entities/custom.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/main/util.dart';
2020-10-07 18:49:28 +06:30
import 'package:fcs/pages/widgets/input_text.dart';
2020-10-07 02:33:06 +06:30
import 'package:fcs/pages/widgets/progress.dart';
2020-06-29 16:15:25 +06:30
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class CustomEditor extends StatefulWidget {
final Custom custom;
CustomEditor({this.custom});
@override
_CustomEditorState createState() => _CustomEditorState();
}
class _CustomEditorState extends State<CustomEditor> {
TextEditingController _productController = new TextEditingController();
TextEditingController _feeController = new TextEditingController();
bool _isLoading = false;
Custom _custom = new Custom();
@override
void initState() {
super.initState();
if (widget.custom != null) {
_custom = widget.custom;
_productController.text = _custom.productType;
_feeController.text = _custom.fee.toString();
}
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
2020-10-07 18:49:28 +06:30
final productBox = InputText(
labelTextKey: 'rate.cutom.product_type',
iconData: FontAwesomeIcons.weightHanging,
controller: _productController);
final feeBox = InputText(
labelTextKey: 'rate.custom.fee',
iconData: Icons.attach_money,
controller: _feeController);
2020-06-29 16:15:25 +06:30
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,
2020-10-07 18:49:28 +06:30
title:
Text(AppTranslations.of(context).text("rate.custom.form.title")),
2020-06-29 16:15:25 +06:30
),
body: Container(
padding: EdgeInsets.all(18),
child: Column(
children: <Widget>[
Expanded(
child: ListView(
children: <Widget>[
2020-10-07 18:49:28 +06:30
productBox,
feeBox,
2020-06-29 16:15:25 +06:30
SizedBox(height: 30),
],
),
),
widget.custom == null
? fcsButton(context, "Create", callack: () {})
: fcsButton(context, "Save", callack: () {}),
SizedBox(height: 10)
],
),
),
),
);
}
}