π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mobile][photos] dismiss keyboard if tapped outside of text fields
Priyanshu Dangare2210e11c3e7d
diff --git a/mobile/packages/ente_components/lib/components/text_input_component.dart b/mobile/packages/ente_components/lib/components/text_input_component.dartindex fa119d400e..8e2895e906 100644--- a/mobile/packages/ente_components/lib/components/text_input_component.dart+++ b/mobile/packages/ente_components/lib/components/text_input_component.dart@@ -232,91 +232,94 @@ class _TextInputComponentState extends State<TextInputComponent> {),const SizedBox(height: Spacing.sm),],- GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: widget.isDisabled ? null : _focusNode.requestFocus,- child: Container(- height: _isMultiline ? null : _kHeight,- constraints: _isMultiline- ? const BoxConstraints(minHeight: _kHeight)- : null,- decoration: BoxDecoration(- color: _backgroundColor(colors),- borderRadius: BorderRadius.circular(Radii.lg),- border: Border.all(color: _borderColor(colors)),- ),- child: Stack(- clipBehavior: Clip.none,- fit: _isMultiline ? StackFit.loose : StackFit.expand,- children: [- Padding(- padding: EdgeInsets.symmetric(- horizontal: Spacing.lg,- vertical: _isMultiline ? Spacing.lg : 0,- ),- child: Row(- crossAxisAlignment: _isMultiline- ? CrossAxisAlignment.start- : CrossAxisAlignment.center,- children: [- if (prefix != null) ...[- prefix,- const SizedBox(width: Spacing.sm),- ],- Expanded(- child: TextField(- controller: _controller,- focusNode: _focusNode,- enabled: !widget.isDisabled,- autofocus: widget.autofocus,- obscureText: _obscureText,- maxLines: widget.isPasswordInput- ? 1- : widget.maxLines ?? (_isMultiline ? null : 1),- minLines: widget.isPasswordInput- ? null- : widget.minLines,- keyboardType: widget.keyboardType,- textCapitalization: widget.textCapitalization,- inputFormatters: _inputFormatters,- autofillHints:- widget.autofillHints ??- (widget.isPasswordInput- ? const [AutofillHints.password]- : const []),- autocorrect:- widget.autocorrect && !widget.isPasswordInput,- enableSuggestions: !widget.isPasswordInput,- textAlignVertical: _isMultiline- ? TextAlignVertical.top- : TextAlignVertical.center,- onEditingComplete: _handleEditingComplete,- style: TextStyles.body.copyWith(- color: _textColor(colors),- ),- decoration: InputDecoration(- hintText: widget.hintText,- hintStyle: TextStyles.body.copyWith(- color: _hintColor(colors),+ TextFieldTapRegion(+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: widget.isDisabled ? null : _focusNode.requestFocus,+ child: Container(+ height: _isMultiline ? null : _kHeight,+ constraints: _isMultiline+ ? const BoxConstraints(minHeight: _kHeight)+ : null,+ decoration: BoxDecoration(+ color: _backgroundColor(colors),+ borderRadius: BorderRadius.circular(Radii.lg),+ border: Border.all(color: _borderColor(colors)),+ ),+ child: Stack(+ clipBehavior: Clip.none,+ fit: _isMultiline ? StackFit.loose : StackFit.expand,+ children: [+ Padding(+ padding: EdgeInsets.symmetric(+ horizontal: Spacing.lg,+ vertical: _isMultiline ? Spacing.lg : 0,+ ),+ child: Row(+ crossAxisAlignment: _isMultiline+ ? CrossAxisAlignment.start+ : CrossAxisAlignment.center,+ children: [+ if (prefix != null) ...[+ prefix,+ const SizedBox(width: Spacing.sm),+ ],+ Expanded(+ child: TextField(+ controller: _controller,+ focusNode: _focusNode,+ enabled: !widget.isDisabled,+ autofocus: widget.autofocus,+ obscureText: _obscureText,+ maxLines: widget.isPasswordInput+ ? 1+ : widget.maxLines ?? (_isMultiline ? null : 1),+ minLines: widget.isPasswordInput+ ? null+ : widget.minLines,+ keyboardType: widget.keyboardType,+ textCapitalization: widget.textCapitalization,+ inputFormatters: _inputFormatters,+ autofillHints:+ widget.autofillHints ??+ (widget.isPasswordInput+ ? const [AutofillHints.password]+ : const []),+ autocorrect:+ widget.autocorrect && !widget.isPasswordInput,+ enableSuggestions: !widget.isPasswordInput,+ textAlignVertical: _isMultiline+ ? TextAlignVertical.top+ : TextAlignVertical.center,+ onEditingComplete: _handleEditingComplete,+ onTapOutside: (_) => _focusNode.unfocus(),+ style: TextStyles.body.copyWith(+ color: _textColor(colors),+ ),+ decoration: InputDecoration(+ hintText: widget.hintText,+ hintStyle: TextStyles.body.copyWith(+ color: _hintColor(colors),+ ),+ border: InputBorder.none,+ focusedBorder: InputBorder.none,+ enabledBorder: InputBorder.none,+ disabledBorder: InputBorder.none,+ isDense: true,+ contentPadding: EdgeInsets.zero,),- border: InputBorder.none,- focusedBorder: InputBorder.none,- enabledBorder: InputBorder.none,- disabledBorder: InputBorder.none,- isDense: true,- contentPadding: EdgeInsets.zero,),),- ),- if (suffix != null) ...[- const SizedBox(width: Spacing.sm),- suffix,+ if (suffix != null) ...[+ const SizedBox(width: Spacing.sm),+ suffix,+ ],],- ],+ ),),- ),- if (suffixTap != null) _suffixTapTarget(suffixTap),- ],+ if (suffixTap != null) _suffixTapTarget(suffixTap),+ ],+ ),),),),diff --git a/mobile/packages/ente_components/test/components/text_input_component_test.dart b/mobile/packages/ente_components/test/components/text_input_component_test.dartindex d337090aeb..e3cefc44be 100644--- a/mobile/packages/ente_components/test/components/text_input_component_test.dart+++ b/mobile/packages/ente_components/test/components/text_input_component_test.dart@@ -98,6 +98,35 @@ void main() {);});+ testWidgets("TextInputComponent unfocuses when tapping outside", (+ tester,+ ) async {+ final focusNode = FocusNode();+ addTearDown(focusNode.dispose);++ await tester.pumpWidget(+ _wrap(+ Column(+ children: [+ TextInputComponent(label: "Email", focusNode: focusNode),+ const SizedBox(height: 40),+ const Text("Outside"),+ ],+ ),+ ),+ );++ await tester.tap(find.byType(TextField));+ await tester.pump();++ expect(focusNode.hasFocus, isTrue);++ await tester.tap(find.text("Outside"));+ await tester.pump();++ expect(focusNode.hasFocus, isFalse);+ });+testWidgets("TextInputComponent maps error and success states to borders", (tester,) async {