barcode_scanner/lib/components/quick_action_component.dart
mandreshope ba1d7a6264 refactor: Refines reception validation and quick actions
Allows reception validation regardless of its synchronization status, enabling more flexible use cases.

Simplifies the quick actions available on the reception list page by removing the 'Add' and 'Scan' buttons, retaining only the 'Search' option.

Adds vertical spacing before the search button within the QuickActionComponent for improved visual layout.
2025-07-31 14:25:03 +03:00

135 lines
4.5 KiB
Dart

import 'package:e_scan/components/components.dart';
import 'package:e_scan/themes/app_theme.dart';
import 'package:flutter/material.dart';
class QuickActionComponent extends StatelessWidget {
const QuickActionComponent({
super.key,
this.onTapAdd,
this.onTapScan,
this.onTapSearch,
this.onTapValidateReception,
this.onTapSyncReception,
this.syncReceptionLoading = false,
this.validateReceptionLoading = false,
});
final VoidCallback? onTapAdd;
final VoidCallback? onTapScan;
final VoidCallback? onTapSearch;
final VoidCallback? onTapValidateReception;
final VoidCallback? onTapSyncReception;
final bool syncReceptionLoading;
final bool validateReceptionLoading;
@override
Widget build(BuildContext context) {
return Card(
elevation: 0,
color: AppTheme.of(context).secondaryBackground,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side: BorderSide(color: AppTheme.of(context).alternate),
),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
'Actions Rapides',
style: AppTheme.of(
context,
).bodyMedium.copyWith(fontWeight: FontWeight.bold),
),
const Spacer(),
// Container(
// padding: const EdgeInsets.symmetric(
// horizontal: 10,
// vertical: 4,
// ),
// decoration: BoxDecoration(
// color: AppTheme.of(context).alternate,
// borderRadius: BorderRadius.circular(20),
// ),
// child: Text(
// '3 en attente',
// style: AppTheme.of(context).bodySmall,
// ),
// ),
],
),
if (onTapValidateReception != null) ...[
const SizedBox(height: 16),
SizedBox(
width: double.maxFinite,
child: PrimaryButtonComponent(
loading: validateReceptionLoading,
centered: true,
leading: Icon(Icons.save, color: AppTheme.of(context).white),
text: 'Valider la réception',
onPressed: onTapValidateReception,
),
),
],
if (onTapSyncReception != null) ...[
const SizedBox(height: 16),
SizedBox(
width: double.maxFinite,
child: PrimaryButtonComponent(
loading: syncReceptionLoading,
centered: true,
leading: Icon(
Icons.cloud_upload_outlined,
color: AppTheme.of(context).white,
),
text: 'Synchroniser les données',
onPressed: onTapSyncReception,
),
),
],
if (onTapAdd != null) ...[
const SizedBox(height: 16),
SizedBox(
width: double.maxFinite,
child: PrimaryButtonComponent(
centered: true,
leading: Icon(Icons.add, color: AppTheme.of(context).white),
text: 'Nouvelle Réception',
onPressed: onTapAdd,
),
),
],
if (onTapScan != null) ...[
const SizedBox(height: 12),
SizedBox(
width: double.maxFinite,
child: OutlineButtonComponent(
centered: true,
leading: const Icon(Icons.qr_code_scanner),
text: 'Scanner Code-Barres',
onPressed: onTapScan,
),
),
const SizedBox(height: 12),
],
if (onTapSearch != null) ...[
const SizedBox(height: 12),
SizedBox(
width: double.maxFinite,
child: OutlineButtonComponent(
centered: true,
leading: const Icon(Icons.search),
text: 'Rechercher Existant',
onPressed: onTapSearch,
),
),
],
],
),
),
);
}
}