Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

feat: add autofill hints for one-time code and close keyboard on completion in PinInputComponent

AmanRajSinghMourya79e4feefa4bc
diff --git a/mobile/apps/photos/lib/ui/account/ott_verification_page.dart b/mobile/apps/photos/lib/ui/account/ott_verification_page.dart
index b88da64cd9..7e283637a6 100644
--- a/mobile/apps/photos/lib/ui/account/ott_verification_page.dart
+++ b/mobile/apps/photos/lib/ui/account/ott_verification_page.dart
@@ -134,6 +134,7 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
length: 6,
controller: _pinController,
autofocus: true,
+ autofillHints: const [AutofillHints.oneTimeCode],
onChanged: (String pin) {
setState(() {
_code = pin;
diff --git a/mobile/packages/accounts/lib/pages/ott_verification_page.dart b/mobile/packages/accounts/lib/pages/ott_verification_page.dart
index 0bcb296bb6..de88a2cb82 100644
--- a/mobile/packages/accounts/lib/pages/ott_verification_page.dart
+++ b/mobile/packages/accounts/lib/pages/ott_verification_page.dart
@@ -172,6 +172,7 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
length: 6,
controller: _pinController,
autofocus: true,
+ autofillHints: const [AutofillHints.oneTimeCode],
onCompleted: (value) {
if (value.length == 6) {
onPressed();
diff --git a/mobile/packages/ente_components/lib/components/pin_input_component.dart b/mobile/packages/ente_components/lib/components/pin_input_component.dart
index 6417791069..3fcd5ea8c7 100644
--- a/mobile/packages/ente_components/lib/components/pin_input_component.dart
+++ b/mobile/packages/ente_components/lib/components/pin_input_component.dart
@@ -22,6 +22,7 @@ class PinInputComponent extends StatefulWidget {
this.length = 6,
this.autofocus = false,
this.useNativeKeyboard = true,
+ this.closeKeyboardWhenCompleted = true,
this.obscureText = false,
this.obscuringCharacter = 'β€’',
this.isError = false,
@@ -37,6 +38,7 @@ class PinInputComponent extends StatefulWidget {
final TextEditingController controller;
final bool autofocus;
final bool useNativeKeyboard;
+ final bool closeKeyboardWhenCompleted;
final bool obscureText;
final String obscuringCharacter;
final bool isError;
@@ -152,6 +154,9 @@ class _PinInputComponentState extends State<PinInputComponent> {
}
_lastCompletedValue = controllerText;
widget.onCompleted?.call(controllerText);
+ if (widget.closeKeyboardWhenCompleted && mounted) {
+ _focusNode.unfocus();
+ }
}
String _sanitizeValue(String value) {