Skip to content

armgit / ente

Public Imported from GitHub
0

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

update date time picker

aman-pilot21253559e070
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.dart
index 06c092e843..34177daeed 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
@@ -2,7 +2,6 @@ import "package:ente_components/ente_components.dart";
import "package:flutter/cupertino.dart";
import "package:flutter/material.dart";
import "package:photos/generated/l10n.dart";
-import "package:photos/theme/ente_theme.dart";
Future<DateTime?> showDatePickerSheet(
BuildContext context, {
@@ -11,20 +10,30 @@ Future<DateTime?> showDatePickerSheet(
DateTime? minDate,
bool startWithTime = false,
}) {
+ bool showTimePicker = startWithTime;
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,
- ),
- ),
+ builder: (context) {
+ final l10n = AppLocalizations.of(context);
+ return StatefulBuilder(
+ builder: (context, setState) => BottomSheetComponent(
+ title: showTimePicker ? l10n.selectTime : l10n.selectDate,
+ 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,
+ showTitle: false,
+ onShowTimePickerChanged: (value) =>
+ setState(() => showTimePicker = value),
+ ),
+ ),
+ );
+ },
);
}
@@ -67,7 +76,6 @@ class _DateTimePickerWidgetState extends State<DateTimePickerWidget> {
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
final colors = context.componentColors;
return Container(
color: colors.backgroundBase,
@@ -84,7 +92,7 @@ class _DateTimePickerWidgetState extends State<DateTimePickerWidget> {
_showTimePicker
? AppLocalizations.of(context).selectTime
: AppLocalizations.of(context).selectDate,
- style: TextStyle(color: colorScheme.textBase, fontSize: 16),
+ style: TextStyle(color: colors.textBase, fontSize: 16),
),
),
),
@@ -101,7 +109,7 @@ class _DateTimePickerWidgetState extends State<DateTimePickerWidget> {
brightness: Theme.of(context).brightness,
textTheme: CupertinoTextThemeData(
dateTimePickerTextStyle: TextStyle(
- color: colorScheme.textBase,
+ color: colors.textBase,
fontSize: 22,
),
),
@@ -154,54 +162,51 @@ class _DateTimePickerWidgetState extends State<DateTimePickerWidget> {
),
// Buttons
- Padding(
- padding: const EdgeInsets.symmetric(vertical: 12.0),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- // Cancel Button
- CupertinoButton(
- padding: EdgeInsets.zero,
- child: Text(
- _showTimePicker
- ? AppLocalizations.of(context).previous
- : AppLocalizations.of(context).cancel,
- style: TextStyle(color: colorScheme.textBase, fontSize: 14),
+ SafeArea(
+ top: false,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(vertical: 12.0),
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ TextButton(
+ style: TextButton.styleFrom(
+ foregroundColor: colors.textBase,
+ textStyle: TextStyles.body,
+ ),
+ onPressed: () {
+ if (_showTimePicker) {
+ _setShowTimePicker(false);
+ } else {
+ widget.onCancel();
+ }
+ },
+ child: Text(
+ _showTimePicker
+ ? AppLocalizations.of(context).previous
+ : AppLocalizations.of(context).cancel,
+ ),
),
- onPressed: () {
- if (_showTimePicker) {
- // Go back to date picker
- _setShowTimePicker(false);
- } else {
- widget.onCancel();
- }
- },
- ),
-
- // Next/Done Button
- CupertinoButton(
- padding: EdgeInsets.zero,
- child: Text(
- _showTimePicker
- ? AppLocalizations.of(context).done
- : AppLocalizations.of(context).next,
- style: TextStyle(
- color: colorScheme.primary700,
- fontSize: 14,
- fontWeight: FontWeight.bold,
+ TextButton(
+ style: TextButton.styleFrom(
+ foregroundColor: colors.primary,
+ textStyle: TextStyles.bodyBold,
+ ),
+ onPressed: () {
+ if (_showTimePicker) {
+ widget.onDateTimeSelected(_selectedDateTime);
+ } else {
+ _setShowTimePicker(true);
+ }
+ },
+ child: Text(
+ _showTimePicker
+ ? AppLocalizations.of(context).done
+ : AppLocalizations.of(context).next,
),
),
- onPressed: () {
- if (_showTimePicker) {
- // We're done, call the callback
- widget.onDateTimeSelected(_selectedDateTime);
- } else {
- // Move to time picker
- _setShowTimePicker(true);
- }
- },
- ),
- ],
+ ],
+ ),
),
),
],
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.dart
index 883b89a98e..d6801c06f2 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
@@ -5,8 +5,6 @@ import 'package:intl/intl.dart';
import "package:photos/generated/l10n.dart";
import "package:photos/models/file/file.dart";
import "package:photos/theme/ente_theme.dart";
-import "package:photos/ui/components/buttons/button_widget.dart";
-import "package:photos/ui/components/models/button_type.dart";
import "package:photos/ui/viewer/date/date_time_picker.dart";
import "package:photos/ui/viewer/file/thumbnail_widget.dart";
import "package:photos/utils/magic_util.dart";
@@ -175,33 +173,22 @@ class _EditDateSheetState extends State<EditDateSheet> {
!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);
- },
- ),
- ],
+ Padding(
+ padding: const EdgeInsets.only(top: Spacing.lg),
+ child: ButtonComponent(
+ variant: ButtonComponentVariant.primary,
+ size: ButtonComponentSize.large,
+ label: AppLocalizations.of(context).confirm,
+ onTap: () async {
+ final newDate = await _editDates(
+ context,
+ widget.enteFiles,
+ selectedDate,
+ selectSingleDate ? null : startDate,
+ );
+ Navigator.of(context).pop(newDate);
+ },
+ ),
),
],
),