196 lines
7.1 KiB
Dart
196 lines
7.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:dart_core_sdk/handlingunit.pb.dart';
|
|
import 'package:sampleapp/globals.dart';
|
|
import 'package:sampleapp/widgets/components/reflex_alert.dart';
|
|
import 'package:sampleapp/widgets/components/reflex_button.dart';
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
|
|
import 'reflex_box.dart';
|
|
|
|
class ReflexHUInfo extends StatefulWidget {
|
|
final Handlingunit hu;
|
|
final bool showArticles;
|
|
|
|
const ReflexHUInfo({super.key, required this.hu, required this.showArticles});
|
|
|
|
@override
|
|
_ReflexHUInfoState createState() => _ReflexHUInfoState();
|
|
}
|
|
|
|
class _ReflexHUInfoState extends State<ReflexHUInfo> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
String _translateUnit(String unit) {
|
|
switch (unit) {
|
|
case "KILOGRAM":
|
|
return "kg";
|
|
case "CENTIMETER":
|
|
return "cm";
|
|
default:
|
|
return "";
|
|
}
|
|
}
|
|
|
|
Future<void> _copyToClipboard(String key, String value) {
|
|
return Clipboard.setData(ClipboardData(text: value)).then((_) =>
|
|
ScaffoldMessenger.of(context)
|
|
.showSnackBar(SnackBar(content: Text("$key ${AppLocalizations.of(context)!.copied}"))));
|
|
}
|
|
|
|
List<Widget> _buildArticles() {
|
|
return [
|
|
const SizedBox(height: 20),
|
|
Text(AppLocalizations.of(context)!.items,
|
|
style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
|
|
const SizedBox(height: 5),
|
|
Expanded(
|
|
child: ReflexBox(
|
|
child: Scrollbar(
|
|
child: ListView(
|
|
padding: const EdgeInsets.symmetric(horizontal: 10),
|
|
shrinkWrap: true,
|
|
children: [
|
|
...widget.hu.payload.preparedContents.map((e) => Row(
|
|
children: [
|
|
Expanded(
|
|
flex: 2,
|
|
child: TextField(
|
|
enabled: false,
|
|
style: const TextStyle(
|
|
color: Colors.black,
|
|
),
|
|
decoration: InputDecoration(
|
|
border: InputBorder.none,
|
|
labelText: AppLocalizations.of(context)!.itemId,
|
|
),
|
|
controller:
|
|
TextEditingController(text: e.goods.itemID),
|
|
)),
|
|
Expanded(
|
|
flex: 1,
|
|
child: TextField(
|
|
enabled: false,
|
|
style: const TextStyle(
|
|
color: Colors.black,
|
|
),
|
|
decoration: InputDecoration(
|
|
border: InputBorder.none,
|
|
labelText: AppLocalizations.of(context)!.quantity,
|
|
),
|
|
controller: TextEditingController(
|
|
text: e.quantity.value!.toString()),
|
|
)),
|
|
],
|
|
)),
|
|
],
|
|
),
|
|
),
|
|
)),
|
|
];
|
|
}
|
|
|
|
Widget _buildHU() {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(AppLocalizations.of(context)!.informations,
|
|
style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
|
|
const SizedBox(height: 5),
|
|
ReflexBox(
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 10),
|
|
child: Column(children: [
|
|
TextField(
|
|
enabled: false,
|
|
style: const TextStyle(
|
|
fontSize: 24,
|
|
color: Colors.black,
|
|
),
|
|
decoration: InputDecoration(
|
|
border: InputBorder.none,
|
|
labelText: AppLocalizations.of(context)!.handlingUnitIdentifier,
|
|
),
|
|
controller: TextEditingController(text: widget.hu.iD.refID),
|
|
),
|
|
TextField(
|
|
readOnly: true,
|
|
style: const TextStyle(
|
|
color: Colors.black,
|
|
),
|
|
decoration: InputDecoration(
|
|
suffixIcon: IconButton(
|
|
onPressed: () => _copyToClipboard(AppLocalizations.of(context)!.trackingNumber,
|
|
widget.hu.payload.currentTrackingSummary.trackingID),
|
|
icon: const Icon(Icons.copy)),
|
|
border: InputBorder.none,
|
|
labelText: AppLocalizations.of(context)!.trackingNumber,
|
|
labelStyle: const TextStyle(color: Colors.grey),
|
|
),
|
|
controller: TextEditingController(
|
|
text: widget.hu.payload.currentTrackingSummary.trackingID),
|
|
),
|
|
Row(
|
|
children: [
|
|
Flexible(
|
|
flex: 2,
|
|
child: TextField(
|
|
enabled: false,
|
|
style: const TextStyle(
|
|
color: Colors.black,
|
|
),
|
|
decoration: InputDecoration(
|
|
border: InputBorder.none,
|
|
labelText: AppLocalizations.of(context)!.handlingUnitType,
|
|
),
|
|
controller: TextEditingController(
|
|
text: widget.hu.payload.information.containerType),
|
|
)),
|
|
Expanded(
|
|
flex: 2,
|
|
child: TextField(
|
|
enabled: false,
|
|
style: const TextStyle(
|
|
color: Colors.black,
|
|
),
|
|
decoration: InputDecoration(
|
|
border: InputBorder.none,
|
|
labelText: AppLocalizations.of(context)!.dimensions,
|
|
),
|
|
controller: TextEditingController(
|
|
text:
|
|
"${widget.hu.payload.information.height.value} x ${widget.hu.payload.information.width.value} x ${widget.hu.payload.information.length!.value} ${_translateUnit(widget.hu.payload.information.length.unit.name)}"),
|
|
)),
|
|
Flexible(
|
|
child: TextField(
|
|
enabled: false,
|
|
style: const TextStyle(
|
|
color: Colors.black,
|
|
),
|
|
decoration: InputDecoration(
|
|
border: InputBorder.none,
|
|
labelText: AppLocalizations.of(context)!.weight
|
|
),
|
|
controller: TextEditingController(
|
|
text:
|
|
"${widget.hu.payload.information.weight.value} ${_translateUnit(widget.hu.payload.information.weight.unit.name)}"),
|
|
),
|
|
),
|
|
],
|
|
)
|
|
]),
|
|
)),
|
|
if (widget.showArticles) ..._buildArticles(),
|
|
],
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return _buildHU();
|
|
}
|
|
}
|