update processing
This commit is contained in:
@@ -31,12 +31,14 @@ class _CartonSizeEditorState extends State<CartonSizeEditor> {
|
||||
|
||||
bool _isLoading = false;
|
||||
CartonSize _cartonSize;
|
||||
bool _isNew;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.cartonSize != null) {
|
||||
_cartonSize = widget.cartonSize;
|
||||
_isNew = false;
|
||||
_nameController.text = _cartonSize.name;
|
||||
_widthController.text = _cartonSize.width.toString();
|
||||
_heightController.text = _cartonSize.height.toString();
|
||||
@@ -45,6 +47,7 @@ class _CartonSizeEditorState extends State<CartonSizeEditor> {
|
||||
_lengthController.text = "12";
|
||||
_widthController.text = "12";
|
||||
_heightController.text = "12";
|
||||
_isNew = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,9 +107,20 @@ class _CartonSizeEditorState extends State<CartonSizeEditor> {
|
||||
double w = double.parse(_widthController.text, (s) => 0);
|
||||
double h = double.parse(_heightController.text, (s) => 0);
|
||||
|
||||
CartonSize _cartonSize = CartonSize(
|
||||
name: _nameController.text, length: l, width: w, height: h);
|
||||
await cartonSizeModel.addCartonSize(_cartonSize);
|
||||
if (_isNew) {
|
||||
CartonSize _cartonSize = CartonSize(
|
||||
name: _nameController.text, length: l, width: w, height: h);
|
||||
await cartonSizeModel.addCartonSize(_cartonSize);
|
||||
} else {
|
||||
CartonSize _cartonSize = CartonSize(
|
||||
id: widget.cartonSize.id,
|
||||
name: _nameController.text,
|
||||
length: l,
|
||||
width: w,
|
||||
height: h);
|
||||
await cartonSizeModel.updateCartonSize(_cartonSize);
|
||||
}
|
||||
|
||||
Navigator.pop(context);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
|
||||
@@ -29,34 +29,38 @@ class _CartonSizeListState extends State<CartonSizeList> {
|
||||
BuildContext context, List<CartonSize> cartonSizes) {
|
||||
return cartonSizes.map((p) {
|
||||
return new ListTile(
|
||||
onTap: () {
|
||||
Navigator.of(context).push<void>(CupertinoPageRoute(
|
||||
builder: (context) => CartonSizeEditor(cartonSize: p)));
|
||||
},
|
||||
title: new Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
new Text(
|
||||
p.name,
|
||||
style: TextStyle(fontSize: 15.0),
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
new Text(
|
||||
p.name,
|
||||
style: TextStyle(fontSize: 15.0),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: new Text(
|
||||
"(L${p.length}xW${p.width}xH${p.height})",
|
||||
style: new TextStyle(color: Colors.grey),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 15)
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: new Text(
|
||||
"(L${p.length}xW${p.width}xH${p.height})",
|
||||
style: new TextStyle(color: Colors.grey),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 15)
|
||||
],
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
IconButton(
|
||||
icon: Icon(Icons.remove, color: primaryColor),
|
||||
onPressed: () => _remove(p),
|
||||
)
|
||||
],
|
||||
));
|
||||
),
|
||||
Spacer(),
|
||||
IconButton(
|
||||
icon: Icon(Icons.remove, color: primaryColor),
|
||||
onPressed: () => _remove(p),
|
||||
)
|
||||
],
|
||||
));
|
||||
}).toList();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,12 +5,19 @@ import 'package:fcs/domain/entities/carton_size.dart';
|
||||
import 'package:fcs/pages/main/model/base_model.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
const MANAGE_CARTONSIZE = "Manage Carton Size";
|
||||
|
||||
class CartonSizeModel extends BaseModel {
|
||||
List<CartonSize> cartonSizes = [];
|
||||
final log = Logger('CartonSizeModel');
|
||||
|
||||
StreamSubscription<QuerySnapshot> listener;
|
||||
|
||||
List<CartonSize> get getCartonSizes {
|
||||
var _cartonSizes = new List<CartonSize>.from(cartonSizes);
|
||||
return _cartonSizes..insert(0, CartonSize(name: MANAGE_CARTONSIZE));
|
||||
}
|
||||
|
||||
void initUser(user) {
|
||||
super.initUser(user);
|
||||
cartonSizes = [
|
||||
@@ -32,5 +39,7 @@ class CartonSizeModel extends BaseModel {
|
||||
|
||||
Future<void> addCartonSize(CartonSize cartonSize) async {}
|
||||
|
||||
Future<void> updateCartonSize(CartonSize cartonSize) async {}
|
||||
|
||||
Future<void> deleteCartonSize(String id) async {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user