update carton and add staff name
This commit is contained in:
128
lib/pages/carton/mix_carton_editor.dart
Normal file
128
lib/pages/carton/mix_carton_editor.dart
Normal file
@@ -0,0 +1,128 @@
|
||||
import 'package:fcs/domain/entities/carton.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/carton_search/carton_search.dart';
|
||||
import 'package:fcs/pages/widgets/local_button.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/local_title.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'carton_row.dart';
|
||||
|
||||
class MixCartonEditor extends StatefulWidget {
|
||||
final Carton box;
|
||||
MixCartonEditor({this.box});
|
||||
|
||||
@override
|
||||
_MixCartonEditorState createState() => _MixCartonEditorState();
|
||||
}
|
||||
|
||||
class _MixCartonEditorState extends State<MixCartonEditor> {
|
||||
Carton _box;
|
||||
bool _isLoading = false;
|
||||
bool _isNew;
|
||||
List<Carton> _cartons = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
if (widget.box != null) {
|
||||
_box = widget.box;
|
||||
_isNew = false;
|
||||
} else {
|
||||
_isNew = true;
|
||||
_box = Carton(cargoTypes: []);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final createBtn = LocalButton(
|
||||
textKey: "box.mix_carton_btn",
|
||||
callBack: _creatCarton,
|
||||
);
|
||||
|
||||
final cargoTableTitleBox = LocalTitle(
|
||||
textKey: "boxes.title",
|
||||
trailing: IconButton(
|
||||
icon: Icon(
|
||||
Icons.add_circle,
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () => searchCarton(context, callbackCartonSelect: (c) {
|
||||
_addMixCarton(c);
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(
|
||||
CupertinoIcons.back,
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
shadowColor: Colors.transparent,
|
||||
backgroundColor: Colors.white,
|
||||
title: LocalText(
|
||||
context,
|
||||
"box.min_caton.form.title",
|
||||
fontSize: 20,
|
||||
color: primaryColor,
|
||||
),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ListView(
|
||||
children: [
|
||||
cargoTableTitleBox,
|
||||
Column(
|
||||
children: _getCartons(
|
||||
context,
|
||||
this._cartons,
|
||||
)),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
createBtn
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _getCartons(BuildContext context, List<Carton> cartons) {
|
||||
return cartons.map((c) {
|
||||
return CartonRow(
|
||||
key: ValueKey(c.id),
|
||||
box: c,
|
||||
onRemove: (carton) {
|
||||
_removeMixCarton(carton);
|
||||
},
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
_addMixCarton(Carton carton) {
|
||||
if (carton == null) return;
|
||||
if (this._cartons.any((c) => c.cartonNumber == carton.cartonNumber)) return;
|
||||
setState(() {
|
||||
this._cartons.add(carton);
|
||||
});
|
||||
}
|
||||
|
||||
_removeMixCarton(Carton carton) {
|
||||
setState(() {
|
||||
this._cartons.remove(carton);
|
||||
});
|
||||
}
|
||||
|
||||
_creatCarton() {}
|
||||
}
|
||||
Reference in New Issue
Block a user