Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] extract widgets

laurenspriem013f83cc39e6
diff --git a/mobile/lib/ui/components/bulk_edit_widget.dart b/mobile/lib/ui/components/bulk_edit_widget.dart
index cb8466f84d..175476ba28 100644
--- a/mobile/lib/ui/components/bulk_edit_widget.dart
+++ b/mobile/lib/ui/components/bulk_edit_widget.dart
@@ -4,16 +4,12 @@ import "package:photos/models/file/file.dart";
import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/viewer/file/thumbnail_widget.dart";
-class PhotoDateSelectionBottomSheet extends StatelessWidget {
+class BulkEditDateBottomSheet extends StatelessWidget {
final Iterable<EnteFile> enteFiles;
- final Function(bool) onSelectOneDate;
- final Function(bool) onShiftDates;
- const PhotoDateSelectionBottomSheet({
+ const BulkEditDateBottomSheet({
super.key,
required this.enteFiles,
- required this.onSelectOneDate,
- required this.onShiftDates,
});
@override
@@ -51,155 +47,209 @@ class PhotoDateSelectionBottomSheet extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
// Photo count and date range section
- Container(
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
- child: Row(
- children: [
- // Thumbnail
- ClipRRect(
- borderRadius: BorderRadius.circular(8),
- child: SizedBox(
- width: 56,
- height: 56,
- child: ThumbnailWidget(enteFiles.first),
- ),
+ PhotoDateHeaderWidget(
+ enteFiles: enteFiles,
+ startDate: startDate,
+ endDate: endDate,
+ ),
+ SelectDateOrShiftWidget(
+ onSelectOneDate: () {
+ Navigator.pop(context);
+ },
+ onShiftDates: () {
+ Navigator.pop(context);
+ },
+ ),
+
+ // Bottom indicator line
+ const SizedBox(height: 48),
+ ],
+ ),
+ );
+ }
+}
+
+class SelectDateOrShiftWidget extends StatelessWidget {
+ const SelectDateOrShiftWidget({
+ super.key,
+ required this.onSelectOneDate,
+ required this.onShiftDates,
+ });
+
+ final Function() onSelectOneDate;
+ final Function() onShiftDates;
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ return Padding(
+ padding: const EdgeInsets.all(8.0),
+ child: Container(
+ decoration: BoxDecoration(
+ color: colorScheme.backgroundElevated2,
+ border: Border.all(
+ color: colorScheme.strokeFaint,
+ width: 0.5,
+ ),
+ borderRadius: BorderRadius.circular(8),
+ ),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ // Select one date option
+ ListTile(
+ leading: Icon(
+ Icons.calendar_today_outlined,
+ color: colorScheme.textBase,
+ ),
+ title: Text(
+ "Select one date and time",
+ style: TextStyle(
+ color: colorScheme.textBase,
+ fontSize: 16,
),
- const SizedBox(width: 16),
- // Photo count and date info
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- "$photoCount photos",
- style: TextStyle(
- color: colorScheme.textBase,
- fontSize: 18,
- fontWeight: FontWeight.bold,
- ),
- ),
- const SizedBox(height: 4),
- Row(
- children: [
- Text(
- _formatDate(startDate),
- style: TextStyle(
- color: colorScheme.textMuted,
- fontSize: 12,
- ),
- ),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8),
- child: Text(
- "-",
- style: TextStyle(
- color: colorScheme.textMuted,
- fontSize: 12,
- ),
- ),
- ),
- Text(
- _formatDate(endDate),
- style: TextStyle(
- color: colorScheme.textMuted,
- fontSize: 12,
- ),
- ),
- ],
- ),
- ],
- ),
+ ),
+ subtitle: Text(
+ "Move selected photos to one date",
+ style: TextStyle(
+ color: colorScheme.textFaint,
+ fontSize: 12,
),
- ],
+ ),
+ trailing: Icon(
+ Icons.chevron_right,
+ color: colorScheme.strokeMuted,
+ ),
+ onTap: () => onSelectOneDate(),
),
- ),
- Padding(
- padding: const EdgeInsets.all(8.0),
- child: Container(
- decoration: BoxDecoration(
- color: colorScheme.backgroundElevated2,
- border: Border.all(
- color: colorScheme.strokeFaint,
- width: 0.5,
+
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ child: Divider(
+ color: colorScheme.blurStrokeFaint,
+ ),
+ ),
+
+ // Shift dates option
+ ListTile(
+ leading: Icon(
+ Icons.calendar_month_outlined,
+ color: colorScheme.textBase,
+ ),
+ title: Text(
+ "Shift dates and time",
+ style: TextStyle(
+ color: colorScheme.textBase,
+ fontSize: 16,
),
- borderRadius: BorderRadius.circular(8),
),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- // Select one date option
- ListTile(
- leading: Icon(
- Icons.calendar_today_outlined,
- color: colorScheme.textBase,
- ),
- title: Text(
- "Select one date and time",
- style: TextStyle(
- color: colorScheme.textBase,
- fontSize: 16,
- ),
- ),
- subtitle: Text(
- "Move selected photos to one date",
+ subtitle: Text(
+ "Photos keep relative time difference",
+ style: TextStyle(
+ color: colorScheme.textFaint,
+ fontSize: 12,
+ ),
+ ),
+ trailing: Icon(
+ Icons.chevron_right,
+ color: colorScheme.strokeMuted,
+ ),
+ onTap: () => onShiftDates(),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+}
+
+class PhotoDateHeaderWidget extends StatelessWidget {
+ const PhotoDateHeaderWidget({
+ super.key,
+ required this.enteFiles,
+ required this.startDate,
+ required this.endDate,
+ });
+
+ final Iterable<EnteFile> enteFiles;
+ final DateTime startDate;
+ final DateTime endDate;
+
+ @override
+ Widget build(BuildContext context) {
+ final photoCount = enteFiles.length;
+ if (photoCount == 0) {
+ return const SizedBox.shrink();
+ }
+ final colorScheme = getEnteColorScheme(context);
+ if (photoCount == 0) {
+ return const SizedBox.shrink();
+ }
+ return Container(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
+ child: Row(
+ children: [
+ // Thumbnail
+ ClipRRect(
+ borderRadius: BorderRadius.circular(8),
+ child: SizedBox(
+ width: 56,
+ height: 56,
+ child: ThumbnailWidget(enteFiles.first),
+ ),
+ ),
+ const SizedBox(width: 16),
+ // Photo count and date info
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ "$photoCount photos",
+ style: TextStyle(
+ color: colorScheme.textBase,
+ fontSize: 18,
+ fontWeight: FontWeight.bold,
+ ),
+ ),
+ const SizedBox(height: 4),
+ Row(
+ children: [
+ Text(
+ _formatDate(startDate),
style: TextStyle(
- color: colorScheme.textFaint,
+ color: colorScheme.textMuted,
fontSize: 12,
),
),
- trailing: Icon(
- Icons.chevron_right,
- color: colorScheme.strokeMuted,
- ),
- onTap: () => onSelectOneDate(true),
- ),
-
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Divider(
- color: colorScheme.blurStrokeFaint,
- ),
- ),
-
- // Shift dates option
- ListTile(
- leading: Icon(
- Icons.calendar_month_outlined,
- color: colorScheme.textBase,
- ),
- title: Text(
- "Shift dates and time",
- style: TextStyle(
- color: colorScheme.textBase,
- fontSize: 16,
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 8),
+ child: Text(
+ "-",
+ style: TextStyle(
+ color: colorScheme.textMuted,
+ fontSize: 12,
+ ),
),
),
- subtitle: Text(
- "Photos keep relative time difference",
+ Text(
+ _formatDate(endDate),
style: TextStyle(
- color: colorScheme.textFaint,
+ color: colorScheme.textMuted,
fontSize: 12,
),
),
- trailing: Icon(
- Icons.chevron_right,
- color: colorScheme.strokeMuted,
- ),
- onTap: () => onShiftDates(true),
- ),
- ],
- ),
+ ],
+ ),
+ ],
),
),
-
- // Bottom indicator line
- const SizedBox(height: 48),
],
),
);
}
+}
- String _formatDate(DateTime date) {
- return "Sat, ${DateFormat('dd MMM yyyy').format(date)}\n${DateFormat('h:mm a').format(date)}";
- }
+String _formatDate(DateTime date) {
+ return "Sat, ${DateFormat('dd MMM yyyy').format(date)}\n${DateFormat('h:mm a').format(date)}";
}
diff --git a/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart b/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart
index cedacccd3a..da464a866c 100644
--- a/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart
+++ b/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart
@@ -406,16 +406,8 @@ class _FileSelectionActionsWidgetState
await showModalBottomSheet(
context: context,
isScrollControlled: true,
- builder: (context) => PhotoDateSelectionBottomSheet(
+ builder: (context) => BulkEditDateBottomSheet(
enteFiles: widget.selectedFiles.files,
- onSelectOneDate: (selected) {
- Navigator.pop(context);
- // Handle select one date action
- },
- onShiftDates: (selected) {
- Navigator.pop(context);
- // Handle shift dates action
- },
),
);
},