
Refines the `ProductScannedComponent` by updating button labels, icons, and actions to clarify the user workflow. The "Nouveau scan" button is now "Terminer" (onDetails), and "Voir détails" is "Continuer" (onRescan). Transitions the `ReceptionScanPageModel` to fetch reception data from the local ObjectBox database, enhancing offline capabilities and responsiveness. Prepares for local barcode processing by introducing a new handler.
49 lines
1.6 KiB
Dart
49 lines
1.6 KiB
Dart
import 'package:e_scan/backend/objectbox/entities/stock_picking/stock_picking_record_entity.dart';
|
|
import 'package:e_scan/backend/objectbox/objectbox_manager.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
import 'package:mobile_scanner/mobile_scanner.dart';
|
|
|
|
part 'reception_scan_page_model.freezed.dart';
|
|
|
|
final receptionScanPageModelProvider =
|
|
StateNotifierProvider.autoDispose<
|
|
ReceptionScanPageModel,
|
|
ReceptionScanPageModelState
|
|
>((ref) {
|
|
return ReceptionScanPageModel();
|
|
});
|
|
|
|
class ReceptionScanPageModel
|
|
extends StateNotifier<ReceptionScanPageModelState> {
|
|
ReceptionScanPageModel() : super(const ReceptionScanPageModelState());
|
|
|
|
Future getReceptionById({required int id}) async {
|
|
try {
|
|
final stockPickingRecords = objectboxManager.store
|
|
.box<StockPickingRecordEntity>();
|
|
state = state.copyWith(loading: true);
|
|
final entity = stockPickingRecords.get(id);
|
|
state = state.copyWith(loading: false, reception: entity);
|
|
} catch (e) {
|
|
state = state.copyWith(loading: false);
|
|
}
|
|
}
|
|
|
|
Future handleBarcode({required BarcodeCapture barcodeCapture}) async {
|
|
try {
|
|
final stockPickingRecords = objectboxManager.store
|
|
.box<StockPickingRecordEntity>();
|
|
} catch (e) {}
|
|
}
|
|
}
|
|
|
|
@freezed
|
|
abstract class ReceptionScanPageModelState with _$ReceptionScanPageModelState {
|
|
const factory ReceptionScanPageModelState({
|
|
StockPickingRecordEntity? reception,
|
|
@Default(false) bool loading,
|
|
}) = _ReceptionScanPageModelState;
|
|
}
|