π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Update UI
vishnukvmd788c868fa43e
diff --git a/mobile/apps/locker/lib/l10n/app_en.arb b/mobile/apps/locker/lib/l10n/app_en.arbindex 931822b580..ce34267583 100644--- a/mobile/apps/locker/lib/l10n/app_en.arb+++ b/mobile/apps/locker/lib/l10n/app_en.arb@@ -360,7 +360,7 @@"saveToLocker": "Save to Locker","saveDocumentTitle": "Document","saveDocumentDescription": "Upload items to to be preserved",- "informationDescription": "Save important information that can be shared and passed down to loved ones.",+ "informationDescription": "Save information to be shared or passed down to loved ones.","personalNote": "Note","personalNoteDescription": "Write down thoughts and instructions","physicalRecords": "Place",@@ -395,14 +395,14 @@"recordLocationHint": "Where can this item be found?","recordNotes": "Notes","recordNotesHint": "Any additional information about the item",- "credentialName": "Item name",- "credentialNameHint": "Name of the service or account",+ "credentialName": "Account",+ "credentialNameHint": "Name of the service","username": "Username",- "usernameHint": "Login username or email address",+ "usernameHint": "Login ID or email","password": "Password",- "passwordHint": "Account password",+ "passwordHint": "Password","credentialNotes": "Additional notes",- "credentialNotesHint": "Recovery methods, security questions, or other important details",+ "credentialNotesHint": "Recovery methods, security questions, ...","contactName": "Contact name","contactNameHint": "Full name of the emergency contact","contactDetails": "Contact details",diff --git a/mobile/apps/locker/lib/l10n/app_localizations.dart b/mobile/apps/locker/lib/l10n/app_localizations.dartindex 78e6d9377a..b2bfcd8edc 100644--- a/mobile/apps/locker/lib/l10n/app_localizations.dart+++ b/mobile/apps/locker/lib/l10n/app_localizations.dart@@ -1081,7 +1081,7 @@ abstract class AppLocalizations {/// No description provided for @informationDescription.////// In en, this message translates to:- /// **'Save important information that can be shared and passed down to loved ones.'**+ /// **'Save information to be shared or passed down to loved ones.'**String get informationDescription;/// No description provided for @personalNote.@@ -1237,13 +1237,13 @@ abstract class AppLocalizations {/// No description provided for @credentialName.////// In en, this message translates to:- /// **'Item name'**+ /// **'Account'**String get credentialName;/// No description provided for @credentialNameHint.////// In en, this message translates to:- /// **'Name of the service or account'**+ /// **'Name of the service'**String get credentialNameHint;/// No description provided for @username.@@ -1255,7 +1255,7 @@ abstract class AppLocalizations {/// No description provided for @usernameHint.////// In en, this message translates to:- /// **'Login username or email address'**+ /// **'Login ID or email'**String get usernameHint;/// No description provided for @password.@@ -1267,7 +1267,7 @@ abstract class AppLocalizations {/// No description provided for @passwordHint.////// In en, this message translates to:- /// **'Account password'**+ /// **'Password'**String get passwordHint;/// No description provided for @credentialNotes.@@ -1279,7 +1279,7 @@ abstract class AppLocalizations {/// No description provided for @credentialNotesHint.////// In en, this message translates to:- /// **'Recovery methods, security questions, or other important details'**+ /// **'Recovery methods, security questions, ...'**String get credentialNotesHint;/// No description provided for @contactName.diff --git a/mobile/apps/locker/lib/l10n/app_localizations_en.dart b/mobile/apps/locker/lib/l10n/app_localizations_en.dartindex e959170324..4237b44bd5 100644--- a/mobile/apps/locker/lib/l10n/app_localizations_en.dart+++ b/mobile/apps/locker/lib/l10n/app_localizations_en.dart@@ -568,7 +568,7 @@ class AppLocalizationsEn extends AppLocalizations {@overrideString get informationDescription =>- 'Save important information that can be shared and passed down to loved ones.';+ 'Save information to be shared or passed down to loved ones.';@overrideString get personalNote => 'Note';@@ -648,29 +648,28 @@ class AppLocalizationsEn extends AppLocalizations {String get recordNotesHint => 'Any additional information about the item';@override- String get credentialName => 'Item name';+ String get credentialName => 'Account';@override- String get credentialNameHint => 'Name of the service or account';+ String get credentialNameHint => 'Name of the service';@overrideString get username => 'Username';@override- String get usernameHint => 'Login username or email address';+ String get usernameHint => 'Login ID or email';@overrideString get password => 'Password';@override- String get passwordHint => 'Account password';+ String get passwordHint => 'Password';@overrideString get credentialNotes => 'Additional notes';@override- String get credentialNotesHint =>- 'Recovery methods, security questions, or other important details';+ String get credentialNotesHint => 'Recovery methods, security questions, ...';@overrideString get contactName => 'Contact name';diff --git a/mobile/apps/locker/lib/ui/components/capsule_form_field.dart b/mobile/apps/locker/lib/ui/components/capsule_form_field.dartnew file mode 100644index 0000000000..00a0a870f5--- /dev/null+++ b/mobile/apps/locker/lib/ui/components/capsule_form_field.dart@@ -0,0 +1,343 @@+import 'package:ente_ui/theme/ente_theme.dart';+import 'package:flutter/material.dart';+import 'package:flutter/services.dart';++class CapsuleFormField extends StatefulWidget {+ const CapsuleFormField({+ super.key,+ required this.controller,+ required this.labelText,+ this.hintText,+ this.focusNode,+ this.validator,+ this.trailing,+ this.autofocus = false,+ this.obscureText = false,+ this.enabled = true,+ this.readOnly = false,+ this.maxLines = 1,+ this.minLines,+ this.keyboardType,+ this.textCapitalization = TextCapitalization.none,+ this.textInputAction,+ this.inputFormatters,+ this.onChanged,+ this.onEditingComplete,+ this.onSubmitted,+ this.lineHeight,+ this.contentPadding =+ const EdgeInsets.symmetric(horizontal: 24, vertical: 18),+ });++ final TextEditingController controller;+ final FocusNode? focusNode;+ final String labelText;+ final String? hintText;+ final String? Function(String?)? validator;+ final Widget? trailing;+ final bool autofocus;+ final bool obscureText;+ final bool enabled;+ final bool readOnly;+ final int? maxLines;+ final int? minLines;+ final TextInputType? keyboardType;+ final TextCapitalization textCapitalization;+ final TextInputAction? textInputAction;+ final List<TextInputFormatter>? inputFormatters;+ final ValueChanged<String>? onChanged;+ final VoidCallback? onEditingComplete;+ final ValueChanged<String>? onSubmitted;+ final double? lineHeight;+ final EdgeInsets contentPadding;++ @override+ State<CapsuleFormField> createState() => _CapsuleFormFieldState();+}++class _CapsuleFormFieldState extends State<CapsuleFormField> {+ final GlobalKey<FormFieldState<String>> _fieldKey =+ GlobalKey<FormFieldState<String>>();+ FocusNode? _internalFocusNode;++ FocusNode get _focusNode => widget.focusNode ?? _internalFocusNode!;++ @override+ void initState() {+ super.initState();+ _ensureFocusNode();+ widget.controller.addListener(_handleControllerChanged);+ _focusNode.addListener(_handleFocusChanged);+ }++ void _ensureFocusNode() {+ if (widget.focusNode == null && _internalFocusNode == null) {+ _internalFocusNode = FocusNode();+ }+ }++ @override+ void didUpdateWidget(CapsuleFormField oldWidget) {+ super.didUpdateWidget(oldWidget);+ if (oldWidget.focusNode != widget.focusNode) {+ oldWidget.focusNode?.removeListener(_handleFocusChanged);+ _internalFocusNode?.removeListener(_handleFocusChanged);+ if (oldWidget.focusNode == null) {+ _internalFocusNode?.dispose();+ _internalFocusNode = null;+ }+ _ensureFocusNode();+ _focusNode.addListener(_handleFocusChanged);+ }++ if (oldWidget.controller != widget.controller) {+ oldWidget.controller.removeListener(_handleControllerChanged);+ widget.controller.addListener(_handleControllerChanged);+ _fieldKey.currentState?.didChange(widget.controller.text);+ }+ }++ @override+ void dispose() {+ widget.controller.removeListener(_handleControllerChanged);+ _focusNode.removeListener(_handleFocusChanged);+ _internalFocusNode?.dispose();+ super.dispose();+ }++ void _handleControllerChanged() {+ _fieldKey.currentState?.didChange(widget.controller.text);+ if (mounted) {+ setState(() {});+ }+ }++ void _handleFocusChanged() {+ if (mounted) {+ setState(() {});+ }+ }++ @override+ Widget build(BuildContext context) {+ final colorScheme = getEnteColorScheme(context);+ final textTheme = getEnteTextTheme(context);+ final accentBlue = Color.lerp(+ colorScheme.primary500,+ const Color(0xFF3B82F6),+ 0.7,+ )!;++ final isEnabled = widget.enabled && !widget.readOnly;+ _focusNode.canRequestFocus = isEnabled;+ final hasFocus = _focusNode.hasFocus && isEnabled;+ final bool isMultiline =+ (widget.maxLines ?? 1) > 1 || (widget.minLines ?? 1) > 1;+ final int? effectiveMaxLines =+ widget.obscureText ? 1 : widget.maxLines;+ final int? effectiveMinLines = widget.obscureText+ ? 1+ : (widget.minLines ??+ (isMultiline ? (widget.maxLines ?? 3) : 1));+ final textInputType = widget.keyboardType ??+ (isMultiline ? TextInputType.multiline : TextInputType.text);++ final backgroundColor = !widget.enabled+ ? colorScheme.fillMuted+ : hasFocus+ ? accentBlue.withOpacity(0.14)+ : colorScheme.fillFaint;++ final textLineHeight =+ widget.lineHeight ?? (isMultiline ? 1.5 : 1.25);+ final textColor =+ widget.enabled ? colorScheme.textBase : colorScheme.textFaint;++ return FormField<String>(+ key: _fieldKey,+ autovalidateMode: AutovalidateMode.disabled,+ validator: (value) => widget.validator?.call(widget.controller.text),+ builder: (field) {+ final hasError = field.hasError;+ final errorText = field.errorText;++ return Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ if (widget.labelText.isNotEmpty) ...[+ Text(+ widget.labelText,+ style: textTheme.body,+ ),+ const SizedBox(height: 8),+ ],+ AnimatedContainer(+ duration: const Duration(milliseconds: 220),+ curve: Curves.easeOutCubic,+ decoration: BoxDecoration(+ color: backgroundColor,+ borderRadius: BorderRadius.circular(24),+ ),+ child: Padding(+ padding: widget.contentPadding,+ child: Row(+ crossAxisAlignment: (widget.maxLines ?? 1) > 1+ ? CrossAxisAlignment.start+ : CrossAxisAlignment.center,+ children: [+ Expanded(+ child: TextField(+ controller: widget.controller,+ focusNode: _focusNode,+ readOnly: widget.readOnly,+ enabled: widget.enabled,+ autofocus: widget.autofocus,+ obscureText: widget.obscureText,+ obscuringCharacter: 'β’',+ enableSuggestions: !widget.obscureText,+ autocorrect: !widget.obscureText,+ keyboardType: textInputType,+ textCapitalization: widget.textCapitalization,+ textInputAction: widget.textInputAction,+ inputFormatters: widget.inputFormatters,+ maxLines: effectiveMaxLines,+ minLines: effectiveMinLines,+ onChanged: (value) {+ field.didChange(value);+ widget.onChanged?.call(value);+ },+ onEditingComplete: widget.onEditingComplete,+ onSubmitted: widget.onSubmitted,+ cursorColor: colorScheme.textBase,+ style: textTheme.body.copyWith(+ height: textLineHeight,+ color: textColor,+ ),+ textAlignVertical:+ isMultiline ? TextAlignVertical.top : TextAlignVertical.center,+ decoration: InputDecoration.collapsed(+ hintText: widget.hintText,+ hintStyle: textTheme.body.copyWith(+ color: colorScheme.textFaint,+ height: textLineHeight,+ ),+ ),+ ),+ ),+ if (widget.trailing != null) ...[+ const SizedBox(width: 8),+ widget.trailing!,+ ],+ ],+ ),+ ),+ ),+ if (hasError && errorText != null) ...[+ const SizedBox(height: 6),+ Text(+ errorText,+ style: textTheme.mini.copyWith(+ color: colorScheme.warning500,+ ),+ ),+ ],+ ],+ );+ },+ );+ }+}++class CapsuleDisplayField extends StatelessWidget {+ const CapsuleDisplayField({+ super.key,+ required this.labelText,+ required this.value,+ this.isSecret = false,+ this.maxLines,+ this.lineHeight,+ this.onCopy,+ this.contentPadding =+ const EdgeInsets.symmetric(horizontal: 24, vertical: 18),+ });++ final String labelText;+ final String value;+ final bool isSecret;+ final int? maxLines;+ final double? lineHeight;+ final VoidCallback? onCopy;+ final EdgeInsets contentPadding;++ @override+ Widget build(BuildContext context) {+ final colorScheme = getEnteColorScheme(context);+ final textTheme = getEnteTextTheme(context);+ final displayValue = isSecret ? 'β’β’β’β’β’β’β’β’' : value;+ final textLineHeight =+ lineHeight ?? ((maxLines ?? 1) > 1 ? 1.5 : 1.3);++ return Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ if (labelText.isNotEmpty) ...[+ Text(+ labelText,+ style: textTheme.body,+ ),+ const SizedBox(height: 8),+ ],+ Container(+ decoration: BoxDecoration(+ color: colorScheme.fillFaint,+ borderRadius: BorderRadius.circular(24),+ ),+ child: Padding(+ padding: contentPadding,+ child: Row(+ crossAxisAlignment: (maxLines ?? 1) > 1+ ? CrossAxisAlignment.start+ : CrossAxisAlignment.center,+ children: [+ Expanded(+ child: isSecret+ ? Text(+ displayValue,+ style: textTheme.body.copyWith(height: textLineHeight),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ )+ : SelectableText(+ displayValue,+ style:+ textTheme.body.copyWith(height: textLineHeight),+ maxLines: maxLines,+ ),+ ),+ if (onCopy != null) ...[+ const SizedBox(width: 12),+ InkWell(+ onTap: onCopy,+ borderRadius: BorderRadius.circular(12),+ child: Container(+ padding: const EdgeInsets.all(8),+ decoration: BoxDecoration(+ color: colorScheme.fillBase.withOpacity(0.1),+ borderRadius: BorderRadius.circular(12),+ ),+ child: Icon(+ Icons.copy,+ size: 16,+ color: colorScheme.textMuted,+ ),+ ),+ ),+ ],+ ],+ ),+ ),+ ),+ ],+ );+ }+}diff --git a/mobile/apps/locker/lib/ui/pages/account_credentials_page.dart b/mobile/apps/locker/lib/ui/pages/account_credentials_page.dartindex 4aedafdde7..6f648c43b3 100644--- a/mobile/apps/locker/lib/ui/pages/account_credentials_page.dart+++ b/mobile/apps/locker/lib/ui/pages/account_credentials_page.dart@@ -1,7 +1,8 @@import 'package:flutter/material.dart';+import 'package:flutter/services.dart';import 'package:locker/l10n/l10n.dart';import 'package:locker/models/info/info_item.dart';-import 'package:locker/ui/components/form_text_input_widget.dart';+import 'package:locker/ui/components/capsule_form_field.dart';import 'package:locker/ui/pages/base_info_page.dart';class AccountCredentialsPage extends BaseInfoPage<AccountCredentialData> {@@ -22,7 +23,6 @@ class _AccountCredentialsPageStatefinal TextEditingController _passwordController = TextEditingController();final TextEditingController _notesController = TextEditingController();bool _passwordVisible = false;- final _passwordFocusNode = FocusNode();@overridevoid initState() {@@ -30,11 +30,6 @@ class _AccountCredentialsPageState_nameController.addListener(_onFieldChanged);_usernameController.addListener(_onFieldChanged);_passwordController.addListener(_onFieldChanged);- _passwordFocusNode.addListener(() {- setState(() {- // Password focus state handling if needed- });- });_loadExistingData();}@@ -63,7 +58,6 @@ class _AccountCredentialsPageState_usernameController.dispose();_passwordController.dispose();_notesController.dispose();- _passwordFocusNode.dispose();super.dispose();}@@ -120,12 +114,13 @@ class _AccountCredentialsPageState@overrideList<Widget> buildFormFields() {return [- FormTextInputWidget(+ CapsuleFormField(labelText: context.l10n.credentialName,hintText: context.l10n.credentialNameHint,controller: _nameController,- shouldUseTextInputWidget: false,+ textCapitalization: TextCapitalization.sentences,autofocus: true,+ textInputAction: TextInputAction.next,validator: (value) {if (value == null || value.trim().isEmpty) {return context.l10n.pleaseEnterAccountName;@@ -134,11 +129,11 @@ class _AccountCredentialsPageState},),const SizedBox(height: 24),- FormTextInputWidget(+ CapsuleFormField(labelText: context.l10n.username,hintText: context.l10n.usernameHint,controller: _usernameController,- shouldUseTextInputWidget: false,+ textInputAction: TextInputAction.next,validator: (value) {if (value == null || value.trim().isEmpty) {return context.l10n.pleaseEnterUsername;@@ -147,15 +142,15 @@ class _AccountCredentialsPageState},),const SizedBox(height: 24),- FormTextInputWidget(+ CapsuleFormField(labelText: context.l10n.password,hintText: context.l10n.passwordHint,controller: _passwordController,obscureText: !_passwordVisible,- shouldUseTextInputWidget: false,- suffixIcon: IconButton(+ textInputAction: TextInputAction.next,+ trailing: IconButton(padding: EdgeInsets.zero,- constraints: const BoxConstraints(minHeight: 0, minWidth: 0),+ constraints: const BoxConstraints(minHeight: 32, minWidth: 32),iconSize: 20,visualDensity: VisualDensity.compact,icon: Icon(@@ -175,43 +170,62 @@ class _AccountCredentialsPageState},),const SizedBox(height: 24),- FormTextInputWidget(+ CapsuleFormField(labelText: context.l10n.credentialNotes,hintText: context.l10n.credentialNotesHint,controller: _notesController,- shouldUseTextInputWidget: false,maxLines: 3,+ minLines: 3,+ textCapitalization: TextCapitalization.sentences,+ keyboardType: TextInputType.multiline,+ textInputAction: TextInputAction.newline,+ lineHeight: 1.5,),];}@overrideList<Widget> buildViewFields() {- final viewFields = <Widget>[- buildViewField(- label: context.l10n.username,- value: _usernameController.text,+ final usernameText = _usernameController.text;+ final passwordText = _passwordController.text;+ final notesText = _notesController.text;++ final fields = <Widget>[+ CapsuleDisplayField(+ labelText: context.l10n.username,+ value: usernameText,+ onCopy: usernameText.trim().isEmpty+ ? null+ : () => _copyValue(usernameText, context.l10n.username),),const SizedBox(height: 24),- buildViewField(- label: context.l10n.password,- value: _passwordController.text,+ CapsuleDisplayField(+ labelText: context.l10n.password,+ value: passwordText,isSecret: true,+ onCopy: passwordText.trim().isEmpty+ ? null+ : () => _copyValue(passwordText, context.l10n.password),),];- if (_notesController.text.isNotEmpty) {- viewFields.addAll([+ if (notesText.trim().isNotEmpty) {+ fields.addAll([const SizedBox(height: 24),- buildViewField(- label: context.l10n.credentialNotes,- value: _notesController.text,- maxLines: 3,+ CapsuleDisplayField(+ labelText: context.l10n.credentialNotes,+ value: notesText,+ maxLines: 6,+ lineHeight: 1.5,+ onCopy: () => _copyValue(+ notesText,+ context.l10n.credentialNotes,+ ),),]);}- return viewFields;+ return fields;}void _onFieldChanged() {@@ -219,4 +233,19 @@ class _AccountCredentialsPageStatesetState(() {});}}++ void _copyValue(String value, String label) {+ if (value.trim().isEmpty) {+ return;+ }+ Clipboard.setData(ClipboardData(text: value));+ if (!mounted) return;+ ScaffoldMessenger.of(context).showSnackBar(+ SnackBar(+ content: Text(context.l10n.copiedToClipboard(label)),+ duration: const Duration(seconds: 2),+ backgroundColor: Colors.green,+ ),+ );+ }}diff --git a/mobile/apps/locker/lib/ui/pages/physical_records_page.dart b/mobile/apps/locker/lib/ui/pages/physical_records_page.dartindex 7fccca9939..1fd3b1b155 100644--- a/mobile/apps/locker/lib/ui/pages/physical_records_page.dart+++ b/mobile/apps/locker/lib/ui/pages/physical_records_page.dart@@ -1,7 +1,8 @@import 'package:flutter/material.dart';+import 'package:flutter/services.dart';import 'package:locker/l10n/l10n.dart';import 'package:locker/models/info/info_item.dart';-import 'package:locker/ui/components/form_text_input_widget.dart';+import 'package:locker/ui/components/capsule_form_field.dart';import 'package:locker/ui/pages/base_info_page.dart';class PhysicalRecordsPage extends BaseInfoPage<PhysicalRecordData> {@@ -108,12 +109,13 @@ class _PhysicalRecordsPageState@overrideList<Widget> buildFormFields() {return [- FormTextInputWidget(+ CapsuleFormField(labelText: context.l10n.name,hintText: context.l10n.recordNameHint,controller: _nameController,- shouldUseTextInputWidget: false,autofocus: true,+ textCapitalization: TextCapitalization.sentences,+ textInputAction: TextInputAction.next,validator: (value) {if (value == null || value.trim().isEmpty) {return context.l10n.pleaseEnterRecordName;@@ -122,11 +124,12 @@ class _PhysicalRecordsPageState},),const SizedBox(height: 24),- FormTextInputWidget(+ CapsuleFormField(labelText: context.l10n.recordLocation,hintText: context.l10n.recordLocationHint,controller: _locationController,- shouldUseTextInputWidget: false,+ textCapitalization: TextCapitalization.sentences,+ textInputAction: TextInputAction.next,validator: (value) {if (value == null || value.trim().isEmpty) {return context.l10n.pleaseEnterLocation;@@ -135,12 +138,16 @@ class _PhysicalRecordsPageState},),const SizedBox(height: 24),- FormTextInputWidget(+ CapsuleFormField(labelText: context.l10n.recordNotes,hintText: context.l10n.recordNotesHint,controller: _notesController,- shouldUseTextInputWidget: false,maxLines: 3,+ minLines: 3,+ textCapitalization: TextCapitalization.sentences,+ keyboardType: TextInputType.multiline,+ textInputAction: TextInputAction.newline,+ lineHeight: 1.5,),];}@@ -151,26 +158,52 @@ class _PhysicalRecordsPageState}}+ void _copyValue(String value, String label) {+ if (value.trim().isEmpty) {+ return;+ }+ Clipboard.setData(ClipboardData(text: value));+ if (!mounted) return;+ ScaffoldMessenger.of(context).showSnackBar(+ SnackBar(+ content: Text(context.l10n.copiedToClipboard(label)),+ duration: const Duration(seconds: 2),+ backgroundColor: Colors.green,+ ),+ );+ }+@overrideList<Widget> buildViewFields() {- final viewFields = <Widget>[- buildViewField(- label: context.l10n.recordLocation,+ final fields = <Widget>[+ CapsuleDisplayField(+ labelText: context.l10n.recordLocation,value: _locationController.text,+ onCopy: _locationController.text.trim().isEmpty+ ? null+ : () => _copyValue(+ _locationController.text,+ context.l10n.recordLocation,+ ),),];- if (_notesController.text.isNotEmpty) {- viewFields.addAll([+ if (_notesController.text.trim().isNotEmpty) {+ fields.addAll([const SizedBox(height: 24),- buildViewField(- label: context.l10n.recordNotes,+ CapsuleDisplayField(+ labelText: context.l10n.recordNotes,value: _notesController.text,- maxLines: 3,+ maxLines: 6,+ lineHeight: 1.5,+ onCopy: () => _copyValue(+ _notesController.text,+ context.l10n.recordNotes,+ ),),]);}- return viewFields;+ return fields;}}