Merge branch 'master' of tzw/fcs into master

This commit is contained in:
2025-03-08 10:03:40 +06:30
committed by Gogs
13 changed files with 616 additions and 618 deletions

View File

@@ -328,7 +328,7 @@
"box.mix.number":"Carton number",
"box.package":"Packages",
"box.mix.desc":"Description",
"box.info.title":"Carton Info",
"box.info.title":"Carton",
"box.imageupload.title":"Upload images",
"box.popupmenu.active":"Active Cartons",
"box.popupmenu.delivered":"Delivered Cartons",

View File

@@ -11,6 +11,7 @@ var dividerColor = Colors.grey.shade400;
const dangerColor = const Color(0xffff0606);
const hintTextColor = Color.fromARGB(255, 187, 187, 187);
const linkColor= Color(0xff0000EE);
const oddColor = Color(0xffECF1F7);
const TextStyle labelStyle =
TextStyle(fontSize: 20, color: labelColor, fontWeight: FontWeight.w500);

View File

@@ -9,7 +9,6 @@ import '../../domain/entities/user.dart';
import '../main/util.dart';
import '../rates/model/shipment_rate_model.dart';
import '../widgets/continue_button.dart';
import '../widgets/display_text.dart';
import '../widgets/local_title.dart';
import '../widgets/previous_button.dart';
import 'cargo_type_addition.dart';
@@ -29,14 +28,14 @@ class CargoWidget extends StatefulWidget {
final OnContinue? onContinue;
const CargoWidget({
Key? key,
super.key,
required this.cargoTypes,
required this.surchargeItems,
this.onPrevious,
this.onContinue,
required this.sender,
required this.consignee,
}) : super(key: key);
});
@override
State<CargoWidget> createState() => _CargoWidgetState();
@@ -45,9 +44,9 @@ class CargoWidget extends StatefulWidget {
class _CargoWidgetState extends State<CargoWidget> {
List<CargoType> _cargoTypes = [];
List<CargoType> _surchareItems = [];
TextEditingController _totalCtl = TextEditingController();
List<TextEditingController> _cargoTypeControllers = [];
List<TextEditingController> _surchargeControllers = [];
TextEditingController totalCtl = TextEditingController();
List<TextEditingController> cargoTypeControllers = [];
List<TextEditingController> surchargeControllers = [];
@override
void initState() {
@@ -59,36 +58,37 @@ class _CargoWidgetState extends State<CargoWidget> {
// for cargo types
if (widget.cargoTypes.isNotEmpty) {
_cargoTypes = List.from(widget.cargoTypes);
_cargoTypes.forEach((e) {
var editor = new TextEditingController();
for (var e in _cargoTypes) {
var editor = TextEditingController();
editor.text = removeTrailingZeros(e.weight);
editor.addListener(inputChangeListener);
_cargoTypeControllers.add(editor);
});
cargoTypeControllers.add(editor);
}
_calculateTotalWeght();
} else {
var model = context.read<ShipmentRateModel>();
var cargoes = model.rate.cargoTypes.map((e) => e.clone()).toList();
_cargoTypes = cargoes.where((e) => e.isDefault).toList();
_cargoTypes.forEach((e) {
var editor = new TextEditingController();
// ignore: unused_local_variable
for (var e in _cargoTypes) {
var editor = TextEditingController();
editor.text = '';
editor.addListener(inputChangeListener);
_cargoTypeControllers.add(editor);
});
cargoTypeControllers.add(editor);
}
}
//for surcharge items
if (widget.surchargeItems.isNotEmpty) {
_surchareItems = List.from(widget.surchargeItems);
_surchareItems.forEach((e) {
var editor = new TextEditingController();
for (var e in _surchareItems) {
var editor = TextEditingController();
editor.text = e.qty.toString();
editor.addListener(inputChangeListener);
_surchargeControllers.add(editor);
});
surchargeControllers.add(editor);
}
}
if (mounted) {
@@ -98,16 +98,16 @@ class _CargoWidgetState extends State<CargoWidget> {
_calculateTotalWeght() {
double total = _cargoTypes.fold(0, (sum, value) => sum + value.weight);
_totalCtl.text = removeTrailingZeros(total);
totalCtl.text = removeTrailingZeros(total);
}
bool isFieldEmpty(int index) {
return _cargoTypeControllers[index].text.isEmpty;
return cargoTypeControllers[index].text.isEmpty;
}
List<int> getEmptyFields() {
List<int> emptyFields = [];
for (int i = 0; i < _cargoTypeControllers.length; i++) {
for (int i = 0; i < cargoTypeControllers.length; i++) {
if (isFieldEmpty(i)) {
emptyFields.add(i);
}
@@ -121,38 +121,36 @@ class _CargoWidgetState extends State<CargoWidget> {
if (emptyFields.isEmpty) {
_cargoTypes.asMap().entries.forEach((e) {
_cargoTypes[e.key].weight =
double.tryParse(_cargoTypeControllers[e.key].text) ?? 0;
double.tryParse(cargoTypeControllers[e.key].text) ?? 0;
});
double total = _cargoTypes.fold(0, (sum, value) => sum + value.weight);
setState(() {
_totalCtl.text = removeTrailingZeros(total);
totalCtl.text = removeTrailingZeros(total);
});
}
}
@override
Widget build(BuildContext context) {
final senderBox = DisplayText(
text: widget.sender.name,
labelTextKey: "box.sender.title",
iconData: MaterialCommunityIcons.account_arrow_right,
subText: Text(widget.sender.fcsID!,
style: TextStyle(fontSize: 13, color: labelColor)),
);
final senderBox = userDisplayBox(context,
lableKey: "box.sender.title",
icon: MaterialCommunityIcons.account_arrow_right,
showLink: false,
name: widget.sender.name ?? "",
fcsID: widget.sender.fcsID ?? "");
final consigneeBox = DisplayText(
text: widget.consignee.name,
labelTextKey: "box.consignee.title",
iconData: MaterialCommunityIcons.account_arrow_left,
subText: Text(widget.consignee.fcsID!,
style: TextStyle(fontSize: 13, color: labelColor)),
);
final consigneeBox = userDisplayBox(context,
showLink: false,
lableKey: "box.consignee.title",
icon: MaterialCommunityIcons.account_arrow_left,
name: widget.consignee.name,
fcsID: widget.consignee.fcsID);
final userRow = Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(child: senderBox, flex: 2),
Flexible(child: consigneeBox)
Expanded(flex: 2, child: consigneeBox),
Flexible(child: senderBox)
],
);
@@ -173,14 +171,14 @@ class _CargoWidgetState extends State<CargoWidget> {
if (cargoType == null) return;
_cargoTypes.add(cargoType);
_cargoTypeControllers.clear();
cargoTypeControllers.clear();
_cargoTypes.forEach((e) {
var editor = new TextEditingController();
for (var e in _cargoTypes) {
var editor = TextEditingController();
editor.text = removeTrailingZeros(e.weight);
editor.addListener(inputChangeListener);
_cargoTypeControllers.add(editor);
});
cargoTypeControllers.add(editor);
}
_calculateTotalWeght();
if (mounted) {
@@ -204,17 +202,17 @@ class _CargoWidgetState extends State<CargoWidget> {
onTap: () {
_cargoTypes.removeAt(key);
double totalWeight = double.tryParse(_totalCtl.text) ?? 0;
double totalWeight = double.tryParse(totalCtl.text) ?? 0;
double removeWeight =
(double.tryParse(_cargoTypeControllers[key].text) ??
(double.tryParse(cargoTypeControllers[key].text) ??
0);
if (totalWeight >= removeWeight) {
double result = totalWeight - removeWeight;
_totalCtl.text = removeTrailingZeros(result);
totalCtl.text = removeTrailingZeros(result);
}
_cargoTypeControllers[key].clear();
cargoTypeControllers[key].clear();
if (mounted) {
setState(() {});
@@ -225,7 +223,7 @@ class _CargoWidgetState extends State<CargoWidget> {
Flexible(
child: inputTextFieldWidget(context,
lableText: c.name ?? "",
controller: _cargoTypeControllers[key]),
controller: cargoTypeControllers[key]),
),
],
),
@@ -243,7 +241,7 @@ class _CargoWidgetState extends State<CargoWidget> {
radius: 25,
onTap: () {
setState(() {
_totalCtl.clear();
totalCtl.clear();
});
},
child: Icon(MaterialIcons.clear, color: labelColor)),
@@ -251,16 +249,16 @@ class _CargoWidgetState extends State<CargoWidget> {
Flexible(
child: inputTextFieldWidget(context,
lableText: "Total",
controller: _totalCtl,
controller: totalCtl,
readOnly: getEmptyFields().isEmpty, onChanged: (neValue) {
List<int> emptyFields = getEmptyFields();
if (emptyFields.length == 1) {
double totalWeight = double.tryParse(neValue) ?? 0;
_cargoTypes.asMap().entries.forEach((e) {
_cargoTypes[e.key].weight = double.tryParse(
_cargoTypeControllers[e.key].text) ??
0;
_cargoTypes[e.key].weight =
double.tryParse(cargoTypeControllers[e.key].text) ??
0;
});
double result = _cargoTypes.fold(
0, (sum, value) => sum + value.weight);
@@ -268,7 +266,7 @@ class _CargoWidgetState extends State<CargoWidget> {
if (totalWeight >= result) {
double remaining = totalWeight - result;
setState(() {
_cargoTypeControllers[emptyFields.first].text =
cargoTypeControllers[emptyFields.first].text =
removeTrailingZeros(remaining);
});
}
@@ -297,11 +295,11 @@ class _CargoWidgetState extends State<CargoWidget> {
_surchareItems.add(surchargeItem);
_surchargeControllers.clear();
surchargeControllers.clear();
_surchareItems.asMap().entries.forEach((e) {
var editor = new TextEditingController();
var editor = TextEditingController();
editor.text = e.value.qty.toString();
_surchargeControllers.add(editor);
surchargeControllers.add(editor);
});
if (mounted) {
@@ -333,7 +331,7 @@ class _CargoWidgetState extends State<CargoWidget> {
child: inputTextFieldWidget(
context,
lableText: c.name ?? "",
controller: _surchargeControllers[key],
controller: surchargeControllers[key],
onChanged: (newValue) {
setState(() {
_surchareItems[key].qty = int.tryParse(newValue) ?? 0;
@@ -418,7 +416,7 @@ class _CargoWidgetState extends State<CargoWidget> {
keyboardType: TextInputType.number,
onChanged: onChanged,
readOnly: readOnly,
decoration: new InputDecoration(
decoration: InputDecoration(
contentPadding: EdgeInsets.all(0),
labelText: lableText,
labelStyle: newLabelStyle(color: Colors.black54, fontSize: 17),

View File

@@ -3,8 +3,6 @@ import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/domain/entities/user.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/user_search/user_search.dart';
import 'package:fcs/pages/widgets/display_text.dart';
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
import 'package:fcs/pages/widgets/local_app_bar.dart';
import 'package:fcs/pages/widgets/local_radio_buttons.dart';
import 'package:fcs/pages/widgets/local_text.dart';
@@ -22,24 +20,22 @@ import 'model/package_selection_model.dart';
import 'widget/carton_row.dart';
class CartonEditor extends StatefulWidget {
final Carton? carton;
CartonEditor({this.carton});
const CartonEditor({super.key});
@override
_CartonEditorState createState() => _CartonEditorState();
}
class _CartonEditorState extends State<CartonEditor> {
List<String> _cartonTypes = [carton_from_packages, carton_mix_carton];
List<Carton> _cartons = [];
List<String> cartonTypes = [carton_from_packages, carton_mix_carton];
List<Carton> cartons = [];
bool _isLoading = false;
bool _isNew = false;
bool isLoading = false;
String? _selectedCartonType;
User? _consignee;
User? _sender;
Carton? _carton;
bool _hasPackages = true;
@override
@@ -49,26 +45,7 @@ class _CartonEditorState extends State<CartonEditor> {
}
_init() {
if (widget.carton != null) {
_carton = widget.carton;
_selectedCartonType = _carton!.cartonType;
_isNew = false;
_consignee = User(
id: _carton!.consigneeID,
fcsID: _carton!.consigneeFCSID,
name: _carton!.consigneeName);
_sender = User(
id: _carton!.senderID,
fcsID: _carton!.senderFCSID,
name: _carton!.senderName);
} else {
_carton = Carton(cargoTypes: [], packages: []);
_isNew = true;
_selectedCartonType = carton_from_packages;
_cartons = [];
}
_selectedCartonType = carton_from_packages;
if (mounted) {
setState(() {});
}
@@ -115,8 +92,8 @@ class _CartonEditorState extends State<CartonEditor> {
);
final cartonTypeBox = LocalRadioButtons(
readOnly: !_isNew,
values: _cartonTypes,
readOnly: false,
values: cartonTypes,
selectedValue: _selectedCartonType,
callback: (String? v) {
setState(() {
@@ -125,8 +102,8 @@ class _CartonEditorState extends State<CartonEditor> {
});
final cartonTitleBox = LocalTitle(
textKey: _cartons.isEmpty ? "box.shipment.boxes" : "box.cartion.count",
translationVariables: _cartons.isEmpty ? null : ["${_cartons.length}"],
textKey: cartons.isEmpty ? "box.shipment.boxes" : "box.cartion.count",
translationVariables: cartons.isEmpty ? null : ["${cartons.length}"],
trailing: Padding(
padding: const EdgeInsets.only(right: 5),
child: InkResponse(
@@ -134,20 +111,19 @@ class _CartonEditorState extends State<CartonEditor> {
onTap: () async {
//for packages
if (isFromPackages) {
if (_sender == null) {
showMsgDialog(
context, "Error", "Please select sender's FCS ID");
if (_consignee == null) {
showMsgDialog(context, "Error", "Please select consignee");
return;
}
if (_consignee == null) {
showMsgDialog(
context, "Error", "Please select consignee's FCS ID");
if (_sender == null) {
showMsgDialog(context, "Error", "Please select sender");
return;
}
if (!_hasPackages) {
showMsgDialog(
context, "Error", "No packages in sender and consignee");
context, "Error", "No packages in consignee and sender");
return;
}
@@ -155,13 +131,11 @@ class _CartonEditorState extends State<CartonEditor> {
context,
CupertinoPageRoute(
builder: (context) => CartonPackageForm(
sender: _sender!,
consignee: _consignee!,
)));
sender: _sender!, consignee: _consignee!)));
if (carton != null) {
setState(() {
_cartons.add(carton);
cartons.add(carton);
});
}
}
@@ -174,7 +148,7 @@ class _CartonEditorState extends State<CartonEditor> {
if (carton != null) {
setState(() {
_cartons.add(carton);
cartons.add(carton);
});
}
}
@@ -183,109 +157,33 @@ class _CartonEditorState extends State<CartonEditor> {
),
));
final consigneeSearchBox = Row(
children: <Widget>[
Flexible(
child: Padding(
padding: const EdgeInsets.only(left: 2),
child: LocalText(context, "box.consignee.title",
color: Colors.black, fontSize: 15),
)),
IconButton(
icon: Icon(Icons.search, color: Colors.black),
onPressed: () => searchUser(context, onUserSelect: (u) async {
setState(() {
this._consignee = u;
});
final consigneeBox = userSearchBox(context,
lableKey: 'box.consignee.title',
icon: MaterialCommunityIcons.account_arrow_left,
user: _consignee,
onSearch: () => searchUser(context, onUserSelect: (u) {
setState(() {
_consignee = u;
});
_checkPackages();
}, popPage: true));
_checkPackages();
}, popPage: true)),
],
);
final consigneefcsIDBox = DisplayText(
text: _consignee != null ? _consignee!.fcsID : "",
labelTextKey: "processing.fcs.id",
icon: FcsIDIcon(),
);
final consigneePhoneBox = DisplayText(
text: _consignee != null ? _consignee!.phoneNumber : "",
labelTextKey: "processing.phone",
iconData: MaterialCommunityIcons.phone);
final consigneeNameBox = DisplayText(
text: _consignee != null ? _consignee!.name : "",
labelTextKey: "processing.consignee.name",
maxLines: 2,
iconData: MaterialCommunityIcons.account_arrow_left);
final consigneeBox = Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
consigneeSearchBox,
consigneefcsIDBox,
consigneePhoneBox,
consigneeNameBox,
],
),
);
final senderSearchBox = Row(
children: <Widget>[
Flexible(
child: Padding(
padding: const EdgeInsets.only(left: 2),
child: LocalText(context, "box.sender.title",
color: Colors.black, fontSize: 15),
)),
IconButton(
icon: Icon(Icons.search, color: Colors.black),
onPressed: () => searchUser(context, onUserSelect: (u) async {
setState(() {
this._sender = u;
});
_checkPackages();
}, popPage: true)),
],
);
final senderIDBox = DisplayText(
text: _sender != null ? _sender!.fcsID : "",
labelTextKey: "processing.fcs.id",
icon: FcsIDIcon());
final senderPhoneBox = DisplayText(
text: _sender != null ? _sender!.phoneNumber : "",
labelTextKey: "processing.phone",
iconData: MaterialCommunityIcons.phone,
);
final senderNameBox = DisplayText(
text: _sender != null ? _sender!.name : "",
labelTextKey: "processing.shipper.name",
maxLines: 2,
iconData: MaterialCommunityIcons.account_arrow_right);
final senderBox = Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
senderSearchBox,
senderIDBox,
senderPhoneBox,
senderNameBox,
],
),
);
final senderBox = userSearchBox(context,
lableKey: 'box.sender.title',
icon: MaterialCommunityIcons.account_arrow_right,
user: _sender,
onSearch: () => searchUser(context, onUserSelect: (u) {
setState(() {
_sender = u;
});
_checkPackages();
}, popPage: true));
return LocalProgress(
inAsyncCall: _isLoading,
inAsyncCall: isLoading,
child: Scaffold(
appBar: LocalAppBar(
labelKey: _isNew ? "boxes.new" : "box.edit.title",
labelKey: "boxes.new",
backgroundColor: Colors.white,
arrowColor: primaryColor,
labelColor: primaryColor),
@@ -303,8 +201,8 @@ class _CartonEditorState extends State<CartonEditor> {
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Flexible(child: senderBox),
Flexible(child: consigneeBox)
Flexible(child: consigneeBox),
Flexible(child: senderBox)
],
),
!_hasPackages
@@ -319,7 +217,7 @@ class _CartonEditorState extends State<CartonEditor> {
)
: Container(),
cartonTitleBox,
Column(children: _getCartons(context, _cartons)),
Column(children: _getCartons(context, cartons)),
SizedBox(height: 20),
createBtn,
SizedBox(height: 20),

View File

@@ -8,12 +8,13 @@ import 'package:provider/provider.dart';
import '../main/util.dart';
import '../widgets/local_button.dart';
import '../widgets/local_text.dart';
import '../widgets/multi_img_file.dart';
import 'model/carton_model.dart';
class CartonImageUploadEditor extends StatefulWidget {
final Carton carton;
const CartonImageUploadEditor({required this.carton});
const CartonImageUploadEditor({super.key, required this.carton});
@override
_CartonImageUploaState createState() => _CartonImageUploaState();
}
@@ -21,12 +22,12 @@ class CartonImageUploadEditor extends StatefulWidget {
class _CartonImageUploaState extends State<CartonImageUploadEditor> {
bool _isLoading = false;
MultiImgController _multiImgController = MultiImgController();
MultiImgController multiImgController = MultiImgController();
@override
void initState() {
super.initState();
_multiImgController.setImageUrls = widget.carton.photoUrls;
multiImgController.setImageUrls = widget.carton.photoUrls;
}
@override
@@ -44,24 +45,25 @@ class _CartonImageUploaState extends State<CartonImageUploadEditor> {
inAsyncCall: _isLoading,
child: Scaffold(
appBar: LocalAppBar(
labelKey: "box.imageupload.title",
backgroundColor: Colors.white,
labelColor: primaryColor,
arrowColor: primaryColor,
actions: []),
titleWidget: Column(
children: [
LocalText(context, "box.imageupload.title",
fontSize: 20, color: primaryColor),
Text(widget.carton.cartonNumber ?? '',
style: TextStyle(fontSize: 15, color: Colors.black))
],
),
backgroundColor: Colors.white,
labelColor: primaryColor,
arrowColor: primaryColor,
),
body: Padding(
padding: EdgeInsets.only(left: 12.0, right: 12),
child: ListView(
children: [
Center(
child: Text("${widget.carton.cartonNumber}",
style: TextStyle(
color: primaryColor,
fontSize: 25,
))),
MultiImageFile(
enabled: true,
controller: _multiImgController,
controller: multiImgController,
title: "Receipt File",
),
const SizedBox(height: 20),
@@ -77,7 +79,7 @@ class _CartonImageUploaState extends State<CartonImageUploadEditor> {
});
try {
await context.read<CartonModel>().uploadCartonImages(widget.carton,
_multiImgController.getAddedFile, _multiImgController.getDeletedUrl);
multiImgController.getAddedFile, multiImgController.getDeletedUrl);
Navigator.pop(context, true);
} catch (e) {
showMsgDialog(context, "Error", e.toString());

View File

@@ -18,7 +18,9 @@ import 'package:flutter_vector_icons/flutter_vector_icons.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import '../../domain/entities/carton_size.dart';
import '../../domain/entities/fcs_shipment.dart';
import '../carton_size/model/carton_size_model.dart';
import '../fcs_shipment/model/fcs_shipment_model.dart';
import '../widgets/local_button.dart';
import 'carton_package_editor.dart';
import 'mix_carton/mix_carton_editor.dart';
@@ -34,9 +36,9 @@ class CartonInfo extends StatefulWidget {
}
class _CartonInfoState extends State<CartonInfo> {
final DateFormat dateFormat = DateFormat("d MMM yyyy");
var dateFormatter = DateFormat('dd MMM yyyy');
final NumberFormat numberFormatter = NumberFormat("#,###");
MultiImgController _multiImgController = MultiImgController();
MultiImgController multiImgController = MultiImgController();
bool _isLoading = false;
late Carton _carton;
List<CargoType> _cargoTypes = [];
@@ -46,6 +48,7 @@ class _CartonInfoState extends State<CartonInfo> {
double totalWeight = 0.0;
double totalSurchargeCount = 0.0;
CartonSize? standardSize;
FcsShipment? _shipment;
@override
void initState() {
@@ -57,7 +60,7 @@ class _CartonInfoState extends State<CartonInfo> {
_init() async {
try {
_isLoading = true;
_multiImgController.setImageUrls = _carton.photoUrls;
multiImgController.setImageUrls = _carton.photoUrls;
_cargoTypes = _carton.cargoTypes;
_surchareItems = _carton.surchareItems;
@@ -82,6 +85,14 @@ class _CartonInfoState extends State<CartonInfo> {
_carton.cartonSizeType = customCarton;
}
if (widget.carton.fcsShipmentID != null &&
widget.carton.fcsShipmentID != '') {
var s = await context
.read<FcsShipmentModel>()
.getFcsShipment(widget.carton.fcsShipmentID!);
_shipment = s;
}
if (_carton.cartonType == carton_from_packages) {
_packages = await context
.read<PackageModel>()
@@ -119,11 +130,6 @@ class _CartonInfoState extends State<CartonInfo> {
? "${_carton.length.toInt()}”x${_carton.width.toInt()}”x${_carton.height.toInt()}"
: null;
final cartonNumberBox = DisplayText(
text: _carton.cartonNumber,
labelTextKey: "box.number",
);
final cartonQrBox = IconButton(
onPressed: () {
Navigator.push(
@@ -132,7 +138,7 @@ class _CartonInfoState extends State<CartonInfo> {
builder: (context) => PrintQrCodePage(carton: _carton)),
);
},
icon: Icon(AntDesign.qrcode, color: Colors.black));
icon: Icon(AntDesign.qrcode, color: primaryColor));
final cartonTypeBox = DisplayText(
text: _carton.cartonType == carton_from_packages
@@ -152,11 +158,6 @@ class _CartonInfoState extends State<CartonInfo> {
labelTextKey: "box.bill_to",
);
final shipmentBox = DisplayText(
text: _carton.fcsShipmentNumber,
labelTextKey: "box.fcs_shipment_num",
);
final lastMileBox = DisplayText(
text: _carton.lastMile == delivery_caton
? 'Delivery'
@@ -167,22 +168,34 @@ class _CartonInfoState extends State<CartonInfo> {
);
final cartonSizeBox = DisplayText(
subText: Text("${boxDimension ?? 'No defined size'}"),
subText: Text(boxDimension ?? 'No defined size'),
labelTextKey: "box.select_carton_size",
);
final senderBox = DisplayText(
text: _carton.senderName == null ? "" : _carton.senderName,
subText: Text(_carton.senderFCSID ?? "", style: textStyle),
labelTextKey: "box.name",
final packageLengthBox = DisplayText(
showLabelLink: true,
subText: Text(numberFormatter.format(_packages.length)),
labelTextKey: "box.package",
onTapLabel: () {},
);
final consigneeNameBox = DisplayText(
text: _carton.consigneeName != null ? _carton.consigneeName : "",
subText: Text(_carton.consigneeFCSID ?? "", style: textStyle),
labelTextKey: "processing.consignee.name",
final mixCartonLengthBox = DisplayText(
showLabelLink: true,
subText: Text(numberFormatter.format(_mixCartons.length)),
labelTextKey: "box.shipment.boxes",
onTapLabel: () {},
);
final senderBox = userDisplayBox(context,
lableKey: "box.sender.title",
name: _carton.senderName,
fcsID: _carton.senderFCSID);
final consigneeNameBox = userDisplayBox(context,
lableKey: "box.consignee.title",
name: _carton.consigneeName,
fcsID: _carton.consigneeFCSID);
// final billWidget = Expanded(
// child: Padding(
// padding: EdgeInsets.only(left: 0, top: 15),
@@ -200,6 +213,21 @@ class _CartonInfoState extends State<CartonInfo> {
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
consigneeNameBox,
],
),
),
// _carton.billTo == billToConsignee ? billWidget : const SizedBox()
],
)),
Expanded(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -216,21 +244,6 @@ class _CartonInfoState extends State<CartonInfo> {
],
),
),
Expanded(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
consigneeNameBox,
],
),
),
// _carton.billTo == billToConsignee ? billWidget : const SizedBox()
],
))
],
);
@@ -246,82 +259,88 @@ class _CartonInfoState extends State<CartonInfo> {
fontWeight: FontWeight.normal),
_cargoTypes.isNotEmpty
? Padding(
padding: EdgeInsets.only(right: 50),
padding: EdgeInsets.only(right: 0),
child: Text("${removeTrailingZeros(totalWeight)} lb",
textAlign: TextAlign.end,
style: TextStyle(color: Colors.black54, fontSize: 15)))
: const SizedBox()
],
),
Container(
child: Padding(
padding: const EdgeInsets.only(right: 50),
child: Column(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: _cargoTypes.map((e) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 3),
Padding(
padding: const EdgeInsets.only(right: 0),
child: Column(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: _cargoTypes.asMap().entries.map((e) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 2),
child: Container(
color: e.key.isEven ? Colors.grey.shade300 : oddColor,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
e.name ?? "",
e.value.name ?? "",
style:
TextStyle(color: Colors.black, fontSize: 15),
),
Text("${removeTrailingZeros(e.weight)} lb",
Text("${removeTrailingZeros(e.value.weight)} lb",
textAlign: TextAlign.end,
style: TextStyle(
color: Colors.black, fontSize: 15))
],
),
);
}).toList()),
],
),
),
),
]),
);
final surchargeItemBox =
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Container(
child: Padding(
padding: const EdgeInsets.only(right: 50),
child: Column(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: _surchareItems.map((e) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 3),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
e.name ?? "",
style: TextStyle(color: Colors.black, fontSize: 15),
),
Text("${removeTrailingZeros((e.qty).toDouble())} pc",
textAlign: TextAlign.end,
style:
TextStyle(color: Colors.black, fontSize: 15))
],
),
);
}).toList()),
],
),
),
),
]);
]),
);
final surchargeItemBox = Padding(
padding: const EdgeInsets.only(top: 16),
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
LocalText(context, 'box.input_surcharge_item',
color: Colors.black54, fontSize: 16, fontWeight: FontWeight.normal),
Padding(
padding: const EdgeInsets.only(right: 0),
child: Column(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: _surchareItems.asMap().entries.map((e) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 2),
child: Container(
color: e.key.isEven ? Colors.grey.shade300 : oddColor,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
e.value.name ?? "",
style: TextStyle(color: Colors.black, fontSize: 15),
),
Text("${removeTrailingZeros((e.value.qty).toDouble())} pc",
textAlign: TextAlign.end,
style:
TextStyle(color: Colors.black, fontSize: 15))
],
),
),
);
}).toList()),
],
),
),
]),
);
final img = MultiImageFile(
enabled: false,
controller: _multiImgController,
controller: multiImgController,
title: "Receipt File",
);
@@ -367,15 +386,74 @@ class _CartonInfoState extends State<CartonInfo> {
),
);
final shipmentBox = Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
LocalText(context, "package.shipment.title",
fontSize: 15, color: Colors.black54),
const SizedBox(height: 5),
Container(
decoration: BoxDecoration(
border: Border.all(color: dividerColor),
borderRadius: BorderRadius.circular(5),
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Column(
children: [
DisplayText(
text: _shipment?.shipmentNumber,
labelTextKey: "FCSshipment.number",
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
child: DisplayText(
text: _shipment != null
? _shipment!.cutoffDate != null
? dateFormatter.format(_shipment!.cutoffDate!)
: ""
: "",
labelTextKey: "FCSshipment.cutoff_date",
)),
Flexible(
child: DisplayText(
text: _shipment != null
? _shipment!.etaDate != null
? dateFormatter.format(_shipment!.etaDate!)
: ""
: "",
labelTextKey: "FCSshipment.ETA",
)),
],
)
],
),
),
)
],
),
);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: LocalAppBar(
labelKey: "box.info.title",
titleWidget: Column(
children: [
LocalText(context, "box.info.title",
fontSize: 20, color: primaryColor),
Text(_carton.cartonNumber ?? '',
style: TextStyle(fontSize: 15, color: Colors.black))
],
),
backgroundColor: Colors.white,
labelColor: primaryColor,
arrowColor: primaryColor,
actions: <Widget>[
cartonQrBox,
_carton.status == carton_packed_status
? IconButton(
icon: Icon(Icons.edit, color: primaryColor),
@@ -385,66 +463,64 @@ class _CartonInfoState extends State<CartonInfo> {
body: Container(
padding: const EdgeInsets.only(left: 20, right: 20),
child: ListView(children: <Widget>[
Row(children: [
Flexible(child: cartonNumberBox, flex: 1),
Flexible(
child: cartonQrBox,
),
]),
Row(
children: [
Flexible(child: cartonTypeBox),
],
),
fromPackage ? userRowBox : const SizedBox(),
fromPackage
? Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(child: billInfoBox),
Flexible(child: lastMileBox),
],
)
: const SizedBox(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
fromPackage ? Flexible(child: billInfoBox) : SizedBox(),
Flexible(child: shipmentBox),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
fromPackage
? Flexible(child: lastMileBox)
: const SizedBox(),
Flexible(child: cartonSizeBox),
Flexible(child: packageLengthBox),
],
),
_packages.isEmpty
? const SizedBox()
: Padding(
padding: const EdgeInsets.only(top: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
LocalText(context, "box.package",
color: Colors.black54, fontSize: 15),
const SizedBox(height: 5),
Column(
children: getPackageList(_packages),
),
],
),
),
_mixCartons.isEmpty
? const SizedBox()
: Padding(
padding: const EdgeInsets.only(top: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
LocalText(context, "box.shipment.boxes",
color: Colors.black54, fontSize: 15),
const SizedBox(height: 5),
Column(children: getCartonList(_mixCartons)),
],
),
),
fromPackage ? const SizedBox() : mixCartonLengthBox,
shipmentBox,
// _packages.isEmpty
// ? const SizedBox()
// : Padding(
// padding: const EdgeInsets.only(top: 15),
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// LocalText(context, "box.package",
// color: Colors.black54, fontSize: 15),
// const SizedBox(height: 5),
// Column(
// children: getPackageList(_packages),
// ),
// ],
// ),
// ),
// _mixCartons.isEmpty
// ? const SizedBox()
// : Padding(
// padding: const EdgeInsets.only(top: 15),
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// LocalText(context, "box.shipment.boxes",
// color: Colors.black54, fontSize: 15),
// const SizedBox(height: 5),
// Column(children: getCartonList(_mixCartons)),
// ],
// ),
// ),
cargosBox,
surchargeItemBox,
_surchareItems.isNotEmpty
? surchargeItemBox
: const SizedBox(),
const SizedBox(height: 10),
uploadImageBtn,
_carton.photoUrls.isNotEmpty

View File

@@ -30,10 +30,10 @@ class CartonPackageForm extends StatefulWidget {
final User consignee;
const CartonPackageForm({
Key? key,
super.key,
required this.sender,
required this.consignee,
}) : super(key: key);
});
@override
State<CartonPackageForm> createState() => _CartonPackageFormState();

View File

@@ -14,7 +14,6 @@ import '../fcs_shipment/model/fcs_shipment_model.dart';
import '../main/util.dart';
import '../widgets/box_size_picker.dart';
import '../widgets/continue_button.dart';
import '../widgets/display_text.dart';
import '../widgets/local_dropdown.dart';
import '../widgets/local_text.dart';
import '../widgets/local_title.dart';
@@ -41,7 +40,7 @@ class CartonSizeWidget extends StatefulWidget {
final double? height;
const CartonSizeWidget(
{Key? key,
{super.key,
this.onPrevious,
this.onContinue,
this.shipment,
@@ -53,8 +52,7 @@ class CartonSizeWidget extends StatefulWidget {
required this.sender,
required this.consignee,
required this.lastMile,
required this.billType})
: super(key: key);
required this.billType});
@override
State<CartonSizeWidget> createState() => _CartonSizeWidgetState();
@@ -69,9 +67,9 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
late String _selectedLastmile;
late String _billToValue;
TextEditingController _widthController = new TextEditingController();
TextEditingController _heightController = new TextEditingController();
TextEditingController _lengthController = new TextEditingController();
TextEditingController widthController = TextEditingController();
TextEditingController heightController = TextEditingController();
TextEditingController lengthController = TextEditingController();
@override
void initState() {
@@ -83,15 +81,15 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
_selectedLastmile = widget.lastMile;
_billToValue = widget.billType;
_cartonSizeType = widget.cartonSizeType;
_lengthController.text =
lengthController.text =
widget.length == null ? "0" : removeTrailingZeros(widget.length ?? 0);
_widthController.text =
widthController.text =
widget.width == null ? "0" : removeTrailingZeros(widget.width ?? 0);
_heightController.text =
heightController.text =
widget.height == null ? "0" : removeTrailingZeros(widget.height ?? 0);
_getStandardCartonSize();
_loadShipment();
_loadShipment();
if (mounted) {
setState(() {});
}
@@ -135,169 +133,163 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
bool isCustomSize = _cartonSizeType == customCarton;
bool isNoneDefinedSize = _cartonSizeType == packageCarton;
final senderBox = DisplayText(
text: widget.sender.name,
labelTextKey: "box.sender.title",
iconData: MaterialCommunityIcons.account_arrow_right,
subText: Text(widget.sender.fcsID ?? "",
style: TextStyle(fontSize: 13, color: labelColor)),
);
final senderBox = userDisplayBox(context,
lableKey: "box.sender.title",
icon: MaterialCommunityIcons.account_arrow_right,
showLink: false,
name: widget.sender.name ?? "",
fcsID: widget.sender.fcsID ?? "");
final consigneeBox = DisplayText(
text: widget.consignee.name,
labelTextKey: "box.consignee.title",
iconData: MaterialCommunityIcons.account_arrow_left,
subText: Text(widget.consignee.fcsID ?? '',
style: TextStyle(fontSize: 13, color: labelColor)),
);
final consigneeBox = userDisplayBox(context,
showLink: false,
lableKey: "box.consignee.title",
icon: MaterialCommunityIcons.account_arrow_left,
name: widget.consignee.name,
fcsID: widget.consignee.fcsID);
final userRow = Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: senderBox,
flex: 2,
child: consigneeBox,
),
Flexible(child: consigneeBox)
Flexible(child: senderBox)
],
);
final deliveryTypeBox = Container(
child: Row(
children: [
Flexible(
child: InkWell(
final deliveryTypeBox = Row(
children: [
Flexible(
child: InkWell(
onTap: () {
setState(() {
_selectedLastmile = delivery_caton;
});
},
child: Row(children: <Widget>[
LocalRadio(
value: delivery_caton,
groupValue: _selectedLastmile,
onChanged: (p0) {
setState(() {
_selectedLastmile = delivery_caton;
});
},
),
Flexible(
child: Padding(
padding: const EdgeInsets.only(left: 10),
child: LocalText(context, 'box.delivery',
fontSize: 15,
color: _selectedLastmile == delivery_caton
? primaryColor
: Colors.black),
),
)
]),
)),
Flexible(
child: InkWell(
onTap: () {
setState(() {
_selectedLastmile = delivery_caton;
_selectedLastmile = pickup_carton;
});
},
child: Row(children: <Widget>[
LocalRadio(
value: delivery_caton,
value: pickup_carton,
groupValue: _selectedLastmile,
onChanged: (p0) {
setState(() {
_selectedLastmile = delivery_caton;
_selectedLastmile = pickup_carton;
});
},
),
Flexible(
child: Padding(
padding: const EdgeInsets.only(left: 10),
child: LocalText(context, 'box.delivery',
child: LocalText(context, 'box.pickup',
fontSize: 15,
color: _selectedLastmile == delivery_caton
color: _selectedLastmile == pickup_carton
? primaryColor
: Colors.black),
),
)
]),
)),
Flexible(
child: InkWell(
onTap: () {
setState(() {
_selectedLastmile = pickup_carton;
});
},
child: Row(children: <Widget>[
LocalRadio(
value: pickup_carton,
groupValue: _selectedLastmile,
onChanged: (p0) {
setState(() {
_selectedLastmile = pickup_carton;
});
},
),
Flexible(
child: Padding(
padding: const EdgeInsets.only(left: 10),
child: LocalText(context, 'box.pickup',
fontSize: 15,
color: _selectedLastmile == pickup_carton
? primaryColor
: Colors.black),
),
)
]),
),
)
],
),
),
)
],
);
final billRadioBox = Container(
child: Row(
children: [
Flexible(
child: InkWell(
final billRadioBox = Row(
children: [
Flexible(
child: InkWell(
onTap: () {
setState(() {
_billToValue = billToSender;
_billToValue = billToConsignee;
});
},
child: Row(children: <Widget>[
LocalRadio(
value: billToSender,
value: billToConsignee,
groupValue: _billToValue,
onChanged: (p0) {
setState(() {
_billToValue = billToSender;
_billToValue = billToConsignee;
});
},
),
Flexible(
child: Padding(
padding: const EdgeInsets.only(left: 10),
child: LocalText(context, 'box.sender.title',
child: LocalText(context, 'box.consignee.title',
fontSize: 15,
color: _billToValue == billToSender
color: _billToValue == billToConsignee
? primaryColor
: Colors.black),
),
)
]),
)),
Flexible(
),
),
Flexible(
child: InkWell(
onTap: () {
onTap: () {
setState(() {
_billToValue = billToSender;
});
},
child: Row(children: <Widget>[
LocalRadio(
value: billToSender,
groupValue: _billToValue,
onChanged: (p0) {
setState(() {
_billToValue = billToConsignee;
_billToValue = billToSender;
});
},
child: Row(children: <Widget>[
LocalRadio(
value: billToConsignee,
groupValue: _billToValue,
onChanged: (p0) {
setState(() {
_billToValue = billToConsignee;
});
},
),
Flexible(
child: Padding(
padding: const EdgeInsets.only(left: 10),
child: LocalText(context, 'box.consignee.title',
fontSize: 15,
color: _billToValue == billToConsignee
? primaryColor
: Colors.black),
),
)
]),
),
)
],
),
Flexible(
child: Padding(
padding: const EdgeInsets.only(left: 10),
child: LocalText(context, 'box.sender.title',
fontSize: 15,
color: _billToValue == billToSender
? primaryColor
: Colors.black),
),
)
]),
)),
],
);
final continueBtn = ContinueButton(onTap: () {
double l = double.tryParse(_lengthController.text) ?? 0;
double w = double.tryParse(_widthController.text) ?? 0;
double h = double.tryParse(_heightController.text) ?? 0;
double l = double.tryParse(lengthController.text) ?? 0;
double w = double.tryParse(widthController.text) ?? 0;
double h = double.tryParse(heightController.text) ?? 0;
if (_shipment == null) {
showMsgDialog(context, "Error", "Please select shipment");
@@ -382,17 +374,17 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
final lengthBox = BoxSizePicker(
lableKey: 'box.length',
controller: _lengthController,
controller: lengthController,
enable: isCustomSize);
final widthBox = BoxSizePicker(
lableKey: 'box.width',
controller: _widthController,
controller: widthController,
enable: isCustomSize);
final heightBox = BoxSizePicker(
lableKey: 'box.height',
controller: _heightController,
controller: heightController,
enable: isCustomSize);
final customSizeBox = Padding(

View File

@@ -37,7 +37,7 @@ class CartonSubmit extends StatelessWidget {
final OnPrevious? onPrevious;
final bool isNew;
const CartonSubmit(
{Key? key,
{super.key,
required this.sender,
required this.consingee,
required this.billToValue,
@@ -53,8 +53,7 @@ class CartonSubmit extends StatelessWidget {
this.height = 0,
this.cargoTypes = const [],
this.surchareItems = const [],
this.isNew = true})
: super(key: key);
this.isNew = true});
@override
Widget build(BuildContext context) {
@@ -89,7 +88,7 @@ class CartonSubmit extends StatelessWidget {
child: Row(
children: [
Expanded(
child: LocalText(context, 'box.sender.title',
child: LocalText(context, 'box.consignee.title',
color: primaryColor,
fontSize: 16,
fontWeight: FontWeight.normal),
@@ -97,7 +96,7 @@ class CartonSubmit extends StatelessWidget {
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 13),
child: LocalText(context, 'box.consignee.title',
child: LocalText(context, 'box.sender.title',
color: primaryColor,
fontSize: 16,
fontWeight: FontWeight.normal),
@@ -115,57 +114,58 @@ class CartonSubmit extends StatelessWidget {
padding: const EdgeInsets.all(8.0),
child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
Expanded(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(sender.name ?? "",
style: const TextStyle(
fontSize: 16.0, fontWeight: FontWeight.w500)),
sender.fcsID == null
? const SizedBox()
: Text(sender.fcsID!,
style: const TextStyle(
fontSize: 14.0, color: Colors.grey)),
],
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(consingee.name ?? "",
style: const TextStyle(
fontSize: 16.0, fontWeight: FontWeight.w500)),
consingee.fcsID == null
? const SizedBox()
: Text(consingee.fcsID!,
style: const TextStyle(
fontSize: 14.0, color: Colors.grey)),
],
),
// billToValue == billToSender
// ? billWidget(context)
// : const SizedBox()
],
),
// billToValue == billToConsignee
// ? billWidget(context)
// : const SizedBox()
],
)),
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 15),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(sender.name ?? "",
style: const TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.w500)),
sender.fcsID == null
? const SizedBox()
: Text(sender.fcsID!,
style: const TextStyle(
fontSize: 14.0, color: Colors.grey)),
],
),
),
// billToValue == billToSender
// ? billWidget(context)
// : const SizedBox()
],
),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 15),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(consingee.name ?? "",
style: const TextStyle(
fontSize: 16.0, fontWeight: FontWeight.w500)),
consingee.fcsID == null
? const SizedBox()
: Text(consingee.fcsID!,
style: const TextStyle(
fontSize: 14.0, color: Colors.grey)),
],
),
),
// billToValue == billToConsignee
// ? billWidget(context)
// : const SizedBox()
],
),
))
]),
),
),

