Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][locker] Migrate file selection surfaces to component theme

aman-pilotb32fade57780
diff --git a/mobile/apps/locker/lib/ui/components/file_list_widget.dart b/mobile/apps/locker/lib/ui/components/file_list_widget.dart
index 91bbb54ff9..d70959a03e 100644
--- a/mobile/apps/locker/lib/ui/components/file_list_widget.dart
+++ b/mobile/apps/locker/lib/ui/components/file_list_widget.dart
@@ -1,6 +1,6 @@
+import "package:ente_components/ente_components.dart";
import "package:ente_sharing/models/user.dart";
import "package:ente_sharing/user_avator_widget.dart";
-import "package:ente_ui/theme/ente_theme.dart";
import "package:flutter/material.dart";
import "package:flutter_svg/flutter_svg.dart";
import "package:hugeicons/hugeicons.dart";
@@ -31,7 +31,7 @@ class FileListWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
+ final colors = context.componentColors;
final collection = file.collectionID != null
? CollectionService.instance.getFromCache(file.collectionID!)
@@ -62,7 +62,7 @@ class FileListWidget extends StatelessWidget {
child: Stack(
clipBehavior: Clip.none,
children: [
- _buildFileIcon(),
+ _buildFileIcon(context, backgroundColor: colors.backgroundBase),
if (showSharingIndicator)
Positioned(
right: -4,
@@ -70,7 +70,7 @@ class FileListWidget extends StatelessWidget {
child: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
- color: colorScheme.backdropBase,
+ color: colors.fillLight,
),
padding: const EdgeInsets.all(1.0),
child: HugeIcon(
@@ -78,7 +78,7 @@ class FileListWidget extends StatelessWidget {
? HugeIcons.strokeRoundedCircleArrowUpRight
: HugeIcons.strokeRoundedCircleArrowDownLeft,
strokeWidth: 2.0,
- color: colorScheme.primary700,
+ color: colors.primary,
size: 16.0,
),
),
@@ -94,6 +94,7 @@ class FileListWidget extends StatelessWidget {
children: [
Text(
file.displayName,
+ style: TextStyles.body,
overflow: TextOverflow.ellipsis,
maxLines: 1,
),
@@ -128,12 +129,10 @@ class FileListWidget extends StatelessWidget {
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
border: Border.all(
- color: isSelected
- ? colorScheme.primary700
- : colorScheme.backdropBase,
+ color: isSelected ? colors.strokeDark : colors.fillLight,
width: 1.5,
),
- color: colorScheme.backdropBase,
+ color: colors.fillLight,
borderRadius: const BorderRadius.all(Radius.circular(20)),
),
child: Row(
@@ -154,9 +153,7 @@ class FileListWidget extends StatelessWidget {
);
},
child: _buildTrailingIndicator(
- color: isSelected
- ? colorScheme.primary700
- : colorScheme.textMuted,
+ color: isSelected ? colors.primary : colors.textLight,
isSelected: isSelected,
isIncoming: isIncoming,
isMarkedOffline: !isTrashFile && isMarkedOffline,
@@ -172,19 +169,31 @@ class FileListWidget extends StatelessWidget {
);
}
- Widget _buildFileIcon() {
+ Widget _buildFileIcon(
+ BuildContext context, {
+ required Color backgroundColor,
+ }) {
if (InfoFileService.instance.isInfoFile(file)) {
try {
final infoItem = InfoFileService.instance.extractInfoFromFile(file);
if (infoItem != null) {
- return InfoItemUtils.getInfoIcon(infoItem.type);
+ return InfoItemUtils.getInfoIcon(
+ context,
+ infoItem.type,
+ backgroundColor: backgroundColor,
+ );
}
} catch (e) {
// Fallback to default icon if extraction fails
}
}
- return FileIconUtils.getFileIcon(file.displayName, showBackground: true);
+ return FileIconUtils.getFileIcon(
+ context,
+ file.displayName,
+ showBackground: true,
+ backgroundColor: backgroundColor,
+ );
}
Widget _buildOwnerAvatar(User owner) {
@@ -210,11 +219,18 @@ class FileListWidget extends StatelessWidget {
required User? owner,
}) {
if (isSelected) {
- return Icon(
+ return Container(
key: const ValueKey("selected"),
- Icons.check_circle_rounded,
- color: color,
- size: 24,
+ width: 18,
+ height: 18,
+ alignment: Alignment.center,
+ decoration: BoxDecoration(color: color, shape: BoxShape.circle),
+ child: const HugeIcon(
+ icon: HugeIcons.strokeRoundedTick02,
+ color: Colors.white,
+ size: 12,
+ strokeWidth: 2,
+ ),
);
}
diff --git a/mobile/apps/locker/lib/ui/viewer/actions/collection_selection_overlay_bar.dart b/mobile/apps/locker/lib/ui/viewer/actions/collection_selection_overlay_bar.dart
index d42eb0fc21..bfec844369 100644
--- a/mobile/apps/locker/lib/ui/viewer/actions/collection_selection_overlay_bar.dart
+++ b/mobile/apps/locker/lib/ui/viewer/actions/collection_selection_overlay_bar.dart
@@ -1,4 +1,4 @@
-import "package:ente_ui/theme/ente_theme.dart";
+import 'package:ente_components/ente_components.dart';
import "package:ente_ui/utils/dialog_util.dart";
import "package:ente_ui/utils/toast_util.dart";
import "package:flutter/material.dart";
@@ -73,8 +73,7 @@ class _CollectionSelectionOverlayBarState
@override
Widget build(BuildContext context) {
final bottomPadding = MediaQuery.of(context).padding.bottom;
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
+ final colors = context.componentColors;
final hasSelection = widget.selectedCollections.collections.isNotEmpty;
return IgnorePointer(
@@ -92,13 +91,13 @@ class _CollectionSelectionOverlayBarState
child: hasSelection
? Container(
decoration: BoxDecoration(
- color: colorScheme.backdropBase.withValues(alpha: 1.0),
+ color: colors.backgroundBase,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
),
border: Border(
- top: BorderSide(color: colorScheme.strokeFaint),
+ top: BorderSide(color: colors.strokeFaint),
),
),
child: Padding(
@@ -133,7 +132,7 @@ class _CollectionSelectionOverlayBarState
},
child: Container(
decoration: BoxDecoration(
- color: colorScheme.backgroundElevated2,
+ color: colors.fillLight,
borderRadius: BorderRadius.circular(50),
),
padding: const EdgeInsets.symmetric(
@@ -145,12 +144,12 @@ class _CollectionSelectionOverlayBarState
children: [
Text(
buttonText,
- style: textTheme.small,
+ style: TextStyles.body,
),
const SizedBox(width: 6),
Icon(
iconData,
- color: colorScheme.textBase,
+ color: colors.textBase,
size: 20,
),
],
@@ -175,7 +174,7 @@ class _CollectionSelectionOverlayBarState
},
child: Container(
decoration: BoxDecoration(
- color: colorScheme.backgroundElevated2,
+ color: colors.fillLight,
borderRadius: BorderRadius.circular(50),
),
padding: const EdgeInsets.symmetric(
@@ -187,12 +186,12 @@ class _CollectionSelectionOverlayBarState
children: [
Text(
countText,
- style: textTheme.small,
+ style: TextStyles.body,
),
const SizedBox(width: 6),
Icon(
Icons.close,
- color: colorScheme.textBase,
+ color: colors.textBase,
size: 20,
),
],
@@ -217,7 +216,7 @@ class _CollectionSelectionOverlayBarState
}
Widget _buildPrimaryActionButtons() {
- final colorScheme = getEnteColorScheme(context);
+ final colors = context.componentColors;
final selectedCollections = widget.selectedCollections.collections;
if (selectedCollections.isEmpty) {
return const SizedBox.shrink();
@@ -253,7 +252,7 @@ class _CollectionSelectionOverlayBarState
SelectionActionButton(
hugeIcon: HugeIcon(
icon: HugeIcons.strokeRoundedLogout02,
- color: colorScheme.warning500,
+ color: colors.warning,
),
label: context.l10n.leaveCollection,
onTap: () => _leaveCollections(sharedIncomingCollections),
@@ -263,7 +262,7 @@ class _CollectionSelectionOverlayBarState
SelectionActionButton(
hugeIcon: HugeIcon(
icon: HugeIcons.strokeRoundedDelete02,
- color: colorScheme.warning500,
+ color: colors.warning,
),
label: context.l10n.delete,
onTap: () {
@@ -279,7 +278,7 @@ class _CollectionSelectionOverlayBarState
return Container(
decoration: BoxDecoration(
- color: colorScheme.backgroundElevated2,
+ color: colors.fillLight,
borderRadius: BorderRadius.circular(24),
),
child: Row(children: _buildActionRow(primaryActions)),
diff --git a/mobile/apps/locker/lib/ui/viewer/actions/file_selection_overlay_bar.dart b/mobile/apps/locker/lib/ui/viewer/actions/file_selection_overlay_bar.dart
index 6dc7c764e5..9ba91b7aa7 100644
--- a/mobile/apps/locker/lib/ui/viewer/actions/file_selection_overlay_bar.dart
+++ b/mobile/apps/locker/lib/ui/viewer/actions/file_selection_overlay_bar.dart
@@ -1,8 +1,7 @@
+import 'package:ente_components/ente_components.dart';
import "package:ente_events/event_bus.dart";
import "package:ente_icons/ente_icons.dart";
import "package:ente_ui/components/buttons/button_widget.dart";
-import "package:ente_ui/theme/colors.dart";
-import "package:ente_ui/theme/ente_theme.dart";
import "package:ente_ui/utils/dialog_util.dart";
import "package:ente_ui/utils/toast_util.dart";
import "package:flutter/material.dart";
@@ -131,8 +130,7 @@ class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {
@override
Widget build(BuildContext context) {
final bottomPadding = MediaQuery.of(context).padding.bottom;
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
+ final colors = context.componentColors;
return IgnorePointer(
ignoring: !hasSelection,
@@ -160,13 +158,13 @@ class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {
},
child: Container(
decoration: BoxDecoration(
- color: colorScheme.backdropBase.withValues(alpha: 1.0),
+ color: colors.backgroundBase,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
),
border: Border(
- top: BorderSide(color: colorScheme.strokeFaint),
+ top: BorderSide(color: colors.strokeFaint),
),
),
child: Padding(
@@ -205,8 +203,7 @@ class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {
},
child: Container(
decoration: BoxDecoration(
- color:
- colorScheme.backgroundElevated2,
+ color: colors.fillLight,
borderRadius: BorderRadius.circular(
50,
),
@@ -220,12 +217,12 @@ class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {
children: [
Text(
buttonText,
- style: textTheme.small,
+ style: TextStyles.body,
),
const SizedBox(width: 6),
Icon(
iconData,
- color: colorScheme.textBase,
+ color: colors.textBase,
size: 20,
),
],
@@ -248,8 +245,7 @@ class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {
},
child: Container(
decoration: BoxDecoration(
- color:
- colorScheme.backgroundElevated2,
+ color: colors.fillLight,
borderRadius: BorderRadius.circular(
50,
),
@@ -263,12 +259,12 @@ class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {
children: [
Text(
countText,
- style: textTheme.small,
+ style: TextStyles.body,
),
const SizedBox(width: 6),
Icon(
Icons.close,
- color: colorScheme.textBase,
+ color: colors.textBase,
semanticLabel: "close",
size: 20,
),
@@ -332,10 +328,10 @@ class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {
Widget _buildPrimaryActionRow(Set<EnteFile> selectedFiles) {
final files = selectedFiles.toList();
- final colorScheme = getEnteColorScheme(context);
+ final colors = context.componentColors;
if (widget.isTrashMode) {
- return _buildTrashActionRow(files, colorScheme);
+ return _buildTrashActionRow(files, colors);
}
final isSingleSelection = selectedFiles.length == 1;
@@ -370,10 +366,7 @@ class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {
: "assets/svg/keep_offline.svg",
width: 22,
height: 22,
- colorFilter: ColorFilter.mode(
- colorScheme.textBase,
- BlendMode.srcIn,
- ),
+ colorFilter: ColorFilter.mode(colors.textBase, BlendMode.srcIn),
),
label: shouldRemoveOffline
? context.l10n.cloudOnly
@@ -395,7 +388,7 @@ class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {
? null
: HugeIcon(
icon: HugeIcons.strokeRoundedStar,
- color: colorScheme.textBase,
+ color: colors.textBase,
),
label: isImportant
? context.l10n.unimportant
@@ -412,7 +405,7 @@ class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {
SelectionActionButton(
hugeIcon: HugeIcon(
icon: HugeIcons.strokeRoundedDelete02,
- color: colorScheme.warning500,
+ color: colors.warning,
),
label: context.l10n.delete,
onTap: () => isSingleSelection
@@ -426,13 +419,10 @@ class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {
return Row(children: _buildActionRow(actions));
}
- Widget _buildTrashActionRow(
- List<EnteFile> files,
- EnteColorScheme colorScheme,
- ) {
+ Widget _buildTrashActionRow(List<EnteFile> files, ColorTokens colors) {
return Container(
decoration: BoxDecoration(
- color: colorScheme.backgroundElevated2,
+ color: colors.fillLight,
borderRadius: BorderRadius.circular(24),
),
child: Row(
@@ -445,7 +435,7 @@ class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {
SelectionActionButton(
hugeIcon: HugeIcon(
icon: HugeIcons.strokeRoundedDelete02,
- color: colorScheme.warning500,
+ color: colors.warning,
),
label: context.l10n.delete,
onTap: () => _deleteFromTrash(context, files),
@@ -463,11 +453,11 @@ class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {
return const SizedBox.shrink();
}
- final colorScheme = getEnteColorScheme(context);
+ final colors = context.componentColors;
return Container(
decoration: BoxDecoration(
- color: colorScheme.backgroundElevated2,
+ color: colors.fillLight,
borderRadius: BorderRadius.circular(24),
),
child: Row(children: _buildActionRow(actions, spacing: 0)),