Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][locker] Migrate home search and icon colors

aman-pilot66047b84cca1
diff --git a/mobile/apps/locker/lib/ui/components/collection_popup_menu_widget.dart b/mobile/apps/locker/lib/ui/components/collection_popup_menu_widget.dart
index 20b12a5fb8..e69ba716df 100644
--- a/mobile/apps/locker/lib/ui/components/collection_popup_menu_widget.dart
+++ b/mobile/apps/locker/lib/ui/components/collection_popup_menu_widget.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:hugeicons/hugeicons.dart";
import "package:locker/l10n/l10n.dart";
@@ -20,27 +20,27 @@ class CollectionPopupMenuWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
+ final colors = context.componentColors;
return PopupMenuButton<String>(
onSelected: (value) => _handleMenuAction(context, value),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
- side: BorderSide(color: colorScheme.strokeFaint),
+ side: BorderSide(color: colors.strokeFaint),
),
padding: EdgeInsets.zero,
menuPadding: EdgeInsets.zero,
- color: colorScheme.backdropBase,
+ color: colors.fillLight,
surfaceTintColor: Colors.transparent,
elevation: 15,
offset: const Offset(-24, 24),
- shadowColor: Colors.black.withValues(alpha: 0.08),
+ shadowColor: colors.specialScrim.withValues(alpha: 0.08),
constraints: const BoxConstraints(minWidth: 120),
child:
child ??
HugeIcon(
icon: HugeIcons.strokeRoundedMoreVertical,
- color: colorScheme.textBase,
+ color: colors.textBase,
),
itemBuilder: (BuildContext context) {
return _buildPopupMenuItems(context);
@@ -49,7 +49,7 @@ class CollectionPopupMenuWidget extends StatelessWidget {
}
List<PopupMenuItem<String>> _buildPopupMenuItems(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
+ final colors = context.componentColors;
final collectionViewType = getCollectionViewType(
collection,
@@ -69,7 +69,7 @@ class CollectionPopupMenuWidget extends StatelessWidget {
child: PopupMenuItemWidget(
icon: HugeIcon(
icon: HugeIcons.strokeRoundedEdit02,
- color: colorScheme.textBase,
+ color: colors.textBase,
size: 20,
),
label: context.l10n.edit,
@@ -87,7 +87,7 @@ class CollectionPopupMenuWidget extends StatelessWidget {
child: PopupMenuItemWidget(
icon: HugeIcon(
icon: HugeIcons.strokeRoundedDelete01,
- color: colorScheme.warning500,
+ color: colors.warning,
size: 20,
),
label: context.l10n.delete,
@@ -109,7 +109,7 @@ class CollectionPopupMenuWidget extends StatelessWidget {
child: PopupMenuItemWidget(
icon: HugeIcon(
icon: HugeIcons.strokeRoundedLogout02,
- color: colorScheme.warning500,
+ color: colors.warning,
size: 20,
),
label: context.l10n.leaveCollection,
diff --git a/mobile/apps/locker/lib/ui/components/popup_menu_item_widget.dart b/mobile/apps/locker/lib/ui/components/popup_menu_item_widget.dart
index 38236417c2..e62ccce5b4 100644
--- a/mobile/apps/locker/lib/ui/components/popup_menu_item_widget.dart
+++ b/mobile/apps/locker/lib/ui/components/popup_menu_item_widget.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";
class PopupMenuItemWidget extends StatelessWidget {
@@ -21,19 +21,16 @@ class PopupMenuItemWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
+ final colors = context.componentColors;
final bottomPadding = MediaQuery.of(context).viewPadding.bottom;
return GestureDetector(
onTap: onTap,
child: Container(
decoration: BoxDecoration(
- color: colorScheme.backdropBase,
+ color: colors.fillLight,
border: !isLast
- ? Border(
- bottom: BorderSide(color: colorScheme.strokeFaint, width: 1),
- )
+ ? Border(bottom: BorderSide(color: colors.strokeFaint, width: 1))
: null,
borderRadius: BorderRadius.only(
topLeft: isFirst ? const Radius.circular(15) : Radius.zero,
@@ -56,8 +53,8 @@ class PopupMenuItemWidget extends StatelessWidget {
child: Text(
label,
style: isWarning
- ? textTheme.body.copyWith(color: colorScheme.warning500)
- : textTheme.body,
+ ? TextStyles.body.copyWith(color: colors.warning)
+ : TextStyles.body,
),
),
],
diff --git a/mobile/apps/locker/lib/ui/pages/home_page.dart b/mobile/apps/locker/lib/ui/pages/home_page.dart
index 2a9f70b9dd..927ee10520 100644
--- a/mobile/apps/locker/lib/ui/pages/home_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/home_page.dart
@@ -7,7 +7,6 @@ import "package:ente_components/ente_components.dart";
import 'package:ente_events/event_bus.dart';
import "package:ente_events/models/trigger_logout_event.dart";
import "package:ente_ui/components/alert_bottom_sheet.dart";
-import 'package:ente_ui/theme/ente_theme.dart';
import 'package:ente_ui/utils/dialog_util.dart';
import "package:ente_utils/email_util.dart";
import 'package:flutter/material.dart';
@@ -38,39 +37,34 @@ import 'package:logging/logging.dart';
class CustomLockerAppBar extends StatelessWidget
implements PreferredSizeWidget {
final GlobalKey<ScaffoldState> scaffoldKey;
- final bool isSearchActive;
final bool isSyncing;
final TextEditingController searchController;
final FocusNode searchFocusNode;
- final VoidCallback onSearchFocused;
final VoidCallback onClearSearch;
final ValueChanged<String>? onSearchChanged;
const CustomLockerAppBar({
super.key,
required this.scaffoldKey,
- required this.isSearchActive,
this.isSyncing = false,
required this.searchController,
required this.searchFocusNode,
- required this.onSearchFocused,
required this.onClearSearch,
this.onSearchChanged,
});
@override
- Size get preferredSize => const Size.fromHeight(156);
+ Size get preferredSize => const Size.fromHeight(140);
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
- final hasQuery = searchController.text.isNotEmpty;
- final showClearIcon = isSearchActive || hasQuery;
+ final colors = context.componentColors;
+ final hasQuery = searchController.text.trim().isNotEmpty;
+ final showClearIcon = searchFocusNode.hasFocus || hasQuery;
return Container(
decoration: BoxDecoration(
- color: colorScheme.primary700,
+ color: colors.primary,
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(20),
bottomRight: Radius.circular(20),
@@ -90,11 +84,11 @@ class CustomLockerAppBar extends StatelessWidget
onTap: () {
scaffoldKey.currentState!.openDrawer();
},
- child: const Padding(
- padding: EdgeInsets.symmetric(horizontal: 12),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 12),
child: HugeIcon(
icon: HugeIcons.strokeRoundedMenu01,
- color: Colors.white,
+ color: colors.specialWhite,
strokeWidth: 2.25,
),
),
@@ -104,21 +98,21 @@ class CustomLockerAppBar extends StatelessWidget
? Row(
mainAxisSize: MainAxisSize.min,
children: [
- const SizedBox(
+ SizedBox(
width: 16,
height: 16,
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(
- Colors.white,
+ colors.specialWhite,
),
),
),
const SizedBox(width: 8),
Text(
context.l10n.syncing,
- style: textTheme.body.copyWith(
- color: Colors.white,
+ style: TextStyles.body.copyWith(
+ color: colors.specialWhite,
),
),
],
@@ -128,65 +122,47 @@ class CustomLockerAppBar extends StatelessWidget
),
),
Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
- child: Container(
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(100),
- ),
- child: TextField(
- autocorrect: false,
- enableSuggestions: false,
- controller: searchController,
- focusNode: searchFocusNode,
- onTap: onSearchFocused,
- cursorColor: colorScheme.primary700,
- onChanged: onSearchChanged,
- textAlignVertical: TextAlignVertical.center,
- decoration: InputDecoration(
- hintText: context.l10n.searchHint,
- hintStyle: textTheme.smallBold.copyWith(
- color: colorScheme.iconColor,
- ),
- border: InputBorder.none,
- focusedBorder: InputBorder.none,
- isDense: true,
- contentPadding: const EdgeInsets.symmetric(
- horizontal: 16,
- vertical: 14,
- ),
- prefixIcon: Padding(
- padding: const EdgeInsets.only(left: 16, right: 8),
- child: HugeIcon(
- icon: HugeIcons.strokeRoundedSearch01,
- color: colorScheme.primary700,
- size: 20,
- strokeWidth: 1.75,
- ),
- ),
- prefixIconConstraints: const BoxConstraints(
- minWidth: 44,
- minHeight: 24,
- ),
- suffixIcon: showClearIcon
- ? IconButton(
- onPressed: onClearSearch,
- splashRadius: 20,
- padding: const EdgeInsets.only(right: 16, left: 8),
- icon: HugeIcon(
- icon: HugeIcons.strokeRoundedCancel01,
- color: colorScheme.iconColor,
- size: 20,
- ),
- )
- : null,
- suffixIconConstraints: const BoxConstraints(
- minWidth: 44,
- minHeight: 44,
- ),
- ),
- style: TextStyle(color: colorScheme.iconColor),
+ padding: const EdgeInsets.only(
+ left: 16,
+ right: 16,
+ top: 16,
+ bottom: 16,
+ ),
+ child: TextInputComponent(
+ controller: searchController,
+ focusNode: searchFocusNode,
+ hintText: context.l10n.searchHint,
+ onChanged: onSearchChanged,
+ autocorrect: false,
+ shouldUnfocusOnClearOrSubmit: true,
+ backgroundColor: colors.specialWhite,
+ textColor: Colors.black,
+ prefix: HugeIcon(
+ icon: HugeIcons.strokeRoundedSearch01,
+ color: colors.primary,
+ size: 20,
+ strokeWidth: 1.75,
),
+ suffix: showClearIcon
+ ? IconButton(
+ onPressed: onClearSearch,
+ splashRadius: 1,
+ padding: EdgeInsets.zero,
+ constraints: const BoxConstraints.tightFor(
+ width: 24,
+ height: 24,
+ ),
+ visualDensity: const VisualDensity(
+ horizontal: -1,
+ vertical: -1,
+ ),
+ icon: HugeIcon(
+ icon: HugeIcons.strokeRoundedCancel01,
+ color: colors.textLighter,
+ size: 20,
+ ),
+ )
+ : null,
),
),
],
@@ -212,7 +188,6 @@ class _HomePageState extends UploaderPageState<HomePage>
scaffoldKey: scaffoldKey,
);
final scaffoldKey = GlobalKey<ScaffoldState>();
- final _searchFocusNode = FocusNode();
final _selectedFiles = SelectedFiles();
final _scrollController = ScrollController();
bool _isLoading = true;
@@ -278,6 +253,8 @@ class _HomePageState extends UploaderPageState<HomePage>
void initState() {
super.initState();
+ searchFocusNode.addListener(_onSearchFocusChanged);
+
_loadCollections();
// Initialize sharing functionality to handle shared files
@@ -320,7 +297,7 @@ class _HomePageState extends UploaderPageState<HomePage>
@override
void dispose() {
- _searchFocusNode.dispose();
+ searchFocusNode.removeListener(_onSearchFocusChanged);
_scrollController.dispose();
_displayedFilesNotifier.dispose();
_deepLinkSubscription?.cancel();
@@ -584,29 +561,35 @@ class _HomePageState extends UploaderPageState<HomePage>
}
void _handleSearchChange(String query) {
- // Trigger search by activating search with the current query
- activateSearchWithQuery(query);
+ updateSearchQuery(query);
}
- void _handleSearchFocused() {
- // Activate search when TextField is tapped/focused
- if (!isSearchActive) {
+ void _onSearchFocusChanged() {
+ if (!mounted) return;
+ if (searchFocusNode.hasFocus && !isSearchActive) {
activateSearchWithQuery('');
+ return;
+ }
+ if (!searchFocusNode.hasFocus &&
+ isSearchActive &&
+ searchController.text.trim().isEmpty) {
+ dismissSearch();
+ return;
}
+ setState(() {});
}
void _handleClearSearch() {
// Clear text and unfocus before dismissing search
searchController.clear();
- _searchFocusNode.unfocus();
+ searchFocusNode.unfocus();
dismissSearch();
}
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final componentColors = context.componentColors;
+ final colors = context.componentColors;
return UserDetailsStateWidget(
child: ListenableBuilder(
listenable: _selectedFiles,
@@ -639,10 +622,10 @@ class _HomePageState extends UploaderPageState<HomePage>
onKeyEvent: handleKeyEvent,
child: Scaffold(
key: scaffoldKey,
- backgroundColor: colorScheme.backgroundBase,
+ backgroundColor: colors.backgroundBase,
drawer: Drawer(
width: 428,
- backgroundColor: componentColors.backgroundBase,
+ backgroundColor: colors.backgroundBase,
child: _settingsPage,
),
drawerEnableOpenDragGesture: false,
@@ -654,11 +637,9 @@ class _HomePageState extends UploaderPageState<HomePage>
},
appBar: CustomLockerAppBar(
scaffoldKey: scaffoldKey,
- isSearchActive: isSearchActive,
isSyncing: _isSyncing,
searchController: searchController,
- searchFocusNode: _searchFocusNode,
- onSearchFocused: _handleSearchFocused,
+ searchFocusNode: searchFocusNode,
onClearSearch: _handleClearSearch,
onSearchChanged: _handleSearchChange,
),
@@ -703,11 +684,11 @@ class _HomePageState extends UploaderPageState<HomePage>
tooltip: 'Add item',
onPressed: _openSavePage,
shape: const CircleBorder(),
- backgroundColor: colorScheme.primary700,
+ backgroundColor: colors.primary,
elevation: 0,
- child: const HugeIcon(
+ child: HugeIcon(
icon: HugeIcons.strokeRoundedPlusSign,
- color: Colors.white,
+ color: colors.specialWhite,
),
);
},
@@ -774,7 +755,7 @@ class _HomePageState extends UploaderPageState<HomePage>
padding: EdgeInsets.only(
left: 16.0,
right: 16.0,
- top: 32.0,
+ top: 16.0,
bottom: scrollBottomPadding,
),
child: Column(
diff --git a/mobile/apps/locker/lib/ui/viewer/date/date_time_picker.dart b/mobile/apps/locker/lib/ui/viewer/date/date_time_picker.dart
index b61fe38082..21c34a6e2a 100644
--- a/mobile/apps/locker/lib/ui/viewer/date/date_time_picker.dart
+++ b/mobile/apps/locker/lib/ui/viewer/date/date_time_picker.dart
@@ -1,5 +1,4 @@
import "package:ente_components/ente_components.dart";
-import "package:ente_ui/theme/ente_theme.dart";
import "package:flutter/cupertino.dart";
import "package:locker/l10n/l10n.dart";
@@ -10,12 +9,12 @@ Future<DateTime?> showDatePickerSheet(
DateTime? minDate,
bool startWithTime = false,
}) {
- final colorScheme = getEnteColorScheme(context);
+ final colors = context.componentColors;
return showBottomSheetComponent<DateTime?>(
context: context,
builder: (sheetContext) => Container(
decoration: BoxDecoration(
- color: colorScheme.backgroundElevated,
+ color: colors.fillLight,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
@@ -78,9 +77,9 @@ class _DateTimePickerWidgetState extends State<DateTimePickerWidget> {
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
+ final colors = context.componentColors;
return Container(
- color: colorScheme.backgroundElevated,
+ color: colors.fillLight,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
@@ -93,7 +92,7 @@ class _DateTimePickerWidgetState extends State<DateTimePickerWidget> {
_showTimePicker
? context.l10n.selectTime
: context.l10n.selectDate,
- style: TextStyle(color: colorScheme.textBase, fontSize: 16),
+ style: TextStyle(color: colors.textBase, fontSize: 16),
),
),
),
@@ -102,7 +101,7 @@ class _DateTimePickerWidgetState extends State<DateTimePickerWidget> {
Container(
height: 220,
decoration: BoxDecoration(
- color: colorScheme.backgroundElevated2,
+ color: colors.fillLight,
borderRadius: BorderRadius.circular(12),
),
child: CupertinoTheme(
@@ -110,7 +109,7 @@ class _DateTimePickerWidgetState extends State<DateTimePickerWidget> {
brightness: Brightness.dark,
textTheme: CupertinoTextThemeData(
dateTimePickerTextStyle: TextStyle(
- color: colorScheme.textBase,
+ color: colors.textBase,
fontSize: 22,
),
),
@@ -175,7 +174,7 @@ class _DateTimePickerWidgetState extends State<DateTimePickerWidget> {
_showTimePicker
? context.l10n.previous
: context.l10n.cancel,
- style: TextStyle(color: colorScheme.textBase, fontSize: 14),
+ style: TextStyle(color: colors.textBase, fontSize: 14),
),
onPressed: () {
if (_showTimePicker) {
@@ -195,7 +194,7 @@ class _DateTimePickerWidgetState extends State<DateTimePickerWidget> {
child: Text(
_showTimePicker ? context.l10n.done : context.l10n.next,
style: TextStyle(
- color: colorScheme.primary700,
+ color: colors.primary,
fontSize: 14,
fontWeight: FontWeight.bold,
),
diff --git a/mobile/apps/locker/lib/utils/file_icon_utils.dart b/mobile/apps/locker/lib/utils/file_icon_utils.dart
index dee78b91d4..3155e97be2 100644
--- a/mobile/apps/locker/lib/utils/file_icon_utils.dart
+++ b/mobile/apps/locker/lib/utils/file_icon_utils.dart
@@ -1,17 +1,18 @@
+import 'package:ente_components/ente_components.dart';
import 'package:flutter/material.dart';
import 'package:hugeicons/hugeicons.dart';
+enum FileIconColorRole { warning, green, primary, neutral }
+
class FileIconConfig {
final dynamic icon;
- final Color color;
- final Color backgroundColor;
final Set<String> extensions;
+ final FileIconColorRole colorRole;
const FileIconConfig({
required this.icon,
- required this.color,
- required this.backgroundColor,
required this.extensions,
+ required this.colorRole,
});
}
@@ -21,34 +22,29 @@ class FileIconUtils {
'pdf': FileIconConfig(
extensions: {'.pdf'},
icon: HugeIcons.strokeRoundedFile01,
- color: Color.fromRGBO(246, 58, 58, 1),
- backgroundColor: Color.fromRGBO(255, 58, 58, 0.06),
+ colorRole: FileIconColorRole.warning,
),
'image': FileIconConfig(
extensions: {'.jpg', '.png', '.heic'},
icon: HugeIcons.strokeRoundedImage01,
- color: Color.fromRGBO(8, 194, 37, 1),
- backgroundColor: Color.fromRGBO(8, 194, 37, 0.06),
+ colorRole: FileIconColorRole.green,
),
'presentation': FileIconConfig(
extensions: {'.pptx'},
icon: HugeIcons.strokeRoundedPresentation01,
- color: Color.fromRGBO(16, 113, 255, 1),
- backgroundColor: Color.fromRGBO(16, 113, 255, 0.06),
+ colorRole: FileIconColorRole.primary,
),
'spreadsheet': FileIconConfig(
extensions: {'.xlsx'},
icon: HugeIcons.strokeRoundedTable01,
- color: Color(0xFF388E3C),
- backgroundColor: Color(0xFFE8F5E9),
+ colorRole: FileIconColorRole.green,
),
};
static const FileIconConfig _defaultConfig = FileIconConfig(
extensions: {},
icon: HugeIcons.strokeRoundedFile02,
- color: Color(0xFF757575),
- backgroundColor: Color(0xFFFAFAFA),
+ colorRole: FileIconColorRole.neutral,
);
static FileIconConfig _getFileConfig(String fileName) {
@@ -71,13 +67,21 @@ class FileIconUtils {
}
static Widget getFileIcon(
+ BuildContext context,
String fileName, {
bool showBackground = true,
double size = 24,
+ Color? backgroundColor,
}) {
+ final colors = context.componentColors;
final config = _getFileConfig(fileName);
+ final foregroundColor = _foregroundColor(config.colorRole, colors);
- final icon = HugeIcon(icon: config.icon, color: config.color, size: size);
+ final icon = HugeIcon(
+ icon: config.icon,
+ color: foregroundColor,
+ size: size,
+ );
if (!showBackground) {
return icon;
@@ -85,18 +89,45 @@ class FileIconUtils {
return Container(
decoration: BoxDecoration(
- color: config.backgroundColor,
+ color: backgroundColor ?? _backgroundColor(config.colorRole, colors),
borderRadius: BorderRadius.circular(12),
),
child: Padding(padding: const EdgeInsets.all(8.0), child: icon),
);
}
- Color getFileIconColor(String fileName) {
- return _getFileConfig(fileName).color;
+ static Color getFileIconColor(BuildContext context, String fileName) {
+ return _foregroundColor(
+ _getFileConfig(fileName).colorRole,
+ context.componentColors,
+ );
+ }
+
+ static Color getFileIconBackgroundColor(
+ BuildContext context,
+ String fileName,
+ ) {
+ return _backgroundColor(
+ _getFileConfig(fileName).colorRole,
+ context.componentColors,
+ );
+ }
+
+ static Color _foregroundColor(FileIconColorRole role, ColorTokens colors) {
+ return switch (role) {
+ FileIconColorRole.warning => colors.warning,
+ FileIconColorRole.green => colors.green,
+ FileIconColorRole.primary => colors.primary,
+ FileIconColorRole.neutral => colors.textLight,
+ };
}
- Color getFileIconBackgroundColor(String fileName) {
- return _getFileConfig(fileName).backgroundColor;
+ static Color _backgroundColor(FileIconColorRole role, ColorTokens colors) {
+ return switch (role) {
+ FileIconColorRole.warning => colors.warningLight,
+ FileIconColorRole.green => colors.greenLight,
+ FileIconColorRole.primary => colors.primaryLight,
+ FileIconColorRole.neutral => colors.fillLight,
+ };
}
}
diff --git a/mobile/apps/locker/lib/utils/info_item_utils.dart b/mobile/apps/locker/lib/utils/info_item_utils.dart
index 86ea92b6bb..71800c4e71 100644
--- a/mobile/apps/locker/lib/utils/info_item_utils.dart
+++ b/mobile/apps/locker/lib/utils/info_item_utils.dart
@@ -1,17 +1,15 @@
+import 'package:ente_components/ente_components.dart';
import 'package:flutter/material.dart';
import 'package:hugeicons/hugeicons.dart';
import 'package:locker/models/info/info_item.dart';
+enum InfoIconColorRole { caution, purple, primary, warning }
+
class InfoIconConfig {
final dynamic icon;
- final Color color;
- final Color backgroundColor;
+ final InfoIconColorRole colorRole;
- const InfoIconConfig({
- required this.icon,
- required this.color,
- required this.backgroundColor,
- });
+ const InfoIconConfig({required this.icon, required this.colorRole});
}
class InfoItemUtils {
@@ -19,23 +17,19 @@ class InfoItemUtils {
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),
+ colorRole: InfoIconColorRole.caution,
),
InfoType.physicalRecord: InfoIconConfig(
icon: HugeIcons.strokeRoundedBriefcase01,
- color: Color.fromRGBO(156, 39, 176, 1),
- backgroundColor: Color.fromRGBO(156, 39, 176, 0.06),
+ colorRole: InfoIconColorRole.purple,
),
InfoType.accountCredential: InfoIconConfig(
icon: HugeIcons.strokeRoundedLockPassword,
- color: Color.fromRGBO(16, 113, 255, 1),
- backgroundColor: Color.fromRGBO(16, 113, 255, 0.06),
+ colorRole: InfoIconColorRole.primary,
),
InfoType.emergencyContact: InfoIconConfig(
icon: HugeIcons.strokeRoundedContactBook,
- color: Color.fromRGBO(244, 67, 54, 1),
- backgroundColor: Color.fromRGBO(244, 67, 54, 0.06),
+ colorRole: InfoIconColorRole.warning,
),
};
@@ -44,13 +38,21 @@ class InfoItemUtils {
}
static Widget getInfoIcon(
+ BuildContext context,
InfoType type, {
bool showBackground = true,
double size = 24,
+ Color? backgroundColor,
}) {
+ final colors = context.componentColors;
final config = _getInfoConfig(type);
+ final foregroundColor = _foregroundColor(config.colorRole, colors);
- final icon = HugeIcon(icon: config.icon, color: config.color, size: size);
+ final icon = HugeIcon(
+ icon: config.icon,
+ color: foregroundColor,
+ size: size,
+ );
if (!showBackground) {
return icon;
@@ -58,10 +60,28 @@ class InfoItemUtils {
return Container(
decoration: BoxDecoration(
- color: config.backgroundColor,
+ color: backgroundColor ?? _backgroundColor(config.colorRole, colors),
borderRadius: BorderRadius.circular(12),
),
child: Padding(padding: const EdgeInsets.all(8.0), child: icon),
);
}
+
+ static Color _foregroundColor(InfoIconColorRole role, ColorTokens colors) {
+ return switch (role) {
+ InfoIconColorRole.caution => colors.caution,
+ InfoIconColorRole.purple => colors.purple,
+ InfoIconColorRole.primary => colors.primary,
+ InfoIconColorRole.warning => colors.warning,
+ };
+ }
+
+ static Color _backgroundColor(InfoIconColorRole role, ColorTokens colors) {
+ return switch (role) {
+ InfoIconColorRole.caution => colors.cautionLight,
+ InfoIconColorRole.purple => colors.purpleLight,
+ InfoIconColorRole.primary => colors.primaryLight,
+ InfoIconColorRole.warning => colors.warningLight,
+ };
+ }
}