enter pin automatically if autopin pref is set

This commit is contained in:
sneurlax 2024-07-01 10:15:17 -05:00
parent 0ce0a38950
commit 8e8b57d8e8
2 changed files with 34 additions and 1 deletions

View file

@ -188,12 +188,14 @@ class _LockscreenViewState extends ConsumerState<LockscreenView> {
_timeout = Duration.zero;
_checkUseBiometrics();
_pinTextController.addListener(_onPinChanged);
super.initState();
}
@override
dispose() {
// _shakeController.dispose();
_pinTextController.removeListener(_onPinChanged);
super.dispose();
}
@ -208,13 +210,27 @@ class _LockscreenViewState extends ConsumerState<LockscreenView> {
);
}
final _pinTextController = TextEditingController();
final FocusNode _pinFocusNode = FocusNode();
late SecureStorageInterface _secureStore;
late Biometrics biometrics;
int pinCount = 1;
final _pinTextController = TextEditingController();
void _onPinChanged() async {
String enteredPin = _pinTextController.text;
final storedPin = await _secureStore.read(key: 'stack_pin');
final autoPin = ref.read(prefsChangeNotifierProvider).autoPin;
if (autoPin && enteredPin == storedPin) {
await Future<void>.delayed(
const Duration(milliseconds: 200),
);
unawaited(_onUnlock());
}
}
Widget get _body => Background(
child: SafeArea(
child: Scaffold(

View file

@ -61,9 +61,12 @@ class _ChangePinViewState extends ConsumerState<ChangePinView> {
int pinCount = 1;
final TextEditingController _pinTextController = TextEditingController();
@override
void initState() {
_secureStore = ref.read(secureStoreProvider);
_pinTextController.addListener(_onPinChanged);
super.initState();
}
@ -74,9 +77,23 @@ class _ChangePinViewState extends ConsumerState<ChangePinView> {
_pinPutController2.dispose();
_pinPutFocusNode1.dispose();
_pinPutFocusNode2.dispose();
_pinTextController.removeListener(_onPinChanged);
super.dispose();
}
void _onPinChanged() async {
String enteredPin = _pinTextController.text;
final storedPin = await _secureStore.read(key: 'stack_pin');
final autoPin = ref.read(prefsChangeNotifierProvider).autoPin;
if (autoPin && enteredPin == storedPin) {
await _pageController.nextPage(
duration: const Duration(milliseconds: 300),
curve: Curves.linear,
);
}
}
@override
Widget build(BuildContext context) {
return Background(