86 lines
2.4 KiB
Dart
86 lines
2.4 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/input_text.dart';
|
|
import 'package:fcs/pages/widgets/progress.dart';
|
|
import 'package:flutter/cupertino.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) {
|
|
final typeBox = InputText(
|
|
labelTextKey: 'cargo.type',
|
|
iconData: Icons.text_format,
|
|
controller: _descController);
|
|
final rateBox = InputText(
|
|
labelTextKey: 'cargo.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("cargo.form.title")),
|
|
),
|
|
body: Container(
|
|
padding: EdgeInsets.all(18),
|
|
child: Column(
|
|
children: <Widget>[
|
|
Expanded(
|
|
child: ListView(
|
|
children: <Widget>[
|
|
typeBox,
|
|
rateBox,
|
|
SizedBox(height: 30),
|
|
],
|
|
),
|
|
),
|
|
widget.rate == null
|
|
? fcsButton(context, "Create", callack: () {})
|
|
: fcsButton(context, "Save", callack: () {}),
|
|
SizedBox(height: 10)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|