π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
update edit sheet
aman-pilot4d505a478ddc
diff --git a/mobile/apps/photos/lib/l10n/intl_en.arb b/mobile/apps/photos/lib/l10n/intl_en.arbindex 24377db67e..a271b6e4a9 100644--- a/mobile/apps/photos/lib/l10n/intl_en.arb+++ b/mobile/apps/photos/lib/l10n/intl_en.arb@@ -2446,6 +2446,7 @@"joinAlbumConfirmationDialogBody": "Joining an album will make your email visible to its participants.","pleaseWaitThisWillTakeAWhile": "Please wait, this will take a while.","editTime": "Edit time",+ "editDateAndTime": "Edit date and time","selectTime": "Select time","selectDate": "Select date","previous": "Previous",diff --git a/mobile/apps/photos/lib/ui/viewer/date/date_time_picker.dart b/mobile/apps/photos/lib/ui/viewer/date/date_time_picker.dartindex 1c50dfed4e..06c092e843 100644--- a/mobile/apps/photos/lib/ui/viewer/date/date_time_picker.dart+++ b/mobile/apps/photos/lib/ui/viewer/date/date_time_picker.dart@@ -1,3 +1,4 @@+import "package:ente_components/ente_components.dart";import "package:flutter/cupertino.dart";import "package:flutter/material.dart";import "package:photos/generated/l10n.dart";@@ -9,37 +10,22 @@ Future<DateTime?> showDatePickerSheet(DateTime? maxDate,DateTime? minDate,bool startWithTime = false,-}) async {- final colorScheme = getEnteColorScheme(context);- final sheet = Container(- decoration: BoxDecoration(- color: colorScheme.backgroundElevated,- borderRadius: const BorderRadius.only(- topLeft: Radius.circular(12),- topRight: Radius.circular(12),- ),- ),- child: Padding(- padding: const EdgeInsets.all(8.0),- child: DateTimePickerWidget(- (DateTime dateTime) {- Navigator.of(context).pop(dateTime);- },- () {- Navigator.of(context).pop(null);- },+}) {+ return showBottomSheetComponent<DateTime?>(+ context: context,+ builder: (context) => BottomSheetComponent(+ showCloseButton: true,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ content: DateTimePickerWidget(+ (dateTime) => Navigator.of(context).pop(dateTime),+ () => Navigator.of(context).pop(null),initialDate,minDateTime: minDate,maxDateTime: maxDate,+ startWithTime: startWithTime,),),);- final newDate = await showModalBottomSheet<DateTime?>(- context: context,- isScrollControlled: true,- builder: (context) => sheet,- );- return newDate;}class DateTimePickerWidget extends StatefulWidget {@@ -49,6 +35,8 @@ class DateTimePickerWidget extends StatefulWidget {final DateTime? maxDateTime;final DateTime? minDateTime;final bool startWithTime;+ final bool showTitle;+ final ValueChanged<bool>? onShowTimePickerChanged;const DateTimePickerWidget(this.onDateTimeSelected,@@ -57,6 +45,8 @@ class DateTimePickerWidget extends StatefulWidget {this.maxDateTime,this.minDateTime,this.startWithTime = false,+ this.showTitle = true,+ this.onShowTimePickerChanged,super.key,});@@ -78,35 +68,37 @@ class _DateTimePickerWidgetState extends State<DateTimePickerWidget> {@overrideWidget build(BuildContext context) {final colorScheme = getEnteColorScheme(context);+ final colors = context.componentColors;return Container(- color: colorScheme.backgroundElevated,+ color: colors.backgroundBase,child: Column(mainAxisSize: MainAxisSize.min,children: [// Header- Padding(- padding: const EdgeInsets.symmetric(vertical: 16),- child: Align(- alignment: Alignment.centerLeft,- child: Text(- _showTimePicker- ? AppLocalizations.of(context).selectTime- : AppLocalizations.of(context).selectDate,- style: TextStyle(color: colorScheme.textBase, fontSize: 16),+ if (widget.showTitle)+ Padding(+ padding: const EdgeInsets.symmetric(vertical: 16),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text(+ _showTimePicker+ ? AppLocalizations.of(context).selectTime+ : AppLocalizations.of(context).selectDate,+ style: TextStyle(color: colorScheme.textBase, fontSize: 16),+ ),),),- ),// Date/Time PickerContainer(height: 220,decoration: BoxDecoration(- color: colorScheme.backgroundElevated2,- borderRadius: BorderRadius.circular(12),+ color: colors.fillLight,+ borderRadius: BorderRadius.circular(Radii.lg),),child: CupertinoTheme(data: CupertinoThemeData(- brightness: Brightness.dark,+ brightness: Theme.of(context).brightness,textTheme: CupertinoTextThemeData(dateTimePickerTextStyle: TextStyle(color: colorScheme.textBase,@@ -179,9 +171,7 @@ class _DateTimePickerWidgetState extends State<DateTimePickerWidget> {onPressed: () {if (_showTimePicker) {// Go back to date picker- setState(() {- _showTimePicker = false;- });+ _setShowTimePicker(false);} else {widget.onCancel();}@@ -207,9 +197,7 @@ class _DateTimePickerWidgetState extends State<DateTimePickerWidget> {widget.onDateTimeSelected(_selectedDateTime);} else {// Move to time picker- setState(() {- _showTimePicker = true;- });+ _setShowTimePicker(true);}},),@@ -220,4 +208,11 @@ class _DateTimePickerWidgetState extends State<DateTimePickerWidget> {),);}++ void _setShowTimePicker(bool showTimePicker) {+ setState(() {+ _showTimePicker = showTimePicker;+ });+ widget.onShowTimePickerChanged?.call(showTimePicker);+ }}diff --git a/mobile/apps/photos/lib/ui/viewer/date/edit_date_sheet.dart b/mobile/apps/photos/lib/ui/viewer/date/edit_date_sheet.dartindex 2f4a0e822d..883b89a98e 100644--- a/mobile/apps/photos/lib/ui/viewer/date/edit_date_sheet.dart+++ b/mobile/apps/photos/lib/ui/viewer/date/edit_date_sheet.dart@@ -1,4 +1,6 @@+import "package:ente_components/ente_components.dart";import 'package:flutter/material.dart';+import "package:hugeicons/hugeicons.dart";import 'package:intl/intl.dart';import "package:photos/generated/l10n.dart";import "package:photos/models/file/file.dart";@@ -14,9 +16,8 @@ Future<DateTime?> showEditDateSheet(Iterable<EnteFile> enteFiles, {bool showHeader = true,}) async {- final newDate = await showModalBottomSheet<DateTime?>(+ final newDate = await showBottomSheetComponent<DateTime?>(context: context,- isScrollControlled: true,builder: (context) =>EditDateSheet(enteFiles: enteFiles, showHeader: showHeader),);@@ -84,119 +85,125 @@ class _EditDateSheetState extends State<EditDateSheet> {return const SizedBox.shrink();}- final colorScheme = getEnteColorScheme(context);DateTime maxDate = DateTime.now();if (!selectSingleDate) {final maxForward = DateTime.now().difference(endDate);maxDate = startDate.add(maxForward);}+ final l10n = AppLocalizations.of(context);+ final String sheetTitle;+ if (selectingTime) {+ sheetTitle = l10n.selectTime;+ } else if (selectingDate) {+ sheetTitle = l10n.selectDate;+ } else {+ sheetTitle = l10n.editDateAndTime;+ }- return Container(- decoration: BoxDecoration(- color: colorScheme.backgroundElevated,- borderRadius: const BorderRadius.only(- topLeft: Radius.circular(12),- topRight: Radius.circular(12),- ),- ),- child: Padding(- padding: const EdgeInsets.all(8.0),- child: Column(- mainAxisSize: MainAxisSize.min,- children: [- // Photo count and date range section- if (widget.showHeader)- PhotoDateHeaderWidget(- enteFiles: widget.enteFiles,- startDate: startDate,- endDate: endDate,- ),- if (showSingleOrShiftChoice)- SelectDateOrShiftWidget(- onSelectOneDate: () {- showSingleOrShiftChoice = false;- selectSingleDate = true;- setState(() {});- },- onShiftDates: () {- showSingleOrShiftChoice = false;- selectSingleDate = false;- setState(() {});- },- ),- if (!showSingleOrShiftChoice && !selectingDate && !selectingTime)- DateAndTimeWidget(- key: ValueKey(selectedDate.toString()),- dateTime: selectedDate,- selectDate: selectSingleDate,- singleFile: photoCount == 1,- newRangeEnd: (selectedDate != startDate && !selectSingleDate)- ? endDate.add(selectedDate.difference(startDate))- : null,- onPressedDate: () {- selectingDate = true;- selectingTime = false;- setState(() {});- },- onPressedTime: () {- selectingDate = false;- selectingTime = true;- setState(() {});- },- ),- if (selectingDate || selectingTime)- DateTimePickerWidget(- (DateTime dateTime) {- selectedDate = dateTime;- selectingDate = false;- selectingTime = false;- setState(() {});- },- () {- selectingDate = false;- selectingTime = false;- setState(() {});- },- selectedDate,- maxDateTime: maxDate,- startWithTime: selectingTime,- ),- if (!showSingleOrShiftChoice &&- !selectingDate &&- !selectingTime &&- selectedDate != startDate)- Column(- children: [- const SizedBox(height: 16),- ButtonWidget(- buttonType: ButtonType.primary,- labelText: AppLocalizations.of(context).confirm,- buttonSize: ButtonSize.large,- onTap: () async {- final newDate = await _editDates(- context,- widget.enteFiles,- selectedDate,- selectSingleDate ? null : startDate,- );- Navigator.of(context).pop(newDate);- },- ),- const SizedBox(height: 8),- ButtonWidget(- buttonType: ButtonType.neutral,- labelText: AppLocalizations.of(context).cancel,- buttonSize: ButtonSize.large,- onTap: () async {- Navigator.of(context).pop(null);- },- ),- ],- ),- // Bottom indicator line- const SizedBox(height: 20),- ],- ),+ return BottomSheetComponent(+ title: sheetTitle,+ showCloseButton: true,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ content: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ // Photo count and date range section+ if (widget.showHeader)+ PhotoDateHeaderWidget(+ enteFiles: widget.enteFiles,+ startDate: startDate,+ endDate: endDate,+ ),+ if (widget.showHeader) const SizedBox(height: Spacing.lg),+ if (showSingleOrShiftChoice)+ SelectDateOrShiftWidget(+ onSelectOneDate: () {+ showSingleOrShiftChoice = false;+ selectSingleDate = true;+ setState(() {});+ },+ onShiftDates: () {+ showSingleOrShiftChoice = false;+ selectSingleDate = false;+ setState(() {});+ },+ ),+ if (!showSingleOrShiftChoice && !selectingDate && !selectingTime)+ DateAndTimeWidget(+ key: ValueKey(selectedDate.toString()),+ dateTime: selectedDate,+ selectDate: selectSingleDate,+ singleFile: photoCount == 1,+ newRangeEnd: (selectedDate != startDate && !selectSingleDate)+ ? endDate.add(selectedDate.difference(startDate))+ : null,+ onPressedDate: () {+ selectingDate = true;+ selectingTime = false;+ setState(() {});+ },+ onPressedTime: () {+ selectingDate = false;+ selectingTime = true;+ setState(() {});+ },+ ),+ if (selectingDate || selectingTime)+ DateTimePickerWidget(+ (DateTime dateTime) {+ selectedDate = dateTime;+ selectingDate = false;+ selectingTime = false;+ setState(() {});+ },+ () {+ selectingDate = false;+ selectingTime = false;+ setState(() {});+ },+ selectedDate,+ maxDateTime: maxDate,+ startWithTime: selectingTime,+ showTitle: false,+ onShowTimePickerChanged: (showTimePicker) {+ selectingDate = !showTimePicker;+ selectingTime = showTimePicker;+ setState(() {});+ },+ ),+ if (!showSingleOrShiftChoice &&+ !selectingDate &&+ !selectingTime &&+ selectedDate != startDate)+ Column(+ children: [+ const SizedBox(height: 16),+ ButtonWidget(+ buttonType: ButtonType.primary,+ labelText: AppLocalizations.of(context).confirm,+ buttonSize: ButtonSize.large,+ onTap: () async {+ final newDate = await _editDates(+ context,+ widget.enteFiles,+ selectedDate,+ selectSingleDate ? null : startDate,+ );+ Navigator.of(context).pop(newDate);+ },+ ),+ const SizedBox(height: 8),+ ButtonWidget(+ buttonType: ButtonType.neutral,+ labelText: AppLocalizations.of(context).cancel,+ buttonSize: ButtonSize.large,+ onTap: () async {+ Navigator.of(context).pop(null);+ },+ ),+ ],+ ),+ ],),);}@@ -255,6 +262,7 @@ class DateAndTimeWidget extends StatelessWidget {@overrideWidget build(BuildContext context) {final colorScheme = getEnteColorScheme(context);+ final colors = context.componentColors;final locale = Localizations.localeOf(context);final String date = DateFormat.yMMMd(locale.toString()).format(dateTime);final String time = DateFormat(@@ -290,53 +298,37 @@ class DateAndTimeWidget extends StatelessWidget {),),if (!singleFile) const SizedBox(height: 16),- 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: [- ListTile(- leading: Icon(- Icons.calendar_today_outlined,- color: colorScheme.textBase,- ),- title: Text(- date,- style: TextStyle(color: colorScheme.textBase, fontSize: 16),- ),- trailing: Icon(- Icons.chevron_right,- color: colorScheme.strokeMuted,- ),- onTap: () => onPressedDate(),+ MenuGroupComponent(+ items: [+ MenuComponent(+ leading: HugeIcon(+ icon: HugeIcons.strokeRoundedCalendar04,+ size: IconSizes.small,+ color: colors.textLight,),- Divider(- color: colorScheme.blurStrokeFaint,- indent: 16,- endIndent: 16,- height: 0.5,+ title: date,+ trailing: Icon(+ Icons.chevron_right_outlined,+ color: colors.textLight,+ size: IconSizes.medium,),- ListTile(- leading: Icon(- Icons.access_time_outlined,- color: colorScheme.textBase,- ),- title: Text(- time,- style: TextStyle(color: colorScheme.textBase, fontSize: 16),- ),- trailing: Icon(- Icons.chevron_right,- color: colorScheme.strokeMuted,- ),- onTap: () => onPressedTime(),+ onTap: () => onPressedDate(),+ ),+ MenuComponent(+ leading: HugeIcon(+ icon: HugeIcons.strokeRoundedClock01,+ size: IconSizes.small,+ color: colors.textLight,),- ],- ),+ title: time,+ trailing: Icon(+ Icons.chevron_right_outlined,+ color: colors.textLight,+ size: IconSizes.medium,+ ),+ onTap: () => onPressedTime(),+ ),+ ],),if (newRangeEnd != null) const SizedBox(height: 16),if (newRangeEnd != null)@@ -421,66 +413,44 @@ class SelectDateOrShiftWidget extends StatelessWidget {@overrideWidget build(BuildContext context) {- final colorScheme = getEnteColorScheme(context);+ final colors = context.componentColors;return Padding(padding: const EdgeInsets.symmetric(vertical: 8),- 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(- AppLocalizations.of(context).selectOneDateAndTime,- style: TextStyle(color: colorScheme.textBase, fontSize: 16),- ),- subtitle: Text(- AppLocalizations.of(context).moveSelectedPhotosToOneDate,- style: TextStyle(color: colorScheme.textFaint, fontSize: 12),- ),- trailing: Icon(- Icons.chevron_right,- color: colorScheme.strokeMuted,- ),- onTap: () => onSelectOneDate(),+ child: MenuGroupComponent(+ items: [+ MenuComponent(+ leading: HugeIcon(+ icon: HugeIcons.strokeRoundedCalendar04,+ size: IconSizes.small,+ color: colors.textLight,),- Divider(- color: colorScheme.blurStrokeFaint,- indent: 16,- endIndent: 16,- height: 0.5,+ title: AppLocalizations.of(context).selectOneDateAndTime,+ subtitle: AppLocalizations.of(context).moveSelectedPhotosToOneDate,+ trailing: Icon(+ Icons.chevron_right_outlined,+ color: colors.textLight,+ size: IconSizes.medium,),- // Shift dates option- ListTile(- leading: Icon(- Icons.calendar_month_outlined,- color: colorScheme.textBase,- ),- title: Text(- AppLocalizations.of(context).shiftDatesAndTime,- style: TextStyle(color: colorScheme.textBase, fontSize: 16),- ),- subtitle: Text(- AppLocalizations.of(context).photosKeepRelativeTimeDifference,- style: TextStyle(color: colorScheme.textFaint, fontSize: 12),- ),- trailing: Icon(- Icons.chevron_right,- color: colorScheme.strokeMuted,- ),- onTap: () => onShiftDates(),+ onTap: () => onSelectOneDate(),+ ),+ MenuComponent(+ leading: HugeIcon(+ icon: HugeIcons.strokeRoundedCalendar03,+ size: IconSizes.small,+ color: colors.textLight,),- ],- ),+ title: AppLocalizations.of(context).shiftDatesAndTime,+ subtitle: AppLocalizations.of(+ context,+ ).photosKeepRelativeTimeDifference,+ trailing: Icon(+ Icons.chevron_right_outlined,+ color: colors.textLight,+ size: IconSizes.medium,+ ),+ onTap: () => onShiftDates(),+ ),+ ],),);}@@ -501,106 +471,73 @@ class PhotoDateHeaderWidget extends StatelessWidget {@overrideWidget build(BuildContext context) {final photoCount = enteFiles.length;- final colorScheme = getEnteColorScheme(context);+ final colors = context.componentColors;final locale = Localizations.localeOf(context);- bool multipleFiles = true;- if (photoCount == 1) {- multipleFiles = false;- }- return Container(- padding: const EdgeInsets.symmetric(vertical: 4),- child: Row(- children: [- // Thumbnail- ClipRRect(- borderRadius: BorderRadius.circular(8),- child: SizedBox(- width: 56,- height: 56,- child: ThumbnailWidget(enteFiles.first),- ),+ final bool multipleFiles = photoCount != 1;+ final dateTextStyle = TextStyles.mini.copyWith(color: colors.textLight);+ return Row(+ children: [+ ClipRRect(+ borderRadius: BorderRadius.circular(Radii.sm),+ child: SizedBox(+ width: 56,+ height: 56,+ child: ThumbnailWidget(enteFiles.first),),- const SizedBox(width: 16),- // Photo count and date info- multipleFiles- ? Expanded(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Text(- AppLocalizations.of(- context,- ).photosCount(count: photoCount),- style: TextStyle(- color: colorScheme.textBase,- fontSize: 18,- fontWeight: FontWeight.bold,+ ),+ const SizedBox(width: Spacing.md),+ multipleFiles+ ? Expanded(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(+ AppLocalizations.of(+ context,+ ).photosCount(count: photoCount),+ style: TextStyles.h2,+ ),+ const SizedBox(height: Spacing.xs),+ Row(+ children: [+ Text(+ _formatDate(startDate, locale, context),+ style: dateTextStyle,),- ),- const SizedBox(height: 4),- Row(- children: [- Text(- _formatDate(startDate, locale, context),- 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, locale, context),- style: TextStyle(- color: colorScheme.textMuted,- fontSize: 12,- ),- ),- ],- ),- ],- ),- )- : Expanded(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Padding(- padding: const EdgeInsets.only(right: 40),- child: FittedBox(- fit: BoxFit.scaleDown,- alignment: Alignment.centerLeft,- child: Text(- enteFiles.first.displayName,- style: TextStyle(- color: colorScheme.textBase,- fontSize: 24,- fontWeight: FontWeight.bold,- ),+ Padding(+ padding: const EdgeInsets.symmetric(+ horizontal: Spacing.sm,),+ child: Text("-", style: dateTextStyle),),- ),- const SizedBox(height: 4),- Text(- "${DateFormat.yMEd(locale.toString()).format(startDate)} Β· ${DateFormat(MediaQuery.of(context).alwaysUse24HourFormat ? 'HH:mm' : 'h:mm a').format(startDate)}",- style: TextStyle(- color: colorScheme.textMuted,- fontSize: 12,+ Text(+ _formatDate(endDate, locale, context),+ style: dateTextStyle,),- ),- ],- ),+ ],+ ),+ ],),- ],- ),+ )+ : Expanded(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(+ enteFiles.first.displayName,+ style: TextStyles.h2,+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ ),+ const SizedBox(height: Spacing.xs),+ Text(+ "${DateFormat.yMEd(locale.toString()).format(startDate)} Β· ${DateFormat(MediaQuery.of(context).alwaysUse24HourFormat ? 'HH:mm' : 'h:mm a').format(startDate)}",+ style: dateTextStyle,+ ),+ ],+ ),+ ),+ ],);}}