Files
fcs/lib/pages/rates/cargo_editor.dart
Sai Naw Wun 65dda16fe6 clean up
2020-10-07 02:33:06 +06:30

80 lines
2.2 KiB
Dart

import 'package:fcs/domain/entities/rate.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/progress.dart';
import 'package:flutter/material.dart';
class CargoEditor extends StatefulWidget {
final Rate rate;
CargoEditor({this.rate});
@override
_CargoEditorState createState() => _CargoEditorState();
}
class _CargoEditorState extends State<CargoEditor> {
TextEditingController _descController = new TextEditingController();
TextEditingController _rateController = new TextEditingController();
bool _isLoading = false;
Rate _rate = new Rate();
@override
void initState() {
super.initState();
if (widget.rate != null) {
_rate = widget.rate;
_descController.text = _rate.description;
_rateController.text = _rate.price.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("cargo.form.title")),
),
body: Container(
padding: EdgeInsets.all(18),
child: Column(
children: <Widget>[
Expanded(
child: ListView(
children: <Widget>[
fcsInput("Cargo Type", Icons.text_format,
controller: _descController),
fcsInput("Rate", Icons.attach_money,
controller: _rateController),
SizedBox(height: 30),
],
),
),
widget.rate == null
? fcsButton(context, "Create", callack: () {})
: fcsButton(context, "Save", callack: () {}),
SizedBox(height: 10)
],
),
),
),
);
}
}