π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][locker] Migrate form and empty states to component theme
aman-pilotf35fd11f18bb
diff --git a/mobile/apps/locker/lib/ui/components/capsule_form_field.dart b/mobile/apps/locker/lib/ui/components/capsule_form_field.dartindex 870b029e1f..c0d91dab91 100644--- a/mobile/apps/locker/lib/ui/components/capsule_form_field.dart+++ b/mobile/apps/locker/lib/ui/components/capsule_form_field.dart@@ -1,4 +1,4 @@-import 'package:ente_ui/theme/ente_theme.dart';+import 'package:ente_components/ente_components.dart';import 'package:flutter/material.dart';import 'package:flutter/services.dart';@@ -122,13 +122,7 @@ class _CapsuleFormFieldState extends State<CapsuleFormField> {@overrideWidget build(BuildContext context) {- final colorScheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);- final accentBlue = Color.lerp(- colorScheme.primary500,- const Color(0xFF3B82F6),- 0.7,- )!;+ final colors = context.componentColors;final isEnabled = widget.enabled && !widget.readOnly;_focusNode.canRequestFocus = isEnabled;@@ -144,15 +138,13 @@ class _CapsuleFormFieldState extends State<CapsuleFormField> {(isMultiline ? TextInputType.multiline : TextInputType.text);final backgroundColor = !widget.enabled- ? colorScheme.fillMuted+ ? colors.fillDarker: hasFocus- ? accentBlue.withValues(alpha: 0.14)- : colorScheme.fillFaint;+ ? colors.primaryLight+ : colors.fillDark;final textLineHeight = widget.lineHeight ?? (isMultiline ? 1.5 : 1.25);- final textColor = widget.enabled- ? colorScheme.textBase- : colorScheme.textFaint;+ final textColor = widget.enabled ? colors.textBase : colors.textLighter;return FormField<String>(key: _fieldKey,@@ -166,7 +158,7 @@ class _CapsuleFormFieldState extends State<CapsuleFormField> {crossAxisAlignment: CrossAxisAlignment.start,children: [if (widget.labelText.isNotEmpty) ...[- Text(widget.labelText, style: textTheme.body),+ Text(widget.labelText, style: TextStyles.body),const SizedBox(height: 8),],AnimatedContainer(@@ -206,8 +198,8 @@ class _CapsuleFormFieldState extends State<CapsuleFormField> {},onEditingComplete: widget.onEditingComplete,onSubmitted: widget.onSubmitted,- cursorColor: colorScheme.textBase,- style: textTheme.body.copyWith(+ cursorColor: colors.textBase,+ style: TextStyles.body.copyWith(height: textLineHeight,color: textColor,),@@ -216,8 +208,8 @@ class _CapsuleFormFieldState extends State<CapsuleFormField> {: TextAlignVertical.center,decoration: InputDecoration.collapsed(hintText: widget.hintText,- hintStyle: textTheme.body.copyWith(- color: colorScheme.textFaint,+ hintStyle: TextStyles.body.copyWith(+ color: colors.textLighter,height: textLineHeight,),),@@ -235,7 +227,7 @@ class _CapsuleFormFieldState extends State<CapsuleFormField> {const SizedBox(height: 6),Text(errorText,- style: textTheme.mini.copyWith(color: colorScheme.warning500),+ style: TextStyles.mini.copyWith(color: colors.warning),),],],@@ -277,8 +269,7 @@ class _CapsuleDisplayFieldState extends State<CapsuleDisplayField> {@overrideWidget build(BuildContext context) {- final colorScheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);+ final colors = context.componentColors;final displayValue = (widget.isSecret && !_isVisible)? 'β’' * widget.value.length: widget.value;@@ -289,12 +280,12 @@ class _CapsuleDisplayFieldState extends State<CapsuleDisplayField> {crossAxisAlignment: CrossAxisAlignment.start,children: [if (widget.labelText.isNotEmpty) ...[- Text(widget.labelText, style: textTheme.body),+ Text(widget.labelText, style: TextStyles.body),const SizedBox(height: 8),],Container(decoration: BoxDecoration(- color: colorScheme.fillFaint,+ color: colors.fillDark,borderRadius: BorderRadius.circular(24),),child: Padding(@@ -308,7 +299,7 @@ class _CapsuleDisplayFieldState extends State<CapsuleDisplayField> {child: (widget.isSecret && !_isVisible)? Text(displayValue,- style: textTheme.body.copyWith(+ style: TextStyles.body.copyWith(height: textLineHeight,),maxLines: 1,@@ -316,7 +307,7 @@ class _CapsuleDisplayFieldState extends State<CapsuleDisplayField> {): SelectableText(displayValue,- style: textTheme.body.copyWith(+ style: TextStyles.body.copyWith(height: textLineHeight,),maxLines: widget.maxLines,@@ -333,7 +324,7 @@ class _CapsuleDisplayFieldState extends State<CapsuleDisplayField> {child: Container(padding: const EdgeInsets.all(8),decoration: BoxDecoration(- color: colorScheme.fillBase.withValues(alpha: 0.1),+ color: colors.fillBase.withValues(alpha: 0.1),borderRadius: BorderRadius.circular(12),),child: Icon(@@ -342,7 +333,7 @@ class _CapsuleDisplayFieldState extends State<CapsuleDisplayField> {semanticLabel: _isVisible? 'hide_password': 'show_password',- color: colorScheme.textMuted,+ color: colors.textLight,),),),@@ -354,13 +345,13 @@ class _CapsuleDisplayFieldState extends State<CapsuleDisplayField> {child: Container(padding: const EdgeInsets.all(8),decoration: BoxDecoration(- color: colorScheme.fillBase.withValues(alpha: 0.1),+ color: colors.fillBase.withValues(alpha: 0.1),borderRadius: BorderRadius.circular(12),),child: Icon(Icons.copy,size: 16,- color: colorScheme.textMuted,+ color: colors.textLight,),),),diff --git a/mobile/apps/locker/lib/ui/components/collection_selection_widget.dart b/mobile/apps/locker/lib/ui/components/collection_selection_widget.dartindex ce13400649..f53574c825 100644--- a/mobile/apps/locker/lib/ui/components/collection_selection_widget.dart+++ b/mobile/apps/locker/lib/ui/components/collection_selection_widget.dart@@ -1,7 +1,6 @@import 'package:collection/collection.dart' show IterableExtension;import 'package:dotted_border/dotted_border.dart';import "package:ente_components/ente_components.dart";-import 'package:ente_ui/theme/ente_theme.dart';import 'package:flutter/material.dart';import 'package:locker/extensions/collection_extension.dart';import 'package:locker/l10n/l10n.dart';@@ -158,8 +157,7 @@ class _CollectionSelectionWidgetState extends State<CollectionSelectionWidget> {}Widget _buildNewCollectionChip() {- final colorScheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);+ final colors = context.componentColors;return GestureDetector(behavior: HitTestBehavior.opaque,@@ -170,7 +168,7 @@ class _CollectionSelectionWidgetState extends State<CollectionSelectionWidget> {options: RoundedRectDottedBorderOptions(strokeWidth: 1,padding: EdgeInsets.zero,- color: colorScheme.textFaint,+ color: colors.textLighter,dashPattern: const [5, 5],radius: const Radius.circular(16),),@@ -180,11 +178,11 @@ class _CollectionSelectionWidgetState extends State<CollectionSelectionWidget> {child: Row(mainAxisSize: MainAxisSize.min,children: [- Icon(Icons.add_rounded, size: 18, color: colorScheme.textMuted),+ Icon(Icons.add_rounded, size: 18, color: colors.textLight),const SizedBox(width: 6),Text(context.l10n.collectionLabel,- style: textTheme.small.copyWith(color: colorScheme.textMuted),+ style: TextStyles.body.copyWith(color: colors.textLight),),],),diff --git a/mobile/apps/locker/lib/ui/components/custom_list_scrollbar.dart b/mobile/apps/locker/lib/ui/components/custom_list_scrollbar.dartindex b22a697de9..2a8fd3484c 100644--- a/mobile/apps/locker/lib/ui/components/custom_list_scrollbar.dart+++ b/mobile/apps/locker/lib/ui/components/custom_list_scrollbar.dart@@ -1,4 +1,4 @@-import 'package:ente_ui/theme/colors.dart';+import 'package:ente_components/ente_components.dart';import 'package:flutter/material.dart';/// A thin scrollbar rendered beside a bounded [ListView], with the thumb sized@@ -11,17 +11,16 @@ class CustomListScrollbar extends StatelessWidget {required this.itemCount,required this.visibleItems,required this.containerHeight,- required this.colorScheme,});final ScrollController scrollController;final int itemCount;final int visibleItems;final double containerHeight;- final EnteColorScheme colorScheme;@overrideWidget build(BuildContext context) {+ final colors = context.componentColors;final thumbHeightRatio = visibleItems / itemCount;final thumbHeight = containerHeight * thumbHeightRatio;@@ -49,7 +48,7 @@ class CustomListScrollbar extends StatelessWidget {width: 5,height: containerHeight,decoration: BoxDecoration(- color: colorScheme.strokeFaint,+ color: colors.strokeFaint,borderRadius: BorderRadius.circular(3),),),@@ -59,7 +58,7 @@ class CustomListScrollbar extends StatelessWidget {width: 5,height: thumbHeight,decoration: BoxDecoration(- color: colorScheme.strokeMuted,+ color: colors.strokeDark,borderRadius: BorderRadius.circular(3),),),diff --git a/mobile/apps/locker/lib/ui/components/empty_state_widget.dart b/mobile/apps/locker/lib/ui/components/empty_state_widget.dartindex f2b13cf87d..7e67f614ff 100644--- a/mobile/apps/locker/lib/ui/components/empty_state_widget.dart+++ b/mobile/apps/locker/lib/ui/components/empty_state_widget.dart@@ -1,5 +1,5 @@import "package:dotted_border/dotted_border.dart";-import "package:ente_ui/theme/ente_theme.dart";+import "package:ente_components/ente_components.dart";import "package:flutter/material.dart";class EmptyStateWidget extends StatelessWidget {@@ -28,15 +28,14 @@ class EmptyStateWidget extends StatelessWidget {@overrideWidget build(BuildContext context) {- final colorScheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);+ final colors = context.componentColors;final content = GestureDetector(onTap: onTap,child: Container(width: double.infinity,decoration: BoxDecoration(- color: colorScheme.backdropBase,+ color: colors.fillLight,borderRadius: BorderRadius.circular(24),),padding: EdgeInsets.symmetric(@@ -53,16 +52,14 @@ class EmptyStateWidget extends StatelessWidget {if (title != null && title!.isNotEmpty)Text(title!,- style: textTheme.largeBold.copyWith(- color: colorScheme.textBase,- ),+ style: TextStyles.large,textAlign: TextAlign.center,),if (title != null && title!.isNotEmpty) const SizedBox(height: 12),if (subtitle != null && subtitle!.isNotEmpty)Text(subtitle!,- style: textTheme.small.copyWith(color: colorScheme.textMuted),+ style: TextStyles.body.copyWith(color: colors.textLight),textAlign: TextAlign.center,),],@@ -77,7 +74,7 @@ class EmptyStateWidget extends StatelessWidget {return DottedBorder(options: RoundedRectDottedBorderOptions(strokeWidth: 1,- color: colorScheme.textFaint,+ color: colors.textLighter,dashPattern: const [5, 5],radius: const Radius.circular(24),),diff --git a/mobile/apps/locker/lib/ui/components/form_text_input_widget.dart b/mobile/apps/locker/lib/ui/components/form_text_input_widget.dartindex c5a5cc2758..e9de134b21 100644--- a/mobile/apps/locker/lib/ui/components/form_text_input_widget.dart+++ b/mobile/apps/locker/lib/ui/components/form_text_input_widget.dart@@ -1,5 +1,5 @@+import 'package:ente_components/ente_components.dart';import 'package:ente_ui/components/text_input_widget.dart';-import 'package:ente_ui/theme/ente_theme.dart';import 'package:flutter/material.dart';import 'package:flutter/services.dart';@@ -81,8 +81,7 @@ class _FormTextInputWidgetState extends State<FormTextInputWidget> {@overrideWidget build(BuildContext context) {- final colorScheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);+ final colors = context.componentColors;return Column(crossAxisAlignment: CrossAxisAlignment.start,@@ -107,7 +106,7 @@ class _FormTextInputWidgetState extends State<FormTextInputWidget> {] else ...[// Custom implementation for advanced featuresif (widget.labelText.isNotEmpty) ...[- Text(widget.labelText, style: textTheme.body),+ Text(widget.labelText, style: TextStyles.body),const SizedBox(height: 8),],ClipRRect(@@ -126,14 +125,14 @@ class _FormTextInputWidgetState extends State<FormTextInputWidget> {inputFormatters: widget.maxLength != null? [LengthLimitingTextInputFormatter(widget.maxLength!)]: null,- style: textTheme.body,+ style: TextStyles.body,decoration: InputDecoration(hintText: widget.hintText,- hintStyle: textTheme.body.copyWith(- color: colorScheme.textFaint,+ hintStyle: TextStyles.body.copyWith(+ color: colors.textLighter,),filled: true,- fillColor: colorScheme.fillFaint,+ fillColor: colors.fillDark,contentPadding: const EdgeInsets.fromLTRB(12, 12, 12, 12),border: const UnderlineInputBorder(borderSide: BorderSide.none,@@ -143,24 +142,15 @@ class _FormTextInputWidgetState extends State<FormTextInputWidget> {borderRadius: BorderRadius.circular(8),),focusedBorder: OutlineInputBorder(- borderSide: BorderSide(- color: colorScheme.strokeFaint,- width: 2,- ),+ borderSide: BorderSide(color: colors.strokeFaint, width: 2),borderRadius: BorderRadius.circular(8),),errorBorder: OutlineInputBorder(- borderSide: BorderSide(- color: colorScheme.warning500,- width: 1,- ),+ borderSide: BorderSide(color: colors.warning, width: 1),borderRadius: BorderRadius.circular(8),),focusedErrorBorder: OutlineInputBorder(- borderSide: BorderSide(- color: colorScheme.warning500,- width: 2,- ),+ borderSide: BorderSide(color: colors.warning, width: 2),borderRadius: BorderRadius.circular(8),),suffixIcon: widget.suffixIcon != null@@ -189,7 +179,7 @@ class _FormTextInputWidgetState extends State<FormTextInputWidget> {padding: const EdgeInsets.symmetric(horizontal: 8),child: Text(_errorText!,- style: textTheme.mini.copyWith(color: colorScheme.warning500),+ style: TextStyles.mini.copyWith(color: colors.warning),),),],diff --git a/mobile/apps/locker/lib/ui/settings/pages/settings_search_page.dart b/mobile/apps/locker/lib/ui/settings/pages/settings_search_page.dartindex 5feccd55ca..ae1c27f89c 100644--- a/mobile/apps/locker/lib/ui/settings/pages/settings_search_page.dart+++ b/mobile/apps/locker/lib/ui/settings/pages/settings_search_page.dart@@ -379,12 +379,7 @@ class _SettingsSearchPageState extends State<SettingsSearchPage> {crossAxisAlignment: CrossAxisAlignment.start,children: [const SizedBox(height: 8),- Text(- context.l10n.suggestions,- style: TextStyles.large.copyWith(- color: context.componentColors.textBase,- ),- ),+ Text(context.l10n.suggestions, style: TextStyles.large),const SizedBox(height: 12),Wrap(spacing: 8,@@ -449,12 +444,7 @@ class _SettingsSearchPageState extends State<SettingsSearchPage> {rows.add(Padding(padding: const EdgeInsets.only(top: 12, bottom: 8),- child: Text(- entry.category,- style: TextStyles.large.copyWith(- color: context.componentColors.textBase,- ),- ),+ child: Text(entry.category, style: TextStyles.large),),);}diff --git a/mobile/apps/locker/lib/ui/settings/pages/support_page.dart b/mobile/apps/locker/lib/ui/settings/pages/support_page.dartindex 768e49e7aa..bb132022a6 100644--- a/mobile/apps/locker/lib/ui/settings/pages/support_page.dart+++ b/mobile/apps/locker/lib/ui/settings/pages/support_page.dart@@ -127,13 +127,9 @@ class SupportPage extends StatelessWidget {}Widget _sectionTitle(BuildContext context, String title) {- final colors = context.componentColors;return Padding(padding: const EdgeInsets.only(left: Spacing.sm, top: 6, bottom: 6),- child: Text(- title,- style: TextStyles.large.copyWith(color: colors.textBase),- ),+ child: Text(title, style: TextStyles.large),);}