diff --git a/mobile/lib/ui/viewer/gallery/component/group/group_header_widget.dart b/mobile/lib/ui/viewer/gallery/component/group/group_header_widget.dart index a946cd9d6..25ea5e7d6 100644 --- a/mobile/lib/ui/viewer/gallery/component/group/group_header_widget.dart +++ b/mobile/lib/ui/viewer/gallery/component/group/group_header_widget.dart @@ -1,16 +1,15 @@ import "package:flutter/cupertino.dart"; -import "package:intl/intl.dart"; import 'package:photos/core/constants.dart'; import "package:photos/generated/l10n.dart"; import "package:photos/theme/ente_theme.dart"; class GroupHeaderWidget extends StatelessWidget { - final int timestamp; + final String title; final int gridSize; const GroupHeaderWidget({ super.key, - required this.timestamp, + required this.title, required this.gridSize, }); @@ -22,7 +21,7 @@ class GroupHeaderWidget extends StatelessWidget { gridSize < photoGridSizeMax ? textTheme.body : textTheme.small; final double horizontalPadding = gridSize < photoGridSizeMax ? 12.0 : 8.0; final double verticalPadding = gridSize < photoGridSizeMax ? 12.0 : 14.0; - final String dayTitle = _getDayTitle(context, timestamp); + return Padding( padding: EdgeInsets.symmetric( horizontal: horizontalPadding, @@ -31,33 +30,12 @@ class GroupHeaderWidget extends StatelessWidget { child: Container( alignment: Alignment.centerLeft, child: Text( - dayTitle, - style: (dayTitle == S.of(context).dayToday) + title, + style: (title == S.of(context).dayToday) ? textStyle : textStyle.copyWith(color: colorScheme.textMuted), ), ), ); } - - String _getDayTitle(BuildContext context, int timestamp) { - final date = DateTime.fromMicrosecondsSinceEpoch(timestamp); - final now = DateTime.now(); - - if (date.year == now.year && date.month == now.month) { - if (date.day == now.day) { - return S.of(context).dayToday; - } else if (date.day == now.day - 1) { - return S.of(context).dayYesterday; - } - } - - if (date.year != DateTime.now().year) { - return DateFormat.yMMMEd(Localizations.localeOf(context).languageCode) - .format(date); - } else { - return DateFormat.MMMEd(Localizations.localeOf(context).languageCode) - .format(date); - } - } } diff --git a/mobile/lib/ui/viewer/gallery/component/group/lazy_group_gallery.dart b/mobile/lib/ui/viewer/gallery/component/group/lazy_group_gallery.dart index 8e81a4eb7..dab467372 100644 --- a/mobile/lib/ui/viewer/gallery/component/group/lazy_group_gallery.dart +++ b/mobile/lib/ui/viewer/gallery/component/group/lazy_group_gallery.dart @@ -11,6 +11,7 @@ import 'package:photos/theme/ente_theme.dart'; import "package:photos/ui/viewer/gallery/component/grid/place_holder_grid_view_widget.dart"; import "package:photos/ui/viewer/gallery/component/group/group_gallery.dart"; import "package:photos/ui/viewer/gallery/component/group/group_header_widget.dart"; +import "package:photos/ui/viewer/gallery/component/group/type.dart"; import 'package:photos/ui/viewer/gallery/gallery.dart'; import "package:photos/ui/viewer/gallery/state/gallery_context_state.dart"; @@ -178,6 +179,7 @@ class _LazyGroupGalleryState extends State { if (_filesInGroup.isEmpty) { return const SizedBox.shrink(); } + final groupType = GalleryContextState.of(context)!.type; return Column( children: [ Row( @@ -185,7 +187,7 @@ class _LazyGroupGalleryState extends State { children: [ if (widget.enableFileGrouping) GroupHeaderWidget( - timestamp: _filesInGroup[0].creationTime!, + title: groupType.getTitle(context, _filesInGroup[0]), gridSize: widget.photoGridSize, ), Expanded(child: Container()),