View File

@@ -10,7 +10,6 @@ import '../../domain/entities/user.dart';
import '../main/util.dart';
import '../widgets/barcode_scanner.dart';
import '../widgets/continue_button.dart';
import '../widgets/display_text.dart';
import '../widgets/local_title.dart';
import '../widgets/previous_button.dart';
import 'model/package_selection_model.dart';
@@ -28,14 +27,14 @@ class PackageSelectionWidget extends StatefulWidget {
final OnContinue? onContinue;
const PackageSelectionWidget({
Key? key,
super.key,
required this.packages,
this.onPrevious,
this.onContinue,
required this.shipment,
required this.sender,
required this.consignee,
}) : super(key: key);
});
@override
State<PackageSelectionWidget> createState() => _PackageSelectionWidgetState();
@@ -109,30 +108,25 @@ class _PackageSelectionWidgetState extends State<PackageSelectionWidget> {
List<Package> searchResults = model.packages;
List<Package> selectedPackageList = model.selectedPackages;
final senderBox = DisplayText(
text: widget.sender.name,
labelTextKey: "box.sender.title",
iconData: MaterialCommunityIcons.account_arrow_right,
subText: Text(widget.sender.fcsID!,
style: TextStyle(fontSize: 13, color: labelColor)),
);
final senderBox = userDisplayBox(context,
lableKey: "box.sender.title",
icon: MaterialCommunityIcons.account_arrow_right,
showLink: false,
name: widget.sender.name ?? "",
fcsID: widget.sender.fcsID ?? "");
final consigneeBox = DisplayText(
text: widget.consignee.name,
labelTextKey: "box.consignee.title",
iconData: MaterialCommunityIcons.account_arrow_left,
subText: Text(widget.consignee.fcsID!,
style: TextStyle(fontSize: 13, color: labelColor)),
);
final consigneeBox = userDisplayBox(context,
showLink: false,
lableKey: "box.consignee.title",
icon: MaterialCommunityIcons.account_arrow_left,
name: widget.consignee.name,
fcsID: widget.consignee.fcsID);
final userRow = Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: senderBox,
flex: 2,
),
Flexible(child: consigneeBox)
Expanded(flex: 2, child: consigneeBox),
Flexible(child: senderBox)
],
);

