barcode_scanner/lib/components/product_scanned_component.dart
2025-06-19 16:41:41 +03:00

189 lines
7.5 KiB
Dart

import 'package:flutter/material.dart';
class ProductScannedComponent extends StatefulWidget {
const ProductScannedComponent({
super.key,
required this.codeScanned,
required this.productName,
required this.brands,
required this.img,
this.onRescan,
this.onDetails,
});
final String codeScanned;
final String productName;
final String brands;
final String img;
final Future Function()? onRescan;
final Future Function()? onDetails;
@override
State<ProductScannedComponent> createState() =>
_ProductScannedComponentState();
}
class _ProductScannedComponentState extends State<ProductScannedComponent> {
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
height: double.infinity,
decoration: BoxDecoration(color: Color(0x80000000)),
child: Padding(
padding: EdgeInsets.all(24.0),
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: EdgeInsets.all(24.0),
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
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.all(16.0),
child: Container(
width: double.infinity,
child: Padding(
padding: EdgeInsets.all(16.0),
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 8,
children: [
Align(
alignment: Alignment.topCenter,
child: Image.network(
widget.img,
width: 60,
height: 60,
),
),
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text('Type de code:'),
Text('EAN-13'),
],
),
Divider(
height: 1.0,
thickness: 1.0,
color: Colors.grey.shade300,
),
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text('Code scanné:'),
Text(widget.codeScanned),
],
),
Divider(
height: 1.0,
thickness: 1.0,
color: Colors.grey.shade300,
),
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text('Produit:'),
Expanded(child: Text(widget.productName)),
],
),
Divider(
height: 1.0,
thickness: 1.0,
color: Colors.grey.shade300,
),
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text('Marque:'),
Text(widget.brands),
],
),
Divider(
height: 1.0,
thickness: 1.0,
color: Colors.grey.shade300,
),
// Row(
// mainAxisSize: MainAxisSize.max,
// mainAxisAlignment:
// MainAxisAlignment.spaceBetween,
// children: [Text('Prix:'), Text('4,99 €')],
// ),
],
),
),
),
),
Row(
mainAxisSize: MainAxisSize.max,
spacing: 12,
children: [
Expanded(
child: TextButton(
onPressed: () async {
await widget.onRescan?.call();
},
child: Text('Nouveau scan'),
),
),
Expanded(
child: TextButton(
onPressed: () async {
await widget.onDetails?.call();
},
child: Text('Voir détails'),
),
),
],
),
],
),
),
),
),
],
),
),
);
}
}