π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Refactor UI components and improve icon handling across the application
AmanRajSinghMourya50e026181fae
diff --git a/mobile/apps/locker/lib/l10n/app_en.arb b/mobile/apps/locker/lib/l10n/app_en.arbindex 5ad29333e8..79d8d2263e 100644--- a/mobile/apps/locker/lib/l10n/app_en.arb+++ b/mobile/apps/locker/lib/l10n/app_en.arb@@ -608,5 +608,6 @@"hideWindow": "Hide Window","showWindow": "Show Window","exitApp": "Exit App",- "lockerLogs": "Locker logs"+ "lockerLogs": "Locker logs",+ "recents": "Recents"}diff --git a/mobile/apps/locker/lib/l10n/app_localizations.dart b/mobile/apps/locker/lib/l10n/app_localizations.dartindex 5bc5eb24af..f347a4c76d 100644--- a/mobile/apps/locker/lib/l10n/app_localizations.dart+++ b/mobile/apps/locker/lib/l10n/app_localizations.dart@@ -1977,6 +1977,12 @@ abstract class AppLocalizations {/// In en, this message translates to:/// **'Locker logs'**String get lockerLogs;++ /// No description provided for @recents.+ ///+ /// In en, this message translates to:+ /// **'Recents'**+ String get recents;}class _AppLocalizationsDelegatediff --git a/mobile/apps/locker/lib/l10n/app_localizations_en.dart b/mobile/apps/locker/lib/l10n/app_localizations_en.dartindex bab8945149..d95df844e3 100644--- a/mobile/apps/locker/lib/l10n/app_localizations_en.dart+++ b/mobile/apps/locker/lib/l10n/app_localizations_en.dart@@ -1116,4 +1116,7 @@ class AppLocalizationsEn extends AppLocalizations {@overrideString get lockerLogs => 'Locker logs';++ @override+ String get recents => 'Recents';}diff --git a/mobile/apps/locker/lib/ui/collections/collection_flex_grid_view.dart b/mobile/apps/locker/lib/ui/collections/collection_flex_grid_view.dartindex 6d4bb99e1a..115c9b104e 100644--- a/mobile/apps/locker/lib/ui/collections/collection_flex_grid_view.dart+++ b/mobile/apps/locker/lib/ui/collections/collection_flex_grid_view.dart@@ -42,7 +42,7 @@ class _CollectionFlexGridViewWidgetStatecrossAxisCount: 2,crossAxisSpacing: 12,mainAxisSpacing: 12,- childAspectRatio: 2.2,+ childAspectRatio: 1.5,),itemCount: min(_displayedCollections.length, 4),itemBuilder: (context, index) {@@ -54,52 +54,55 @@ class _CollectionFlexGridViewWidgetStateonTap: () => _navigateToCollection(collection),child: Container(decoration: BoxDecoration(- borderRadius: BorderRadius.circular(8),- color: getEnteColorScheme(context).fillFaint,+ borderRadius: BorderRadius.circular(20),+ color: getEnteColorScheme(context).backdropBase,),padding: const EdgeInsets.all(12),- child: Stack(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisAlignment: MainAxisAlignment.center,children: [- Column(- crossAxisAlignment: CrossAxisAlignment.start,- mainAxisAlignment: MainAxisAlignment.center,- children: [- Text(- collectionName,- style: getEnteTextTheme(context).body.copyWith(- fontWeight: FontWeight.w500,+ Container(+ height: 48,+ width: 48,+ decoration: BoxDecoration(+ color: getEnteColorScheme(context).backgroundBase,+ borderRadius: BorderRadius.circular(16),+ ),+ child: collection.type == CollectionType.favorites+ ? Icon(+ Icons.star,+ color: getEnteColorScheme(context).primary500,+ size: 22,+ )+ : Icon(+ Icons.folder,+ size: 22,+ color: getEnteColorScheme(context).primary500,+ ),+ ),+ const SizedBox(height: 12),+ Text(+ collectionName,+ style: getEnteTextTheme(context).bodyBold,+ textAlign: TextAlign.left,+ overflow: TextOverflow.ellipsis,+ maxLines: 1,+ ),+ const SizedBox(height: 4),+ FutureBuilder<int>(+ future: CollectionService.instance.getFileCount(collection),+ builder: (context, snapshot) {+ final fileCount = snapshot.data ?? 0;+ return Text(+ context.l10n.items(fileCount),+ style: getEnteTextTheme(context).small.copyWith(+ color: Colors.grey[600],),textAlign: TextAlign.left,- overflow: TextOverflow.ellipsis,- maxLines: 1,- ),- const SizedBox(height: 4),- FutureBuilder<int>(- future:- CollectionService.instance.getFileCount(collection),- builder: (context, snapshot) {- final fileCount = snapshot.data ?? 0;- return Text(- context.l10n.items(fileCount),- style: getEnteTextTheme(context).small.copyWith(- color: Colors.grey[600],- ),- textAlign: TextAlign.left,- );- },- ),- ],+ );+ },),- if (collection.type == CollectionType.favorites)- Positioned(- top: 0,- right: 0,- child: Icon(- Icons.star,- color: getEnteColorScheme(context).primary500,- size: 18,- ),- ),],),),diff --git a/mobile/apps/locker/lib/ui/collections/section_title.dart b/mobile/apps/locker/lib/ui/collections/section_title.dartindex 81f9056b24..c0c559c128 100644--- a/mobile/apps/locker/lib/ui/collections/section_title.dart+++ b/mobile/apps/locker/lib/ui/collections/section_title.dart@@ -36,11 +36,13 @@ class SectionOptions extends StatelessWidget {final Widget title;final Widget? trailingWidget;final VoidCallback? onTap;+ final String? body;const SectionOptions(this.title, {this.trailingWidget,super.key,+ this.body,this.onTap,});@@ -50,11 +52,20 @@ class SectionOptions extends StatelessWidget {return GestureDetector(behavior: HitTestBehavior.opaque,onTap: onTap,- child: Row(- mainAxisAlignment: MainAxisAlignment.spaceBetween,+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,children: [- title,- trailingWidget!,+ Row(+ mainAxisAlignment: MainAxisAlignment.spaceBetween,+ children: [+ title,+ trailingWidget!,+ ],+ ),+ Text(+ body ?? "",+ style: getEnteTextTheme(context).bodyMuted,+ ),],),);diff --git a/mobile/apps/locker/lib/ui/components/file_edit_dialog.dart b/mobile/apps/locker/lib/ui/components/file_edit_dialog.dartindex 0851a7acb3..f552883ee2 100644--- a/mobile/apps/locker/lib/ui/components/file_edit_dialog.dart+++ b/mobile/apps/locker/lib/ui/components/file_edit_dialog.dart@@ -136,10 +136,10 @@ class _FileEditDialogState extends State<FileEditDialog> {children: [Row(children: [- Icon(- FileIconUtils.getFileIcon(_fileName),- color: FileIconUtils.getFileIconColor(_fileName),+ FileIconUtils.getFileIcon(+ _fileName,size: 24,+ showBackground: false,),const SizedBox(width: 8),Expanded(diff --git a/mobile/apps/locker/lib/ui/components/file_row_widget.dart b/mobile/apps/locker/lib/ui/components/file_row_widget.dartindex 139f59f0b6..ade586a392 100644--- a/mobile/apps/locker/lib/ui/components/file_row_widget.dart+++ b/mobile/apps/locker/lib/ui/components/file_row_widget.dart@@ -6,6 +6,7 @@ import "package:ente_ui/components/buttons/models/button_type.dart";import "package:ente_ui/theme/ente_theme.dart";import "package:ente_ui/utils/dialog_util.dart";import "package:flutter/material.dart";+import "package:hugeicons/hugeicons.dart";import "package:locker/l10n/l10n.dart";import "package:locker/models/info/info_item.dart";import "package:locker/models/selected_files.dart";@@ -26,6 +27,7 @@ import "package:locker/ui/pages/emergency_contact_page.dart";import "package:locker/ui/pages/personal_note_page.dart";import "package:locker/ui/pages/physical_records_page.dart";import "package:locker/utils/file_icon_utils.dart";+import "package:locker/utils/info_item_utils.dart";import "package:locker/utils/snack_bar_utils.dart";import "package:open_file/open_file.dart";@@ -59,7 +61,7 @@ class FileRowWidget extends StatelessWidget {children: [SizedBox(height: 60,- width: 48,+ width: 60,child: _buildFileIcon(),),const SizedBox(width: 12),@@ -107,9 +109,10 @@ class FileRowWidget extends StatelessWidget {border: Border.all(color: isSelected? colorScheme.strokeMuted- : colorScheme.strokeFainter,+ : colorScheme.backdropBase,),- borderRadius: const BorderRadius.all(Radius.circular(6)),+ color: colorScheme.backdropBase,+ borderRadius: const BorderRadius.all(Radius.circular(20)),),child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween,@@ -131,8 +134,8 @@ class FileRowWidget extends StatelessWidget {: PopupMenuButton<String>(onSelected: (value) =>_handleMenuAction(context, value),- icon: const Icon(- Icons.more_vert,+ icon: const HugeIcon(+ icon: HugeIcons.strokeRoundedMoreVertical,size: 20,),itemBuilder: (BuildContext context) {@@ -157,7 +160,10 @@ class FileRowWidget extends StatelessWidget {value: action.id,child: Row(children: [- Icon(action.icon, size: 16),+ const HugeIcon(+ icon: HugeIcons.strokeRoundedFile02,+ size: 16,+ ),const SizedBox(width: 8),Text(action.label),],@@ -171,7 +177,10 @@ class FileRowWidget extends StatelessWidget {value: 'edit',child: Row(children: [- const Icon(Icons.edit, size: 16),+ const HugeIcon(+ icon: HugeIcons.strokeRoundedEdit02,+ size: 16,+ ),const SizedBox(width: 8),Text(context.l10n.edit),],@@ -181,7 +190,10 @@ class FileRowWidget extends StatelessWidget {value: 'share_link',child: Row(children: [- const Icon(Icons.share, size: 16),+ const HugeIcon(+ icon: HugeIcons.strokeRoundedShare03,+ size: 16,+ ),const SizedBox(width: 8),Text(context.l10n.share),],@@ -191,7 +203,10 @@ class FileRowWidget extends StatelessWidget {value: 'delete',child: Row(children: [- const Icon(Icons.delete, size: 16),+ const HugeIcon(+ icon: HugeIcons.strokeRoundedDelete01,+ size: 16,+ ),const SizedBox(width: 8),Text(context.l10n.delete),],@@ -407,11 +422,7 @@ class FileRowWidget extends StatelessWidget {try {final infoItem = InfoFileService.instance.extractInfoFromFile(file);if (infoItem != null) {- return Icon(- _getInfoTypeIcon(infoItem.type),- color: _getInfoTypeColor(infoItem.type),- size: 20,- );+ return InfoItemUtils.getInfoIcon(infoItem.type);}} catch (e) {// Fallback to default icon if extraction fails@@ -419,37 +430,7 @@ class FileRowWidget extends StatelessWidget {}// For non-info files or if extraction fails, use the original logic- return Icon(- FileIconUtils.getFileIcon(file.displayName),- color: FileIconUtils.getFileIconColor(file.displayName),- size: 20,- );- }-- IconData _getInfoTypeIcon(InfoType type) {- switch (type) {- case InfoType.note:- return Icons.note;- case InfoType.accountCredential:- return Icons.key;- case InfoType.physicalRecord:- return Icons.inventory;- case InfoType.emergencyContact:- return Icons.emergency;- }- }-- Color _getInfoTypeColor(InfoType type) {- switch (type) {- case InfoType.note:- return Colors.blue;- case InfoType.accountCredential:- return Colors.orange;- case InfoType.physicalRecord:- return Colors.green;- case InfoType.emergencyContact:- return Colors.red;- }+ return FileIconUtils.getFileIcon(file.displayName, showBackground: true);}Future<void> _openFile(BuildContext context) async {diff --git a/mobile/apps/locker/lib/ui/components/file_upload_dialog.dart b/mobile/apps/locker/lib/ui/components/file_upload_dialog.dartindex f1bcdd38c9..dc27035512 100644--- a/mobile/apps/locker/lib/ui/components/file_upload_dialog.dart+++ b/mobile/apps/locker/lib/ui/components/file_upload_dialog.dart@@ -123,10 +123,10 @@ class _FileUploadDialogState extends State<FileUploadDialog> {children: [Row(children: [- Icon(- FileIconUtils.getFileIcon(_fileName),- color: FileIconUtils.getFileIconColor(_fileName),+ FileIconUtils.getFileIcon(+ _fileName,size: 24,+ showBackground: false,),const SizedBox(width: 8),Expanded(diff --git a/mobile/apps/locker/lib/ui/components/recents_section_widget.dart b/mobile/apps/locker/lib/ui/components/recents_section_widget.dartindex 3d9abea2df..bb3e6a5a65 100644--- a/mobile/apps/locker/lib/ui/components/recents_section_widget.dart+++ b/mobile/apps/locker/lib/ui/components/recents_section_widget.dart@@ -9,6 +9,7 @@ import 'package:locker/models/info/info_item.dart';import 'package:locker/services/collections/collections_service.dart';import 'package:locker/services/collections/models/collection.dart';import 'package:locker/services/files/sync/models/file.dart';+import "package:locker/ui/collections/section_title.dart";import 'package:locker/ui/components/item_list_view.dart';class RecentsSectionWidget extends StatefulWidget {@@ -88,9 +89,21 @@ class _RecentsSectionWidgetState extends State<RecentsSectionWidget> {}Widget _buildRecentsHeader() {- return Text(- 'Recents',- style: getEnteTextTheme(context).h3Bold,+ return SectionOptions(+ onTap: () {},+ body: context.l10n.items(_displayedFiles.length),+ SectionTitle(title: context.l10n.recents),+ trailingWidget: Container(+ height: 48,+ width: 48,+ decoration: BoxDecoration(+ borderRadius: BorderRadius.circular(12),+ color: getEnteColorScheme(context).backdropBase,+ ),+ child: const Icon(+ Icons.grid_view_outlined,+ ),+ ),);}diff --git a/mobile/apps/locker/lib/ui/pages/home_page.dart b/mobile/apps/locker/lib/ui/pages/home_page.dartindex 2aedb27bd7..33d502e1dc 100644--- a/mobile/apps/locker/lib/ui/pages/home_page.dart+++ b/mobile/apps/locker/lib/ui/pages/home_page.dart@@ -367,6 +367,7 @@ class _HomePageState extends UploaderPageState<HomePage>@overrideWidget build(BuildContext context) {+ final colorScheme = getEnteColorScheme(context);return PopScope(onPopInvokedWithResult: (_, result) async {if (_isSettingsOpen) {@@ -382,13 +383,16 @@ class _HomePageState extends UploaderPageState<HomePage>onKeyEvent: handleKeyEvent,child: Scaffold(key: scaffoldKey,+ backgroundColor: colorScheme.backgroundBase,drawer: Drawer(width: 428,+ backgroundColor: colorScheme.backgroundBase,child: _settingsPage,),drawerEnableOpenDragGesture: !Platform.isAndroid,onDrawerChanged: (isOpened) => _isSettingsOpen = isOpened,appBar: AppBar(+ surfaceTintColor: Colors.transparent,leading: buildSearchLeading(),title: GestureDetector(onLongPress: () {@@ -405,8 +409,7 @@ class _HomePageState extends UploaderPageState<HomePage>),),elevation: 0,- backgroundColor: Theme.of(context).scaffoldBackgroundColor,- foregroundColor: Theme.of(context).textTheme.bodyLarge?.color,+ backgroundColor: colorScheme.backgroundBase,actions: [buildSearchAction(),...buildSearchActions(),@@ -771,11 +774,12 @@ class _HomePageState extends UploaderPageState<HomePage>),);},+ body: context.l10n.items(collections.length),SectionTitle(title: title),trailingWidget: IconButtonWidget(icon: Icons.chevron_right,iconButtonType: IconButtonType.secondary,- iconColor: getEnteColorScheme(context).blurStrokePressed,+ iconColor: getEnteColorScheme(context).textBase,),),const SizedBox(height: 24),diff --git a/mobile/apps/locker/lib/utils/file_icon_utils.dart b/mobile/apps/locker/lib/utils/file_icon_utils.dartindex bc1f238200..11cfa49f88 100644--- a/mobile/apps/locker/lib/utils/file_icon_utils.dart+++ b/mobile/apps/locker/lib/utils/file_icon_utils.dart@@ -1,13 +1,16 @@import 'package:flutter/material.dart';+import 'package:hugeicons/hugeicons.dart';class FileIconConfig {- final IconData icon;+ final dynamic icon;final Color color;+ final Color backgroundColor;final Set<String> extensions;const FileIconConfig({required this.icon,required this.color,+ required this.backgroundColor,required this.extensions,});}@@ -17,30 +20,35 @@ class FileIconUtils {static const Map<String, FileIconConfig> _fileTypeConfigs = {'pdf': FileIconConfig(extensions: {'.pdf'},- icon: Icons.picture_as_pdf,- color: Colors.red,+ icon: HugeIcons.strokeRoundedFile01,+ color: Color.fromRGBO(246, 58, 58, 1),+ backgroundColor: Color.fromRGBO(255, 58, 58, 0.06),),'image': FileIconConfig(extensions: {'.jpg', '.png', '.heic'},- icon: Icons.image,- color: Colors.blue,+ icon: HugeIcons.strokeRoundedImage01,+ color: Color.fromRGBO(8, 194, 37, 1),+ backgroundColor: Color.fromRGBO(8, 194, 37, 0.06),),'presentation': FileIconConfig(extensions: {'.pptx'},- icon: Icons.slideshow,- color: Colors.orange,+ icon: HugeIcons.strokeRoundedPresentation01,+ color: Color.fromRGBO(16, 113, 255, 1),+ backgroundColor: Color.fromRGBO(16, 113, 255, 0.06),),'spreadsheet': FileIconConfig(extensions: {'.xlsx'},- icon: Icons.table_chart,- color: Colors.green,+ icon: HugeIcons.strokeRoundedTable01,+ color: Color(0xFF388E3C),+ backgroundColor: Color(0xFFE8F5E9),),};static const FileIconConfig _defaultConfig = FileIconConfig(extensions: {},- icon: Icons.insert_drive_file,- color: Colors.grey,+ icon: HugeIcons.strokeRoundedFile02,+ color: Color(0xFF757575),+ backgroundColor: Color(0xFFFAFAFA),);static FileIconConfig _getFileConfig(String fileName) {@@ -62,11 +70,45 @@ class FileIconUtils {return _defaultConfig;}- static IconData getFileIcon(String fileName) {- return _getFileConfig(fileName).icon;+ static Widget getFileIcon(+ String fileName, {+ bool showBackground = true,+ double size = 20,+ }) {+ final config = _getFileConfig(fileName);++ final icon = HugeIcon(+ icon: config.icon,+ color: config.color,+ size: size,+ );++ if (!showBackground) {+ return icon;+ }++ return Padding(+ padding: const EdgeInsets.all(8.0),+ child: Container(+ height: 48,+ width: 48,+ decoration: BoxDecoration(+ color: config.backgroundColor,+ borderRadius: BorderRadius.circular(12),+ ),+ child: Padding(+ padding: const EdgeInsets.all(8.0),+ child: icon,+ ),+ ),+ );}- static Color getFileIconColor(String fileName) {+ Color getFileIconColor(String fileName) {return _getFileConfig(fileName).color;}++ Color getFileIconBackgroundColor(String fileName) {+ return _getFileConfig(fileName).backgroundColor;+ }}diff --git a/mobile/apps/locker/lib/utils/info_item_utils.dart b/mobile/apps/locker/lib/utils/info_item_utils.dartnew file mode 100644index 0000000000..6f662e6b28--- /dev/null+++ b/mobile/apps/locker/lib/utils/info_item_utils.dart@@ -0,0 +1,79 @@+import 'package:flutter/material.dart';+import 'package:hugeicons/hugeicons.dart';+import 'package:locker/models/info/info_item.dart';++class InfoIconConfig {+ final dynamic icon;+ final Color color;+ final Color backgroundColor;++ const InfoIconConfig({+ required this.icon,+ required this.color,+ required this.backgroundColor,+ });+}++class InfoItemUtils {+ // Centralized configuration - change icons and colors here only+ static const Map<InfoType, InfoIconConfig> _infoTypeConfigs = {+ InfoType.note: InfoIconConfig(+ icon: HugeIcons.strokeRoundedNote,+ color: Color.fromRGBO(255, 152, 0, 1),+ backgroundColor: Color.fromRGBO(255, 152, 0, 0.06),+ ),+ InfoType.physicalRecord: InfoIconConfig(+ icon: HugeIcons.strokeRoundedFolder01,+ color: Color.fromRGBO(156, 39, 176, 1),+ backgroundColor: Color.fromRGBO(156, 39, 176, 0.06),+ ),+ InfoType.accountCredential: InfoIconConfig(+ icon: HugeIcons.strokeRoundedKey01,+ color: Color.fromRGBO(16, 113, 255, 1),+ backgroundColor: Color.fromRGBO(16, 113, 255, 0.06),+ ),+ InfoType.emergencyContact: InfoIconConfig(+ icon: HugeIcons.strokeRoundedContactBook,+ color: Color.fromRGBO(244, 67, 54, 1),+ backgroundColor: Color.fromRGBO(244, 67, 54, 0.06),+ ),+ };++ static InfoIconConfig _getInfoConfig(InfoType type) {+ return _infoTypeConfigs[type] ?? _infoTypeConfigs[InfoType.note]!;+ }++ static Widget getInfoIcon(+ InfoType type, {+ bool showBackground = true,+ double size = 20,+ }) {+ final config = _getInfoConfig(type);++ final icon = HugeIcon(+ icon: config.icon,+ color: config.color,+ size: size,+ );++ if (!showBackground) {+ return icon;+ }++ return Padding(+ padding: const EdgeInsets.all(8.0),+ child: Container(+ height: 48,+ width: 48,+ decoration: BoxDecoration(+ color: config.backgroundColor,+ borderRadius: BorderRadius.circular(12),+ ),+ child: Padding(+ padding: const EdgeInsets.all(8.0),+ child: icon,+ ),+ ),+ );+ }+}diff --git a/mobile/packages/ui/lib/theme/colors.dart b/mobile/packages/ui/lib/theme/colors.dartindex cecc222db7..21786e8ac2 100644--- a/mobile/packages/ui/lib/theme/colors.dart+++ b/mobile/packages/ui/lib/theme/colors.dart@@ -620,7 +620,7 @@ const EnteColorScheme darkScheme = EnteColorScheme();// Background Colors-const Color backgroundBaseLight = Color.fromRGBO(255, 255, 255, 1);+const Color backgroundBaseLight = Color.fromRGBO(250, 250, 250, 1);const Color backgroundElevatedLight = Color.fromRGBO(255, 255, 255, 1);const Color backgroundElevated2Light = Color.fromRGBO(251, 251, 251, 1);@@ -782,9 +782,9 @@ const Color _defaultSearchResultsBackgroundColor =// Default Code Card Background Colorconst Color _defaultCodeCardBackgroundColor = Color.fromRGBO(246, 246, 246, 1);-const Color _golden700 = Color(0xFFFDB816);const Color _golden500 = Color(0xFFFFC336);+/// Utility class to help apps create custom color schemes with their brand colors.////// This class provides convenient methods to generate complete color schemes