update carton list and editor
This commit is contained in:
178
lib/pages/carton/mix_cation/mix_cartion_editor.dart
Normal file
178
lib/pages/carton/mix_cation/mix_cartion_editor.dart
Normal file
@@ -0,0 +1,178 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../../../domain/vo/local_step.dart';
|
||||
import '../../../helpers/theme.dart';
|
||||
import '../../widgets/local_text.dart';
|
||||
import '../../widgets/progress.dart';
|
||||
import '../../widgets/step_widget.dart';
|
||||
import 'type_widget.dart';
|
||||
|
||||
class MixCartonEditor extends StatefulWidget {
|
||||
const MixCartonEditor({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<MixCartonEditor> createState() => _MixCartonEditorState();
|
||||
}
|
||||
|
||||
class _MixCartonEditorState extends State<MixCartonEditor> {
|
||||
var dateFormatter = DateFormat('dd MMM yyyy');
|
||||
final NumberFormat numberFormatter = NumberFormat("#,###");
|
||||
List<LocalStep> steps = [
|
||||
LocalStep(lable: 'Type', stepType: StepType.TYPE),
|
||||
LocalStep(lable: 'Cartons', stepType: StepType.CARTONS),
|
||||
LocalStep(lable: 'Submit', stepType: StepType.SUBMIT)
|
||||
];
|
||||
|
||||
bool _isLoading = false;
|
||||
int currentStep = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () {
|
||||
if (currentStep == 0) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
if (currentStep > 0) {
|
||||
setState(() {
|
||||
currentStep -= 1;
|
||||
});
|
||||
}
|
||||
|
||||
return Future.value(false);
|
||||
},
|
||||
child: LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
leading: IconButton(
|
||||
icon: const Icon(CupertinoIcons.back,
|
||||
color: primaryColor, size: 25),
|
||||
onPressed: () {
|
||||
if (currentStep == 0) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
if (currentStep > 0) {
|
||||
setState(() {
|
||||
currentStep -= 1;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
backgroundColor: Colors.white,
|
||||
title: LocalText(context, 'boxes.new',
|
||||
color: primaryColor, fontSize: 20),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
StepperWidget(
|
||||
labels: steps.map((e) => e.lable).toList(),
|
||||
currentStep: currentStep,
|
||||
eachStepWidth: 120,
|
||||
onChange: (index) {
|
||||
if (index > currentStep) {
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
currentStep = index;
|
||||
});
|
||||
},
|
||||
),
|
||||
getContent(currentStep)
|
||||
],
|
||||
))),
|
||||
);
|
||||
}
|
||||
|
||||
Widget getContent(int index) {
|
||||
var step = steps[index];
|
||||
if (step.stepType == StepType.TYPE) {
|
||||
return Expanded(child: TypeWidget(
|
||||
onPrevious: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
// warehouse: _warehouse,
|
||||
// onSelectWarehouse: (w) {
|
||||
// setState(() {
|
||||
// _warehouse = w;
|
||||
// currentStep += 1;
|
||||
// });
|
||||
// },
|
||||
));
|
||||
} else if (step.stepType == StepType.CARTONS) {
|
||||
return Expanded(
|
||||
child: Text("cartons"),
|
||||
// child: StockAdjustmentProducts(
|
||||
// products: products,
|
||||
// onAdd: (ps) {
|
||||
// setState(() {
|
||||
// products = List.from(ps);
|
||||
// });
|
||||
// },
|
||||
// onRemove: (p) {
|
||||
// setState(() {
|
||||
// products.removeWhere((e) => e.id == p.id);
|
||||
// });
|
||||
// },
|
||||
// onRemoveAll: (ps) {
|
||||
// for (var e in ps) {
|
||||
// setState(() {
|
||||
// products.removeWhere((p) => p.id == e.id);
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// onContinue: (ps) {
|
||||
// if (products.isEmpty) {
|
||||
// showMsgDialog(context, 'Error', "Please select product");
|
||||
// return false;
|
||||
// }
|
||||
// setState(() {
|
||||
// products = List.from(ps);
|
||||
// currentStep += 1;
|
||||
// });
|
||||
// },
|
||||
// onPrevious: (ps) {
|
||||
// setState(() {
|
||||
// products = List.from(ps);
|
||||
// currentStep -= 1;
|
||||
// });
|
||||
// },
|
||||
// ),
|
||||
);
|
||||
} else {
|
||||
return Expanded(
|
||||
child: Text("Submit"),
|
||||
// child: StockAdjustmentSubmit(
|
||||
// warehouse: _warehouse?.name,
|
||||
// products: products,
|
||||
// onCreate: () {
|
||||
// if (user != null && user.hasInventoryCreate()) {
|
||||
// showConfirmDialog(context, 'stock_adjustment_confirm', _create);
|
||||
// } else {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (BuildContext context) => const AuthorizedDialog(
|
||||
// uiFunction: funcInventoriesCreate));
|
||||
// }
|
||||
// },
|
||||
// onPrevious: () {
|
||||
// setState(() {
|
||||
// currentStep -= 1;
|
||||
// });
|
||||
// },
|
||||
// ),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
246
lib/pages/carton/mix_cation/type_widget.dart
Normal file
246
lib/pages/carton/mix_cation/type_widget.dart
Normal file
@@ -0,0 +1,246 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../domain/entities/fcs_shipment.dart';
|
||||
import '../../../helpers/theme.dart';
|
||||
import '../../fcs_shipment/model/fcs_shipment_model.dart';
|
||||
import '../../main/util.dart';
|
||||
import '../../widgets/continue_button.dart';
|
||||
import '../../widgets/local_dropdown.dart';
|
||||
import '../../widgets/local_text.dart';
|
||||
import '../../widgets/local_title.dart';
|
||||
import '../../widgets/previous_button.dart';
|
||||
|
||||
typedef OnPrevious = Function();
|
||||
|
||||
class TypeWidget extends StatefulWidget {
|
||||
final OnPrevious? onPrevious;
|
||||
final bool isTransferFrom;
|
||||
final bool isTransferTo;
|
||||
const TypeWidget(
|
||||
{Key? key,
|
||||
this.onPrevious,
|
||||
this.isTransferFrom = false,
|
||||
this.isTransferTo = false})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
State<TypeWidget> createState() => _TypeWidgetState();
|
||||
}
|
||||
|
||||
class _TypeWidgetState extends State<TypeWidget> {
|
||||
FcsShipment? _shipment;
|
||||
List<FcsShipment> shipments = [];
|
||||
List<String> standardSizeList = [
|
||||
'Large - 20”x20”x20”',
|
||||
'Medium - 15”x15”x15”',
|
||||
'Small - 10”x10”x10”'
|
||||
];
|
||||
int _cartinSizeValue = 1;
|
||||
late String selectedValue;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_init();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
_init() async {
|
||||
selectedValue = standardSizeList[1];
|
||||
var fcsShipments =
|
||||
await context.read<FcsShipmentModel>().getActiveFcsShipments();
|
||||
shipments = fcsShipments;
|
||||
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final continueBtn = ContinueButton(onTap: () {
|
||||
if (_shipment == null) {
|
||||
showMsgDialog(context, "Error", "Please select shipment");
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
final previousBtn = PreviousButton(onTap: () {
|
||||
if (widget.onPrevious != null) {
|
||||
widget.onPrevious!();
|
||||
}
|
||||
});
|
||||
|
||||
final standardSizeBox = Padding(
|
||||
padding: const EdgeInsets.only(left: 35.0),
|
||||
child: DropdownButton<String>(
|
||||
isDense: true,
|
||||
value: selectedValue,
|
||||
style: TextStyle(color: Colors.black, fontSize: 14),
|
||||
underline: Container(
|
||||
height: 1,
|
||||
color: Colors.grey,
|
||||
),
|
||||
onChanged: (newValue) {
|
||||
setState(() {
|
||||
selectedValue = newValue!;
|
||||
});
|
||||
},
|
||||
isExpanded: true,
|
||||
items: standardSizeList.map<DropdownMenuItem<String>>((String value) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: Text(value.toString(),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(color: Colors.black)),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
|
||||
final cartonSizedBox = Column(
|
||||
children: [
|
||||
// standard carton size
|
||||
InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_cartinSizeValue = 1;
|
||||
});
|
||||
},
|
||||
child: Row(children: <Widget>[
|
||||
Radio(
|
||||
visualDensity:
|
||||
const VisualDensity(horizontal: VisualDensity.minimumDensity),
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
activeColor: primaryColor,
|
||||
groupValue: _cartinSizeValue,
|
||||
value: 1,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_cartinSizeValue = 1;
|
||||
});
|
||||
},
|
||||
),
|
||||
Flexible(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: LocalText(context, 'box.standard_carton_size',
|
||||
fontSize: 14,
|
||||
color: _cartinSizeValue == 1 ? primaryColor : Colors.black),
|
||||
),
|
||||
)
|
||||
]),
|
||||
),
|
||||
standardSizeBox,
|
||||
const SizedBox(height: 10),
|
||||
// custom size
|
||||
InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_cartinSizeValue = 2;
|
||||
});
|
||||
},
|
||||
child: Row(children: <Widget>[
|
||||
Radio(
|
||||
visualDensity:
|
||||
const VisualDensity(horizontal: VisualDensity.minimumDensity),
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
activeColor: primaryColor,
|
||||
groupValue: _cartinSizeValue,
|
||||
value: 2,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_cartinSizeValue = 2;
|
||||
});
|
||||
},
|
||||
),
|
||||
Flexible(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: LocalText(context, 'box.custom_size',
|
||||
fontSize: 14,
|
||||
color: _cartinSizeValue == 2 ? primaryColor : Colors.black),
|
||||
),
|
||||
)
|
||||
]),
|
||||
),
|
||||
// not defined size
|
||||
InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_cartinSizeValue = 3;
|
||||
});
|
||||
},
|
||||
child: Row(children: <Widget>[
|
||||
Radio(
|
||||
visualDensity:
|
||||
const VisualDensity(horizontal: VisualDensity.minimumDensity),
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
activeColor: primaryColor,
|
||||
groupValue: _cartinSizeValue,
|
||||
value: 3,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_cartinSizeValue = 3;
|
||||
});
|
||||
},
|
||||
),
|
||||
Flexible(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: LocalText(context, 'box.package_size',
|
||||
fontSize: 14,
|
||||
color: _cartinSizeValue == 3 ? primaryColor : Colors.black),
|
||||
),
|
||||
)
|
||||
]),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
final fcsShipmentsBox = Container(
|
||||
padding: EdgeInsets.only(top: 10),
|
||||
child: LocalDropdown<FcsShipment>(
|
||||
callback: (v) {
|
||||
setState(() {
|
||||
_shipment = v;
|
||||
});
|
||||
},
|
||||
labelKey: "box.shipment",
|
||||
iconData: Ionicons.ios_airplane,
|
||||
display: (u) => u.shipmentNumber,
|
||||
selectedValue: _shipment,
|
||||
values: shipments,
|
||||
));
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView(
|
||||
padding: EdgeInsets.only(left: 10, right: 10),
|
||||
children: [
|
||||
LocalTitle(textKey: "box.select_carton_size"),
|
||||
cartonSizedBox,
|
||||
LocalTitle(textKey: "box.select_shipment"),
|
||||
fcsShipmentsBox
|
||||
],
|
||||
)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 15, right: 15),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
widget.onPrevious == null ? const SizedBox() : previousBtn,
|
||||
continueBtn
|
||||
// warehouse != null ? continueBtn : const SizedBox(),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user