feat: add alot
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../viewmodels/pin_lock_view_model.dart';
|
||||
import '../l10n/app_localizations.dart';
|
||||
import '../l10n/app_localizations_helpers.dart';
|
||||
import '../models/app_error.dart';
|
||||
import '../viewmodels/pin_lock_view_model.dart';
|
||||
|
||||
enum PinEntryMode { unlock, create }
|
||||
|
||||
@@ -18,7 +19,7 @@ class PinEntryView extends StatefulWidget {
|
||||
final bool isAdmin;
|
||||
final Future<bool> Function(String)? onVerify;
|
||||
final Future<bool> Function(String)? onSet;
|
||||
final String? Function()? errorMessage;
|
||||
final AppError? Function()? error;
|
||||
final bool showBack;
|
||||
|
||||
const PinEntryView({
|
||||
@@ -28,7 +29,7 @@ class PinEntryView extends StatefulWidget {
|
||||
this.isAdmin = false,
|
||||
this.onVerify,
|
||||
this.onSet,
|
||||
this.errorMessage,
|
||||
this.error,
|
||||
this.showBack = false,
|
||||
});
|
||||
|
||||
@@ -123,7 +124,7 @@ class _PinEntryViewState extends State<PinEntryView> {
|
||||
_firstEntry = null;
|
||||
_isConfirmStep = false;
|
||||
});
|
||||
_fail(l10n.localizedError(_errorMessage()));
|
||||
_fail(l10n.errorText(_error()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -136,7 +137,7 @@ class _PinEntryViewState extends State<PinEntryView> {
|
||||
if (ok) {
|
||||
widget.onSuccess?.call();
|
||||
} else {
|
||||
_fail(l10n.localizedError(_errorMessage()));
|
||||
_fail(l10n.errorText(_error()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,11 +155,11 @@ class _PinEntryViewState extends State<PinEntryView> {
|
||||
return context.read<PinLockViewModel>().verify(pin);
|
||||
}
|
||||
|
||||
String? _errorMessage() {
|
||||
final callback = widget.errorMessage;
|
||||
AppError? _error() {
|
||||
final callback = widget.error;
|
||||
if (callback != null) return callback();
|
||||
|
||||
return context.read<PinLockViewModel>().errorMessage;
|
||||
return context.read<PinLockViewModel>().error;
|
||||
}
|
||||
|
||||
void _fail(String message) {
|
||||
|
||||
Reference in New Issue
Block a user