View File

@@ -21,27 +21,27 @@ import 'fcs_shipment_editor.dart';
class FcsShipmentInfo extends StatefulWidget {
final FcsShipment fcsShipment;
FcsShipmentInfo({required this.fcsShipment});
const FcsShipmentInfo({super.key, required this.fcsShipment});
@override
_FcsShipmentInfoState createState() => _FcsShipmentInfoState();
}
class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
var dateFormatter = new DateFormat('dd MMM yyyy');
var dateFormatter = DateFormat('dd MMM yyyy');
final NumberFormat numberFormatter = NumberFormat("#,###");
late FcsShipment _fcsShipment;
bool _isLoading = false;
TextEditingController _shipmentNumberController = new TextEditingController();
TextEditingController _cutoffDateController = new TextEditingController();
TextEditingController _arrivalDateController = new TextEditingController();
TextEditingController _departureDateControler = new TextEditingController();
TextEditingController _shipmentTypeControler = new TextEditingController();
TextEditingController _consigneeController = new TextEditingController();
TextEditingController _portController = new TextEditingController();
TextEditingController _destinationController = new TextEditingController();
TextEditingController _statusController = new TextEditingController();
TextEditingController shipmentNumberController = TextEditingController();
TextEditingController cutoffDateController = TextEditingController();
TextEditingController arrivalDateController = TextEditingController();
TextEditingController departureDateControler = TextEditingController();
TextEditingController shipmentTypeControler = TextEditingController();
TextEditingController consigneeController = TextEditingController();
TextEditingController portController = TextEditingController();
TextEditingController destinationController = TextEditingController();
TextEditingController statusController = TextEditingController();
@override
void initState() {
@@ -51,21 +51,24 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
}
_load() {
_shipmentNumberController.text = _fcsShipment.shipmentNumber ?? "";
if (_fcsShipment.cutoffDate != null)
_cutoffDateController.text =
shipmentNumberController.text = _fcsShipment.shipmentNumber ?? "";
if (_fcsShipment.cutoffDate != null) {
cutoffDateController.text =
dateFormatter.format(_fcsShipment.cutoffDate!);
if (_fcsShipment.etaDate != null)
_arrivalDateController.text = dateFormatter.format(_fcsShipment.etaDate!);
if (_fcsShipment.departureDate != null)
_departureDateControler.text =
}
if (_fcsShipment.etaDate != null) {
arrivalDateController.text = dateFormatter.format(_fcsShipment.etaDate!);
}
if (_fcsShipment.departureDate != null) {
departureDateControler.text =
dateFormatter.format(_fcsShipment.departureDate!);
}
_shipmentTypeControler.text = _fcsShipment.shipmentTypeName ?? "";
_consigneeController.text = _fcsShipment.consigneeName ?? '';
_portController.text = _fcsShipment.loadingPortName ?? '';
_destinationController.text = _fcsShipment.destinationPortName ?? '';
_statusController.text = _fcsShipment.status ?? "";
shipmentTypeControler.text = _fcsShipment.shipmentTypeName ?? "";
consigneeController.text = _fcsShipment.consigneeName ?? '';
portController.text = _fcsShipment.loadingPortName ?? '';
destinationController.text = _fcsShipment.destinationPortName ?? '';
statusController.text = _fcsShipment.status ?? "";
}
@override
@@ -76,12 +79,12 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
@override
Widget build(BuildContext context) {
final cutoffDateDBox = DisplayText(
text: _cutoffDateController.text,
text: cutoffDateController.text,
labelTextKey: "FCSshipment.cutoff_date",
iconData: Icons.date_range,
);
final etaBox = DisplayText(
text: _arrivalDateController.text,
text: arrivalDateController.text,
labelTextKey: "FCSshipment.ETA",
iconData: Icons.date_range,
);
@@ -99,31 +102,31 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
);
final shipTypeBox = DisplayText(
text: _shipmentTypeControler.text,
text: shipmentTypeControler.text,
labelTextKey: "FCSshipment.shipment_type",
iconData: Ionicons.ios_airplane,
);
final consigneeBox = DisplayText(
text: _consigneeController.text,
text: consigneeController.text,
labelTextKey: "FCSshipment.consignee",
iconData: Icons.work,
);
final portBox = DisplayText(
text: _portController.text,
text: portController.text,
labelTextKey: "FCSshipment.port_of_loading",
iconData: FontAwesomeIcons.ship,
);
final destinationBox = DisplayText(
text: _destinationController.text,
text: destinationController.text,
labelTextKey: "FCSshipment.final_destination",
iconData: MaterialCommunityIcons.location_enter,
);
final statusBox = DisplayText(
text: _statusController.text,
text: statusController.text,
labelTextKey: "FCSshipment.status",
iconData: Feather.clock,
);
@@ -185,8 +188,15 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
inAsyncCall: _isLoading,
child: Scaffold(
appBar: LocalAppBar(
titleWidget: Text(_shipmentNumberController.text,
style: TextStyle(fontSize: 20, color: primaryColor)),
titleWidget: Column(
children: [
LocalText(context, "FCSshipment.form.title",
fontSize: 20, color: primaryColor),
Text(shipmentNumberController.text,
style: TextStyle(fontSize: 15, color: Colors.black))
],
),
backgroundColor: Colors.white,
labelColor: primaryColor,
arrowColor: primaryColor,

View File

@@ -471,16 +471,22 @@ Widget userSearchBox(BuildContext context,
}
Widget userDisplayBox(BuildContext context,
{required String lableKey, IconData? icon, String? name, String? fcsID}) {
{required String lableKey,
IconData? icon,
String? name,
String? fcsID,
bool showLink = true}) {
return fcsID != null && fcsID != ""
? Padding(
padding: const EdgeInsets.only(top: 8.0, bottom: 8),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(right: 15),
child: Icon(icon, color: primaryColor)),
icon != null
? Padding(
padding: const EdgeInsets.only(right: 15),
child: Icon(icon, color: primaryColor))
: const SizedBox(),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -489,16 +495,18 @@ Widget userDisplayBox(BuildContext context,
color: Colors.black54, fontSize: 15),
InkWell(
onTap: null,
child: Text(
name ?? '',
style: TextStyle(
shadows: [
Shadow(color: linkColor, offset: Offset(0, -2))
],
color: Colors.transparent,
decoration: TextDecoration.underline,
decorationColor: linkColor),
),
child: Text(name ?? '',
style: showLink
? TextStyle(
shadows: [
Shadow(
color: linkColor,
offset: Offset(0, -2))
],
color: Colors.transparent,
decoration: TextDecoration.underline,
decorationColor: linkColor)
: TextStyle(color: Colors.black)),
),
Text(fcsID,
style: TextStyle(fontSize: 13, color: labelColor))

View File

@@ -13,27 +13,46 @@ class DisplayText extends StatelessWidget {
final bool? withBorder;
final Color? borderColor;
final Widget? icon;
const DisplayText({
Key? key,
this.text,
this.subText,
this.labelTextKey,
this.iconData,
this.maxLines = 1,
this.withBorder = false,
this.borderColor,
this.icon,
}) : super(key: key);
final bool showLabelLink;
final Function()? onTapLabel;
const DisplayText(
{super.key,
this.text,
this.subText,
this.labelTextKey,
this.iconData,
this.maxLines = 1,
this.withBorder = false,
this.borderColor,
this.icon,
this.showLabelLink = false,
this.onTapLabel});
@override
Widget build(BuildContext context) {
var languageModel = Provider.of<LanguageModel>(context);
var labelStyle = languageModel.isEng
? TextStyle(color: Colors.black54, fontSize: 15)
: TextStyle(
color: Colors.black54, fontFamily: "Myanmar3", fontSize: 15);
? showLabelLink
? TextStyle(
color: Colors.transparent,
fontSize: 15,
decoration: TextDecoration.underline,
decorationColor: linkColor,
shadows: [Shadow(color: linkColor, offset: Offset(0, -2))],
)
: TextStyle(color: Colors.black54, fontSize: 15)
: showLabelLink
? TextStyle(
color: Colors.transparent,
fontFamily: "Myanmar3",
fontSize: 15,
decoration: TextDecoration.underline,
decorationColor: linkColor,
shadows: [Shadow(color: linkColor, offset: Offset(0, -2))],
)
: TextStyle(
color: Colors.black54, fontFamily: "Myanmar3", fontSize: 15);
var textStyle = languageModel.isEng
? TextStyle(color: Colors.black)
: TextStyle(color: Colors.black, fontFamily: "Myanmar3");
@@ -54,16 +73,18 @@ class DisplayText extends StatelessWidget {
color: primaryColor,
),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
labelTextKey == null
? Container()
: Text(
AppTranslations.of(context)!.text(labelTextKey!),
style: labelStyle,
: InkWell(
onTap: showLabelLink ? onTapLabel : null,
child: Text(
AppTranslations.of(context)!.text(labelTextKey!),
style: labelStyle,
),
),
text == null
? Container()
@@ -71,9 +92,7 @@ class DisplayText extends StatelessWidget {
text!,
style: textStyle,
),
subText == null
? Container()
: subText!,
subText == null ? Container() : subText!,
],
),
),