102 lines
3.2 KiB
Dart
102 lines
3.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:dart_core_sdk/handlingunit.pb.dart';
|
|
import 'package:sampleapp/widgets/components/reflex_button.dart';
|
|
import 'package:sampleapp/widgets/components/reflex_hu_info.dart';
|
|
|
|
import '../../globals.dart';
|
|
import '../components/reflex_alert.dart';
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
|
|
class ScanResult extends StatefulWidget {
|
|
final String refID;
|
|
final Handlingunit? handlingUnit;
|
|
final String projectID;
|
|
final void Function(bool isDeliveryValid) onDeliveryConfirmed;
|
|
|
|
const ScanResult(
|
|
{super.key,
|
|
required this.projectID,
|
|
required this.onDeliveryConfirmed,
|
|
this.handlingUnit, required this.refID});
|
|
|
|
@override
|
|
_ScanResultState createState() => _ScanResultState();
|
|
}
|
|
|
|
class _ScanResultState extends State<ScanResult> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
void _onAnomalyPressed() async {
|
|
widget.onDeliveryConfirmed(false);
|
|
}
|
|
|
|
void _onValidPressed() async {
|
|
widget.onDeliveryConfirmed(true);
|
|
}
|
|
|
|
Widget _buildNoHu() {
|
|
return Column(children: [
|
|
TextField(
|
|
decoration: InputDecoration(
|
|
labelText: AppLocalizations.of(context)!.handlingUnitIdentifier,
|
|
),
|
|
controller: TextEditingController(text: widget.refID),
|
|
readOnly: true,
|
|
),
|
|
ReflexAlert(
|
|
icon: Icons.access_alarm_rounded,
|
|
text:
|
|
"${AppLocalizations.of(context)!.noHandlingUnitFound}\n${AppLocalizations.of(context)!.pleaseTryAgain}.",
|
|
color: Globals.RP_DANGER_COLOR),
|
|
ReflexButton(
|
|
text: AppLocalizations.of(context)!.tryAgain,
|
|
onPressed: () => Navigator.pop(context),
|
|
isFullWidth: true,
|
|
),
|
|
]);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Padding(
|
|
padding: const EdgeInsets.all(15.0),
|
|
child: widget.handlingUnit == null
|
|
? _buildNoHu()
|
|
: Column(children: [
|
|
Expanded(
|
|
child: ReflexHUInfo(
|
|
hu: widget.handlingUnit!,
|
|
showArticles: true,
|
|
)),
|
|
SizedBox(height: 10),
|
|
ReflexAlert(
|
|
text:
|
|
AppLocalizations.of(context)!.pleaseIndicateAnomaly,
|
|
icon: Icons.info_outline_rounded),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: ReflexButton(
|
|
text: AppLocalizations.of(context)!.anomaly,
|
|
color: Globals.RP_DANGER_COLOR,
|
|
onPressed: () => _onAnomalyPressed(),
|
|
),
|
|
),
|
|
const SizedBox(width: 10),
|
|
Expanded(
|
|
child: ReflexButton(
|
|
text: AppLocalizations.of(context)!.validDelivery,
|
|
color: Globals.RP_SUCCESS_COLOR,
|
|
onPressed: () => _onValidPressed(),
|
|
),
|
|
),
|
|
],
|
|
)
|
|
])));
|
|
}
|
|
}
|