You've already forked flutter-rp-example
First commit
This commit is contained in:
101
lib/widgets/scan_flow/scan_result_screen.dart
Normal file
101
lib/widgets/scan_flow/scan_result_screen.dart
Normal file
@@ -0,0 +1,101 @@
|
||||
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(),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
])));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user