Show 'last year', 'last week' and 'last month' headers in gallery when appropriate

This commit is contained in:
ashilkn
2025-07-23 16:05:03 +05:30
parent 4f00296933
commit cd46db3d30
4 changed files with 58 additions and 3 deletions

View File

@@ -1195,8 +1195,11 @@ class MessageLookup extends MessageLookupByLibrary {
"kindlyHelpUsWithThisInformation": MessageLookupByLibrary.simpleMessage(
"Kindly help us with this information"),
"language": MessageLookupByLibrary.simpleMessage("Language"),
"lastMonth": MessageLookupByLibrary.simpleMessage("Last month"),
"lastTimeWithThem": m45,
"lastUpdated": MessageLookupByLibrary.simpleMessage("Last updated"),
"lastWeek": MessageLookupByLibrary.simpleMessage("Last week"),
"lastYear": MessageLookupByLibrary.simpleMessage("Last year"),
"lastYearsTrip":
MessageLookupByLibrary.simpleMessage("Last year\'s trip"),
"leave": MessageLookupByLibrary.simpleMessage("Leave"),

View File

@@ -12306,6 +12306,16 @@ class S {
);
}
/// `Last week`
String get lastWeek {
return Intl.message(
'Last week',
name: 'lastWeek',
desc: '',
args: [],
);
}
/// `This month`
String get thisMonth {
return Intl.message(
@@ -12316,6 +12326,16 @@ class S {
);
}
/// `Last month`
String get lastMonth {
return Intl.message(
'Last month',
name: 'lastMonth',
desc: '',
args: [],
);
}
/// `This year`
String get thisYear {
return Intl.message(
@@ -12326,6 +12346,16 @@ class S {
);
}
/// `Last year`
String get lastYear {
return Intl.message(
'Last year',
name: 'lastYear',
desc: '',
args: [],
);
}
/// `Group by`
String get groupBy {
return Intl.message(

View File

@@ -1790,7 +1790,10 @@
"cLDesc6": "No more waiting for uploads/downloads to complete before you can close the app. All uploads and downloads now have the ability to be paused midway, and resume from where you left off.",
"indexingPausedStatusDescription": "Indexing is paused. It will automatically resume when the device is ready. The device is considered ready when its battery level, battery health, and thermal status are within a healthy range.",
"thisWeek": "This week",
"lastWeek": "Last week",
"thisMonth": "This month",
"lastMonth": "Last month",
"thisYear": "This year",
"lastYear": "Last year",
"groupBy": "Group by"
}

View File

@@ -199,7 +199,15 @@ extension GroupTypeExtension on GroupType {
if (startOfWeek.year == nowStartOfWeek.year &&
startOfWeek.month == nowStartOfWeek.month &&
startOfWeek.day == nowStartOfWeek.day) {
return "This week";
return S.of(context).thisWeek;
}
// Check if it's the previous week
final lastWeekStart = nowStartOfWeek.subtract(const Duration(days: 7));
if (startOfWeek.year == lastWeekStart.year &&
startOfWeek.month == lastWeekStart.month &&
startOfWeek.day == lastWeekStart.day) {
return S.of(context).lastWeek;
}
// Return formatted week range
@@ -212,7 +220,13 @@ extension GroupTypeExtension on GroupType {
final now = DateTime.now();
if (date.year == now.year && date.month == now.month) {
return "This month";
return S.of(context).thisMonth;
}
// Check if it's the previous month
final lastMonth = DateTime(now.year, now.month - 1);
if (date.year == lastMonth.year && date.month == lastMonth.month) {
return S.of(context).lastMonth;
}
return DateFormat.yMMM(Localizations.localeOf(context).languageCode)
@@ -224,7 +238,12 @@ extension GroupTypeExtension on GroupType {
final now = DateTime.now();
if (date.year == now.year) {
return "This year";
return S.of(context).thisYear;
}
// Check if it's the previous year
if (date.year == now.year - 1) {
return S.of(context).lastYear;
}
return DateFormat.y(Localizations.localeOf(context).languageCode)