
Integrates the `toastification` package to provide clear and non-intrusive user feedback for operations like product not found. Refactors the reception scan page UI by extracting reusable widgets for the scan information text, the scan box, and the flash button. This improves code organization and readability. Switches the data source for reception details from API calls to the local ObjectBox database, improving performance and enabling offline access for this specific data. Corrects the display of scanned product information to show the barcode instead of a generic ID. Updates `go_router` to version 16.0.0.
180 lines
6.8 KiB
Dart
180 lines
6.8 KiB
Dart
import 'package:e_scan/backend/objectbox/entities/product/product_entity.dart';
|
|
import 'package:e_scan/themes/app_theme.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class ProductScannedComponent extends StatefulWidget {
|
|
const ProductScannedComponent({
|
|
super.key,
|
|
required this.productStruct,
|
|
this.onRescan,
|
|
this.onDetails,
|
|
});
|
|
final ProductEntity productStruct;
|
|
|
|
final Future Function()? onRescan;
|
|
final Function()? onDetails;
|
|
|
|
@override
|
|
State<ProductScannedComponent> createState() =>
|
|
_ProductScannedComponentState();
|
|
}
|
|
|
|
class _ProductScannedComponentState extends State<ProductScannedComponent> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Padding(
|
|
padding: EdgeInsets.all(24.0),
|
|
child: Container(
|
|
width: double.infinity,
|
|
decoration: BoxDecoration(
|
|
color: AppTheme.of(context).secondaryBackground,
|
|
borderRadius: BorderRadius.circular(16.0),
|
|
),
|
|
child: Padding(
|
|
padding: EdgeInsets.all(16.0),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
spacing: 16,
|
|
children: [
|
|
Container(
|
|
width: 80.0,
|
|
height: 80.0,
|
|
decoration: BoxDecoration(
|
|
color: Colors.green,
|
|
shape: BoxShape.circle,
|
|
),
|
|
child: Align(
|
|
alignment: AlignmentDirectional(0.0, 0.0),
|
|
child: Icon(
|
|
Icons.check_rounded,
|
|
color: Colors.white,
|
|
size: 40.0,
|
|
),
|
|
),
|
|
),
|
|
Text('Scan terminé!', textAlign: TextAlign.center),
|
|
Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 16.0),
|
|
child: SizedBox(
|
|
width: double.infinity,
|
|
child: Padding(
|
|
padding: EdgeInsets.symmetric(vertical: 16.0),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
spacing: 8,
|
|
children: [
|
|
SizedBox(height: 15),
|
|
Divider(
|
|
height: 1.0,
|
|
thickness: 1.0,
|
|
color: Colors.grey.shade300,
|
|
),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text('Code scanné:'),
|
|
Text(widget.productStruct.barcode.toString()),
|
|
],
|
|
),
|
|
Divider(
|
|
height: 1.0,
|
|
thickness: 1.0,
|
|
color: Colors.grey.shade300,
|
|
),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text('Produit: '),
|
|
Expanded(
|
|
child: Text(
|
|
widget.productStruct.displayName ?? '',
|
|
textAlign: TextAlign.end,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
// Row(
|
|
// mainAxisSize: MainAxisSize.max,
|
|
// mainAxisAlignment:
|
|
// MainAxisAlignment.spaceBetween,
|
|
// children: [Text('Prix:'), Text('4,99 €')],
|
|
// ),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
spacing: 12,
|
|
children: [
|
|
Expanded(
|
|
child: FilledButton.tonal(
|
|
style: ButtonStyle(
|
|
backgroundColor: WidgetStatePropertyAll(
|
|
AppTheme.of(context).warning,
|
|
),
|
|
),
|
|
onPressed: () async {
|
|
await widget.onDetails?.call();
|
|
},
|
|
child: Row(
|
|
spacing: 5,
|
|
children: [
|
|
Icon(Icons.exit_to_app),
|
|
Text(
|
|
'Terminer',
|
|
style: AppTheme.of(context).bodyMedium,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: ElevatedButton(
|
|
style: ButtonStyle(
|
|
elevation: WidgetStatePropertyAll(10),
|
|
backgroundColor: WidgetStatePropertyAll(
|
|
AppTheme.of(context).primary,
|
|
),
|
|
),
|
|
onPressed: () {
|
|
widget.onRescan?.call();
|
|
},
|
|
child: Row(
|
|
spacing: 5,
|
|
children: [
|
|
Icon(
|
|
Icons.qr_code,
|
|
color: AppTheme.of(context).white,
|
|
),
|
|
Text(
|
|
'Continuer',
|
|
style: AppTheme.of(context).bodyMedium.override(
|
|
color: AppTheme.of(context).white,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|