
import '../bloc/qr_scan_bloc.dart';
import '../bloc/qr_scan_event.dart';

class QrScanViewModel {
  final QrScanBloc bloc;

  QrScanViewModel(this.bloc);

  /// Called when a QR code is detected
  void onQrDetected(String code) {
    final trimmedCode = code.trim();
    if (trimmedCode.isEmpty) return;
    bloc.add(QrCodeDetected(trimmedCode));
  }

  /// Called when user manually enters code
  void onManualEntry(String code) {
    final trimmedCode = code.trim();
    if (trimmedCode.isEmpty) return;
    bloc.add(ManualCodeEntered(trimmedCode));
  }
}
