Skip to content

armgit / ente

Public Imported from GitHub
0

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

Refactor album list and row item components for improved readability and consistency

AmanRajSinghMourya0149c2529e30
diff --git a/mobile/apps/photos/lib/ui/collections/album/list_item.dart b/mobile/apps/photos/lib/ui/collections/album/list_item.dart
index e9274fadea..1ef155b000 100644
--- a/mobile/apps/photos/lib/ui/collections/album/list_item.dart
+++ b/mobile/apps/photos/lib/ui/collections/album/list_item.dart
@@ -1,3 +1,4 @@
+import "package:ente_components/ente_components.dart";
import "package:ente_icons/ente_icons.dart";
import "package:flutter/material.dart";
import "package:hugeicons/hugeicons.dart";
@@ -8,7 +9,7 @@ import "package:photos/models/collection/collection.dart";
import "package:photos/models/file/file.dart";
import "package:photos/models/selected_albums.dart";
import "package:photos/services/collections_service.dart";
-import "package:photos/theme/ente_theme.dart";
+import "package:photos/ui/components/collection_share_badge.dart";
import "package:photos/ui/components/thumbnail_list_item.dart";
import "package:photos/ui/sharing/album_share_info_widget.dart";
import "package:photos/ui/sharing/user_avator_widget.dart";
@@ -54,8 +55,6 @@ class AlbumListItemWidget extends StatelessWidget {
BuildContext context, {
required bool isSelected,
}) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
final bool isOwner = collection.isOwner(
Configuration.instance.getUserID() ?? -1,
);
@@ -69,10 +68,11 @@ class AlbumListItemWidget extends StatelessWidget {
final bool showArchive = isOwner
? collection.isArchived()
: collection.hasShareeArchived();
- final bool hasAnyStatus = isFavoriteAlbum || showPin || showArchive;
+ final colors = context.componentColors;
return ThumbnailListItem(
backgroundColor: thumbnailListItemBackgroundColor(context),
+ selectedBorderColor: colors.primaryStroke,
isSelected: isSelected,
onTap: onTapCallback == null ? null : () => onTapCallback!(collection),
onLongPress: onLongPressCallback == null
@@ -85,7 +85,7 @@ class AlbumListItemWidget extends StatelessWidget {
),
title: Text(
collection.displayName,
- style: textTheme.body,
+ style: TextStyles.body.copyWith(color: colors.textBase),
overflow: TextOverflow.ellipsis,
),
subtitle: FutureBuilder<int>(
@@ -102,39 +102,12 @@ class AlbumListItemWidget extends StatelessWidget {
snapshot.error,
);
}
- return Row(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Flexible(
- child: Text(
- countText,
- style: textTheme.smallMuted,
- overflow: TextOverflow.ellipsis,
- ),
- ),
- if (hasAnyStatus) ...[
- Text(" \u2022 ", style: textTheme.smallMuted),
- if (showPin)
- HugeIcon(
- icon: HugeIcons.strokeRoundedPin,
- size: 12,
- color: colorScheme.textMuted,
- strokeWidth: 2.0,
- ),
- if (showArchive)
- Icon(
- Icons.archive_outlined,
- size: 12,
- color: colorScheme.textMuted,
- ),
- if (isFavoriteAlbum)
- Icon(
- EnteIcons.favoriteFilled,
- size: 12,
- color: colorScheme.greenBase,
- ),
- ],
- ],
+ return _buildSubtitle(
+ context,
+ text: countText,
+ showPin: showPin,
+ showArchive: showArchive,
+ isFavoriteAlbum: isFavoriteAlbum,
);
},
),
@@ -167,6 +140,54 @@ class AlbumListItemWidget extends StatelessWidget {
);
}
+ Widget _buildSubtitle(
+ BuildContext context, {
+ required String text,
+ required bool showPin,
+ required bool showArchive,
+ required bool isFavoriteAlbum,
+ }) {
+ final colors = context.componentColors;
+ final textStyle = TextStyles.mini.copyWith(color: colors.textLight);
+ final hasStatus = showPin || showArchive || isFavoriteAlbum;
+
+ return Row(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ Flexible(
+ child: Text(
+ text,
+ style: textStyle,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ if (hasStatus) ...[
+ Text(" \u2022 ", style: textStyle),
+ if (showPin)
+ HugeIcon(
+ icon: HugeIcons.strokeRoundedPin,
+ size: 12,
+ color: colors.textLight,
+ strokeWidth: 2.0,
+ ),
+ if (showArchive)
+ HugeIcon(
+ icon: HugeIcons.strokeRoundedArchive03,
+ size: 12,
+ color: colors.textLight,
+ strokeWidth: 2.0,
+ ),
+ if (isFavoriteAlbum)
+ Icon(
+ EnteIcons.favoriteFilled,
+ size: 12,
+ color: colors.primary,
+ ),
+ ],
+ ],
+ );
+ }
+
Widget _buildTrailingIndicator(
BuildContext context, {
required bool isSelected,
@@ -176,7 +197,7 @@ class AlbumListItemWidget extends StatelessWidget {
final double slotOverlap = getOverlapPadding(AvatarType.medium);
if (isSelected) {
- return const _CollectionSelectedBadge(
+ return const CollectionSelectedBadge(
key: ValueKey("selected"),
);
}
@@ -255,62 +276,9 @@ class _AlbumListItemCover extends StatelessWidget {
Positioned(
right: -4,
bottom: -4,
- child: _CollectionShareBadge(isOutgoing: isOutgoing),
+ child: CollectionShareBadge(isOutgoing: isOutgoing),
),
],
);
}
}
-
-class _CollectionShareBadge extends StatelessWidget {
- final bool isOutgoing;
-
- const _CollectionShareBadge({
- required this.isOutgoing,
- });
-
- @override
- Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- return Container(
- width: 20,
- height: 20,
- decoration: BoxDecoration(
- color: colorScheme.backgroundElevated,
- shape: BoxShape.circle,
- border: Border.all(color: colorScheme.strokeFainter),
- ),
- child: Center(
- child: Icon(
- isOutgoing
- ? Icons.person_add_alt_1_outlined
- : Icons.person_outline_rounded,
- size: 12,
- color: colorScheme.textMuted,
- ),
- ),
- );
- }
-}
-
-class _CollectionSelectedBadge extends StatelessWidget {
- const _CollectionSelectedBadge({super.key});
-
- @override
- Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- return Container(
- width: getAvatarSize(AvatarType.medium),
- height: getAvatarSize(AvatarType.medium),
- decoration: BoxDecoration(
- color: colorScheme.greenBase,
- shape: BoxShape.circle,
- ),
- child: const Icon(
- Icons.check_rounded,
- size: 16,
- color: Colors.white,
- ),
- );
- }
-}
diff --git a/mobile/apps/photos/lib/ui/collections/album/new_list_item.dart b/mobile/apps/photos/lib/ui/collections/album/new_list_item.dart
index 995f194d63..564df31297 100644
--- a/mobile/apps/photos/lib/ui/collections/album/new_list_item.dart
+++ b/mobile/apps/photos/lib/ui/collections/album/new_list_item.dart
@@ -1,6 +1,8 @@
+import "dart:async";
+
+import 'package:ente_components/ente_components.dart';
import 'package:flutter/material.dart';
import "package:photos/generated/l10n.dart";
-import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/components/thumbnail_list_item.dart";
class NewAlbumListItemWidget extends StatelessWidget {
@@ -13,27 +15,33 @@ class NewAlbumListItemWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
- final textTheme = getEnteTextTheme(context);
- final colorScheme = getEnteColorScheme(context);
+ final colors = context.componentColors;
return ThumbnailListItem(
backgroundColor: thumbnailListItemBackgroundColor(context),
+ onTap: onTap == null ? null : () => unawaited(onTap!(context)),
leading: ClipRRect(
borderRadius: BorderRadius.circular(
ThumbnailListItem.defaultLeadingRadius,
),
child: Container(
- color: Theme.of(context).brightness == Brightness.light
- ? colorScheme.backdropBase
- : colorScheme.backdropFaint,
- child: Icon(
- Icons.add_outlined,
- color: colorScheme.strokeMuted,
+ decoration: BoxDecoration(
+ border: Border.all(color: colors.strokeDark),
+ borderRadius: BorderRadius.circular(
+ ThumbnailListItem.defaultLeadingRadius,
+ ),
+ ),
+ child: Center(
+ child: Image.asset(
+ "assets/new_album_icon.png",
+ width: 20,
+ height: 20,
+ ),
),
),
),
title: Text(
- AppLocalizations.of(context).newAlbum,
- style: textTheme.body.copyWith(color: colorScheme.textMuted),
+ AppLocalizations.of(context).addNew,
+ style: TextStyles.body.copyWith(color: colors.textLight),
),
);
}
diff --git a/mobile/apps/photos/lib/ui/collections/album/new_row_item.dart b/mobile/apps/photos/lib/ui/collections/album/new_row_item.dart
index 29e382a651..3853a47fb1 100644
--- a/mobile/apps/photos/lib/ui/collections/album/new_row_item.dart
+++ b/mobile/apps/photos/lib/ui/collections/album/new_row_item.dart
@@ -1,3 +1,4 @@
+import "package:ente_components/ente_components.dart";
import "package:ente_pure_utils/ente_pure_utils.dart";
import 'package:flutter/material.dart';
import "package:logging/logging.dart";
@@ -5,12 +6,12 @@ import "package:photos/generated/l10n.dart";
import 'package:photos/models/collection/collection.dart';
import 'package:photos/models/collection/collection_items.dart';
import "package:photos/services/collections_service.dart";
-import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/viewer/gallery/collection_page.dart";
import "package:photos/utils/dialog_util.dart";
class NewAlbumRowItemWidget extends StatelessWidget {
static const _cornerRadius = 20.0;
+ static const _thumbnailToTextSpacing = 8.0;
final double height;
final double width;
@@ -23,7 +24,7 @@ class NewAlbumRowItemWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
+ final colors = context.componentColors;
return GestureDetector(
onTap: () async {
final result = await showTextInputDialog(
@@ -42,8 +43,8 @@ class NewAlbumRowItemWidget extends StatelessWidget {
}
try {
- final Collection c =
- await CollectionsService.instance.createAlbum(text);
+ final Collection c = await CollectionsService.instance
+ .createAlbum(text);
// Close the dialog now so that it does not flash when leaving the album again.
Navigator.of(context).pop();
@@ -54,8 +55,9 @@ class NewAlbumRowItemWidget extends StatelessWidget {
CollectionPage(CollectionWithThumbnail(c, null)),
);
} catch (e, s) {
- Logger("CreateNewAlbumRowItemWidget")
- .severe("Failed to rename album", e, s);
+ Logger(
+ "CreateNewAlbumRowItemWidget",
+ ).severe("Failed to rename album", e, s);
rethrow;
}
},
@@ -73,7 +75,7 @@ class NewAlbumRowItemWidget extends StatelessWidget {
child: Container(
height: height,
width: width,
- color: colorScheme.fill,
+ color: colors.fillLight,
child: Center(
child: Image.asset(
"assets/new_album_icon.png",
@@ -83,10 +85,12 @@ class NewAlbumRowItemWidget extends StatelessWidget {
),
),
),
- const SizedBox(height: 6),
+ const SizedBox(height: _thumbnailToTextSpacing),
Text(
AppLocalizations.of(context).addNew,
- style: getEnteTextTheme(context).smallFaint,
+ style: TextStyles.mini.copyWith(
+ color: colors.textLight,
+ ),
),
],
),
diff --git a/mobile/apps/photos/lib/ui/collections/album/row_item.dart b/mobile/apps/photos/lib/ui/collections/album/row_item.dart
index 36027ceea8..34a10eb3a4 100644
--- a/mobile/apps/photos/lib/ui/collections/album/row_item.dart
+++ b/mobile/apps/photos/lib/ui/collections/album/row_item.dart
@@ -1,5 +1,6 @@
import "dart:math";
+import "package:ente_components/ente_components.dart";
import 'package:ente_pure_utils/ente_pure_utils.dart';
import "package:figma_squircle/figma_squircle.dart";
import 'package:flutter/material.dart';
@@ -12,8 +13,6 @@ import 'package:photos/models/collection/collection_items.dart';
import 'package:photos/models/file/file.dart';
import "package:photos/models/selected_albums.dart";
import "package:photos/services/collections_service.dart";
-import "package:photos/theme/colors.dart";
-import 'package:photos/theme/ente_theme.dart';
import "package:photos/ui/components/collection_share_badge.dart";
import "package:photos/ui/sharing/album_share_info_widget.dart";
import "package:photos/ui/sharing/more_count_badge.dart";
@@ -34,9 +33,9 @@ class AlbumRowItemWidget extends StatelessWidget {
static const _cornerRadius = 20.0;
static const _cornerSmoothing = 0.6;
static const _overlayPadding = 8.0;
- static const _sharePillTopOffset = -12.0;
- static const _sharePillLeftOffset = 0.0;
- static const _sharePillPadding = EdgeInsets.all(4);
+ static const _thumbnailToTextSpacing = 8.0;
+ static const _titleToSubtitleSpacing = 1.0;
+ static const _sharePillPadding = EdgeInsets.all(2);
static const _sharedAvatarStrokeWidth = 2.0;
const AlbumRowItemWidget(
@@ -54,20 +53,20 @@ class AlbumRowItemWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final bool isOwner = c.isOwner(Configuration.instance.getUserID()!);
- final String tagPrefix = (isOwner ? "collection" : "shared_collection") +
+ final String tagPrefix =
+ (isOwner ? "collection" : "shared_collection") +
tag +
"_" +
c.id.toString();
- final colorScheme = getEnteColorScheme(context);
- final enteTextTheme = getEnteTextTheme(context);
+ final componentColors = context.componentColors;
final Widget? linkIcon = c.hasLink && isOwner
? HugeIcon(
icon: HugeIcons.strokeRoundedLink02,
color: c.publicURLs.first.isExpired
- ? warning500
- : colorScheme.textBase,
+ ? componentColors.warning
+ : textBaseLight,
size: 10,
- strokeWidth: 1.5,
+ strokeWidth: 2,
)
: null;
@@ -101,8 +100,8 @@ class AlbumRowItemWidget extends StatelessWidget {
} else {
//Need to use cached thumbnail so that the hero
//animation works as expected.
- thumbnail =
- CollectionsService.instance.getCoverCache(c);
+ thumbnail = CollectionsService.instance
+ .getCoverCache(c);
}
if (thumbnail != null) {
final bool isSelected =
@@ -124,9 +123,10 @@ class AlbumRowItemWidget extends StatelessWidget {
if (isSelected)
Container(
decoration: BoxDecoration(
- color: Colors.black.withValues(
- alpha: 0.4,
- ),
+ color: componentColors.specialScrim
+ .withValues(
+ alpha: 0.4,
+ ),
),
),
],
@@ -134,7 +134,7 @@ class AlbumRowItemWidget extends StatelessWidget {
);
} else {
return Container(
- color: colorScheme.backdropBase,
+ color: componentColors.fillDark,
child: const NoThumbnailWidget(
borderRadius: _cornerRadius,
addBorder: false,
@@ -143,6 +143,29 @@ class AlbumRowItemWidget extends StatelessWidget {
}
},
),
+ if (isOwner && (c.hasSharees || c.hasLink))
+ Positioned(
+ top: _overlayPadding,
+ left: _overlayPadding,
+ child: Hero(
+ tag: tagPrefix + "_sharees",
+ transitionOnUserGestures: true,
+ child: Container(
+ padding: _sharePillPadding,
+ decoration: BoxDecoration(
+ color: fillLightLight,
+ borderRadius: BorderRadius.circular(40),
+ ),
+ child: SizedBox(
+ height: getAvatarSize(AvatarType.small),
+ child: _AlbumRowSharePillContent(
+ sharees: c.getSharees(),
+ trailingWidget: linkIcon,
+ ),
+ ),
+ ),
+ ),
+ ),
Positioned(
top: _overlayPadding,
right: _overlayPadding,
@@ -154,11 +177,12 @@ class AlbumRowItemWidget extends StatelessWidget {
child: ListenableBuilder(
listenable: selectedAlbums!,
builder: (context, _) {
- final bool isSelected =
- selectedAlbums!.isAlbumSelected(c);
+ final bool isSelected = selectedAlbums!
+ .isAlbumSelected(c);
return AnimatedSwitcher(
- duration:
- const Duration(milliseconds: 200),
+ duration: const Duration(
+ milliseconds: 200,
+ ),
switchInCurve: Curves.easeOut,
switchOutCurve: Curves.easeIn,
child: isSelected
@@ -177,7 +201,8 @@ class AlbumRowItemWidget extends StatelessWidget {
tag: tagPrefix + "_owner_other",
transitionOnUserGestures: true,
child: SizedBox.square(
- dimension: getAvatarSize(AvatarType.small) +
+ dimension:
+ getAvatarSize(AvatarType.small) +
_sharedAvatarStrokeWidth * 2,
child: Stack(
alignment: Alignment.center,
@@ -193,7 +218,8 @@ class AlbumRowItemWidget extends StatelessWidget {
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
- color: Colors.white,
+ color:
+ componentColors.specialWhite,
width: _sharedAvatarStrokeWidth,
),
),
@@ -214,33 +240,10 @@ class AlbumRowItemWidget extends StatelessWidget {
),
),
),
- if (isOwner && (c.hasSharees || c.hasLink))
- Positioned(
- top: _sharePillTopOffset,
- left: _sharePillLeftOffset,
- child: Hero(
- tag: tagPrefix + "_sharees",
- transitionOnUserGestures: true,
- child: Container(
- padding: _sharePillPadding,
- decoration: BoxDecoration(
- color: colorScheme.backgroundElevated,
- borderRadius: BorderRadius.circular(40),
- ),
- child: SizedBox(
- height: getAvatarSize(AvatarType.small),
- child: _AlbumRowSharePillContent(
- sharees: c.getSharees(),
- trailingWidget: linkIcon,
- ),
- ),
- ),
- ),
- ),
],
),
),
- const SizedBox(height: 6),
+ const SizedBox(height: _thumbnailToTextSpacing),
Hero(
tag: tagPrefix + "_title",
transitionOnUserGestures: true,
@@ -256,33 +259,39 @@ class AlbumRowItemWidget extends StatelessWidget {
} else {
//Need to use cached count so that the hero
//animation works as expected without flickering.
- cachedCount =
- CollectionsService.instance.getCachedFileCount(c);
+ cachedCount = CollectionsService.instance
+ .getCachedFileCount(c);
}
if (cachedCount != null && cachedCount > 0) {
- final String textCount =
- AppLocalizations.of(context).itemCount(
- count: cachedCount,
- );
+ final String textCount = AppLocalizations.of(context)
+ .itemCount(
+ count: cachedCount,
+ );
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
c.displayName,
- style: enteTextTheme.small,
+ style: TextStyles.mini.copyWith(
+ color: componentColors.textBase,
+ ),
overflow: TextOverflow.ellipsis,
),
- const SizedBox(height: 2),
+ const SizedBox(height: _titleToSubtitleSpacing),
Text(
textCount,
- style: enteTextTheme.miniMuted,
+ style: TextStyles.tiny.copyWith(
+ color: componentColors.textLight,
+ ),
),
],
);
} else {
return Text(
c.displayName,
- style: enteTextTheme.small,
+ style: TextStyles.mini.copyWith(
+ color: componentColors.textBase,
+ ),
overflow: TextOverflow.ellipsis,
);
}
@@ -290,7 +299,9 @@ class AlbumRowItemWidget extends StatelessWidget {
)
: Text(
c.displayName,
- style: enteTextTheme.small,
+ style: TextStyles.mini.copyWith(
+ color: componentColors.textBase,
+ ),
overflow: TextOverflow.ellipsis,
),
),
@@ -347,7 +358,6 @@ class AlbumRowItemWidget extends StatelessWidget {
}
class _AlbumRowSharePillContent extends StatelessWidget {
- static const _trailingGap = 2.0;
static const _limitCountTo = 2;
final List<User> sharees;
@@ -370,10 +380,7 @@ class _AlbumRowSharePillContent extends StatelessWidget {
final visibleAvatarsWidth = visibleAvatarCount == 0
? 0.0
: avatarSize + (visibleAvatarCount - 1) * overlapPadding;
- final trailingGap =
- visibleAvatarCount > 0 && trailingWidget != null ? _trailingGap : 0.0;
- final contentWidth =
- visibleAvatarsWidth + trailingGap + trailingWidgetWidth;
+ final contentWidth = visibleAvatarsWidth + trailingWidgetWidth;
final widgets = List<Widget>.generate(
displayCount,
@@ -403,7 +410,7 @@ class _AlbumRowSharePillContent extends StatelessWidget {
if (trailingWidget != null) {
widgets.add(
Positioned(
- left: visibleAvatarsWidth + trailingGap,
+ left: visibleAvatarsWidth,
child: SizedBox.square(
dimension: avatarSize,
child: Center(
diff --git a/mobile/apps/photos/lib/ui/collections/flex_grid_view.dart b/mobile/apps/photos/lib/ui/collections/flex_grid_view.dart
index 0d1f644e49..dc8cee5581 100644
--- a/mobile/apps/photos/lib/ui/collections/flex_grid_view.dart
+++ b/mobile/apps/photos/lib/ui/collections/flex_grid_view.dart
@@ -32,6 +32,7 @@ class CollectionsFlexiGridViewWidget extends StatefulWidget {
static const maxThumbnailWidth = 224.0;
static const crossAxisSpacing = 8.0;
static const horizontalPadding = 16.0;
+ static const gridItemTextHeight = 42.0;
final List<Collection>? collections;
// If true, the GridView will shrink-wrap its contents.
@@ -201,7 +202,7 @@ class _CollectionsFlexiGridViewWidgetState
return SliverPadding(
key: key,
padding: const EdgeInsets.only(
- top: 8,
+ top: 16,
left: CollectionsFlexiGridViewWidget.horizontalPadding / 2,
right: CollectionsFlexiGridViewWidget.horizontalPadding / 2,
bottom: 200,
@@ -242,9 +243,12 @@ class _CollectionsFlexiGridViewWidgetState
),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: albumsCountInCrossAxis,
- mainAxisSpacing: 8,
+ mainAxisSpacing: 24,
crossAxisSpacing: CollectionsFlexiGridViewWidget.crossAxisSpacing,
- childAspectRatio: sideOfThumbnail / (sideOfThumbnail + 46),
+ childAspectRatio:
+ sideOfThumbnail /
+ (sideOfThumbnail +
+ CollectionsFlexiGridViewWidget.gridItemTextHeight),
),
),
);
@@ -262,7 +266,7 @@ class _CollectionsFlexiGridViewWidgetState
return SliverPadding(
key: key,
padding: const EdgeInsets.only(
- top: 8,
+ top: 16,
left: 8,
right: 8,
bottom: 200,
@@ -285,9 +289,8 @@ class _CollectionsFlexiGridViewWidgetState
Widget item;
if (showCreateAlbum && index == 0) {
- item = GestureDetector(
- onTap: _createAlbum,
- child: const NewAlbumListItemWidget(),
+ item = NewAlbumListItemWidget(
+ onTap: (_) => _createAlbum(),
);
} else {
final collectionIndex = showCreateAlbum ? index - 1 : index;
diff --git a/mobile/apps/photos/lib/ui/components/thumbnail_list_item.dart b/mobile/apps/photos/lib/ui/components/thumbnail_list_item.dart
index 9745d6853b..4628f25cbe 100644
--- a/mobile/apps/photos/lib/ui/components/thumbnail_list_item.dart
+++ b/mobile/apps/photos/lib/ui/components/thumbnail_list_item.dart
@@ -1,11 +1,8 @@
-import "package:ente_components/theme/colors.dart" as component_colors;
+import "package:ente_components/ente_components.dart";
import "package:flutter/material.dart";
-import "package:photos/theme/colors.dart";
-import "package:photos/theme/ente_theme.dart";
Color thumbnailListItemBackgroundColor(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- return EnteTheme.isDark(context) ? colorScheme.fill : colorScheme.fillDark;
+ return context.componentColors.fillLight;
}
class ThumbnailListItem extends StatefulWidget {
@@ -14,7 +11,7 @@ class ThumbnailListItem extends StatefulWidget {
static const defaultLeadingRadius = 12.0;
static const defaultBorderRadius = 20.0;
static const defaultContentSpacing = 12.0;
- static const defaultItemSpacing = 4.0;
+ static const defaultItemSpacing = 8.0;
static const _stateTransitionDuration = Duration(milliseconds: 120);
final Widget leading;
@@ -59,18 +56,18 @@ class _ThumbnailListItemState extends State<ThumbnailListItem> {
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
+ final colors = context.componentColors;
final child = AnimatedContainer(
duration: ThumbnailListItem._stateTransitionDuration,
width: double.infinity,
padding: widget.padding,
decoration: BoxDecoration(
- color: _backgroundColor(colorScheme),
+ color: _backgroundColor(colors),
borderRadius: BorderRadius.all(Radius.circular(widget.borderRadius)),
border: Border.all(
color: widget.isSelected
- ? _selectedBorderColor(context)
- : widget.borderColor ?? _backgroundColor(colorScheme),
+ ? widget.selectedBorderColor ?? colors.primaryStroke
+ : widget.borderColor ?? _backgroundColor(colors),
),
),
child: Row(
@@ -121,19 +118,11 @@ class _ThumbnailListItemState extends State<ThumbnailListItem> {
);
}
- Color _backgroundColor(EnteColorScheme colorScheme) {
+ Color _backgroundColor(ColorTokens colors) {
if (_isPressed) {
- return colorScheme.fillDarker;
+ return colors.fillDarker;
}
- return widget.backgroundColor ?? colorScheme.fill;
- }
-
- Color _selectedBorderColor(BuildContext context) {
- return widget.selectedBorderColor ??
- component_colors.ColorTokens.forApp(
- component_colors.ComponentApp.photos,
- brightness: Theme.of(context).brightness,
- ).primaryStroke;
+ return widget.backgroundColor ?? colors.fillLight;
}
void _setPressed(bool value) {