You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
134 lines
3.9 KiB
Dart
134 lines
3.9 KiB
Dart
part of 'fingerprint_bloc.dart';
|
|
|
|
enum DocumentType { nationalId, passport }
|
|
|
|
enum FormStatus {
|
|
idle,
|
|
loggingIn,
|
|
connecting,
|
|
scanning,
|
|
scanned,
|
|
verifying,
|
|
verified,
|
|
error,
|
|
}
|
|
|
|
class FingerprintFormState extends Equatable {
|
|
final DocumentType documentType;
|
|
|
|
/// The selected finger's numeric key from [fingerIndexMap].
|
|
/// Defaults to 1 (Right Thumb).
|
|
final int selectedFingerIndex;
|
|
|
|
final String nationalIdInput;
|
|
final String nationality;
|
|
final String passportNumber;
|
|
final FormStatus status;
|
|
final String? base64Data;
|
|
final String? errorMessage;
|
|
|
|
/// Live device status text shown during the connect retry loop.
|
|
final String? deviceStatusMessage;
|
|
|
|
/// True once the scanner has successfully connected.
|
|
final bool isDeviceConnected;
|
|
|
|
/// True when the Scan button triggered the connection phase
|
|
/// (so the scan button shows "Connecting…" instead of the connect button).
|
|
final bool isScanConnecting;
|
|
final String? nationalIdError;
|
|
final String? nationalityError;
|
|
final String? passportNumberError;
|
|
|
|
/// Populated after a successful verification API call.
|
|
final AuthResultUiModel? authResult;
|
|
|
|
const FingerprintFormState({
|
|
this.documentType = DocumentType.nationalId,
|
|
this.selectedFingerIndex = 1,
|
|
this.nationalIdInput = '',
|
|
this.nationality = '',
|
|
this.passportNumber = '',
|
|
this.status = FormStatus.idle,
|
|
this.base64Data,
|
|
this.errorMessage,
|
|
this.deviceStatusMessage,
|
|
this.isDeviceConnected = false,
|
|
this.isScanConnecting = false,
|
|
this.nationalIdError,
|
|
this.nationalityError,
|
|
this.passportNumberError,
|
|
this.authResult,
|
|
});
|
|
|
|
FingerprintFormState copyWith({
|
|
DocumentType? documentType,
|
|
int? selectedFingerIndex,
|
|
String? nationalIdInput,
|
|
String? nationality,
|
|
String? passportNumber,
|
|
FormStatus? status,
|
|
String? base64Data,
|
|
String? errorMessage,
|
|
String? deviceStatusMessage,
|
|
bool? isDeviceConnected,
|
|
bool? isScanConnecting,
|
|
String? nationalIdError,
|
|
String? nationalityError,
|
|
String? passportNumberError,
|
|
AuthResultUiModel? authResult,
|
|
bool clearBase64 = false,
|
|
bool clearError = false,
|
|
bool clearDeviceStatus = false,
|
|
bool clearNationalIdError = false,
|
|
bool clearNationalityError = false,
|
|
bool clearPassportNumberError = false,
|
|
bool clearAuthResult = false,
|
|
}) {
|
|
return FingerprintFormState(
|
|
documentType: documentType ?? this.documentType,
|
|
selectedFingerIndex: selectedFingerIndex ?? this.selectedFingerIndex,
|
|
nationalIdInput: nationalIdInput ?? this.nationalIdInput,
|
|
nationality: nationality ?? this.nationality,
|
|
passportNumber: passportNumber ?? this.passportNumber,
|
|
status: status ?? this.status,
|
|
base64Data: clearBase64 ? null : (base64Data ?? this.base64Data),
|
|
errorMessage: clearError ? null : (errorMessage ?? this.errorMessage),
|
|
deviceStatusMessage: clearDeviceStatus
|
|
? null
|
|
: (deviceStatusMessage ?? this.deviceStatusMessage),
|
|
isDeviceConnected: isDeviceConnected ?? this.isDeviceConnected,
|
|
isScanConnecting: isScanConnecting ?? this.isScanConnecting,
|
|
nationalIdError:
|
|
clearNationalIdError ? null : (nationalIdError ?? this.nationalIdError),
|
|
nationalityError:
|
|
clearNationalityError ? null : (nationalityError ?? this.nationalityError),
|
|
passportNumberError: clearPassportNumberError
|
|
? null
|
|
: (passportNumberError ?? this.passportNumberError),
|
|
authResult: clearAuthResult ? null : (authResult ?? this.authResult),
|
|
);
|
|
}
|
|
|
|
@override
|
|
List<Object?> get props => [
|
|
documentType,
|
|
selectedFingerIndex,
|
|
nationalIdInput,
|
|
nationality,
|
|
passportNumber,
|
|
status,
|
|
base64Data,
|
|
errorMessage,
|
|
deviceStatusMessage,
|
|
isDeviceConnected,
|
|
isScanConnecting,
|
|
nationalIdError,
|
|
nationalityError,
|
|
passportNumberError,
|
|
authResult,
|
|
];
|
|
}
|
|
|
|
|