Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mobile][photos] use SafeArea in Date Picker sheet

Priyanshu Dangare3bc5b66f3b5b
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 1c50dfed4e..fbba29346b 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
@@ -78,145 +78,150 @@ class _DateTimePickerWidgetState extends State<DateTimePickerWidget> {
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
- return Container(
- color: colorScheme.backgroundElevated,
- 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),
+ return SafeArea(
+ child: Container(
+ color: colorScheme.backgroundElevated,
+ 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),
+ ),
),
),
- ),
- // Date/Time Picker
- Container(
- height: 220,
- decoration: BoxDecoration(
- color: colorScheme.backgroundElevated2,
- borderRadius: BorderRadius.circular(12),
- ),
- child: CupertinoTheme(
- data: CupertinoThemeData(
- brightness: Brightness.dark,
- textTheme: CupertinoTextThemeData(
- dateTimePickerTextStyle: TextStyle(
- color: colorScheme.textBase,
- fontSize: 22,
+ // Date/Time Picker
+ Container(
+ height: 220,
+ decoration: BoxDecoration(
+ color: colorScheme.backgroundElevated2,
+ borderRadius: BorderRadius.circular(12),
+ ),
+ child: CupertinoTheme(
+ data: CupertinoThemeData(
+ brightness: Brightness.dark,
+ textTheme: CupertinoTextThemeData(
+ dateTimePickerTextStyle: TextStyle(
+ color: colorScheme.textBase,
+ fontSize: 22,
+ ),
),
),
- ),
- child: CupertinoDatePicker(
- key: ValueKey(_showTimePicker),
- mode: _showTimePicker
- ? CupertinoDatePickerMode.time
- : CupertinoDatePickerMode.date,
- initialDateTime: _selectedDateTime,
- minimumDate: widget.minDateTime ?? DateTime(1800),
- maximumDate: widget.maxDateTime ?? DateTime(2200),
- use24hFormat: MediaQuery.of(context).alwaysUse24HourFormat,
- showDayOfWeek: !_showTimePicker,
- onDateTimeChanged: (DateTime newDateTime) {
- setState(() {
- if (_showTimePicker) {
- // Keep the date but update the time
- _selectedDateTime = DateTime(
- _selectedDateTime.year,
- _selectedDateTime.month,
- _selectedDateTime.day,
- newDateTime.hour,
- newDateTime.minute,
- );
- } else {
- // Keep the time but update the date
- _selectedDateTime = DateTime(
- newDateTime.year,
- newDateTime.month,
- newDateTime.day,
- _selectedDateTime.hour,
- _selectedDateTime.minute,
- );
- }
+ child: CupertinoDatePicker(
+ key: ValueKey(_showTimePicker),
+ mode: _showTimePicker
+ ? CupertinoDatePickerMode.time
+ : CupertinoDatePickerMode.date,
+ initialDateTime: _selectedDateTime,
+ minimumDate: widget.minDateTime ?? DateTime(1800),
+ maximumDate: widget.maxDateTime ?? DateTime(2200),
+ use24hFormat: MediaQuery.of(context).alwaysUse24HourFormat,
+ showDayOfWeek: !_showTimePicker,
+ onDateTimeChanged: (DateTime newDateTime) {
+ setState(() {
+ if (_showTimePicker) {
+ // Keep the date but update the time
+ _selectedDateTime = DateTime(
+ _selectedDateTime.year,
+ _selectedDateTime.month,
+ _selectedDateTime.day,
+ newDateTime.hour,
+ newDateTime.minute,
+ );
+ } else {
+ // Keep the time but update the date
+ _selectedDateTime = DateTime(
+ newDateTime.year,
+ newDateTime.month,
+ newDateTime.day,
+ _selectedDateTime.hour,
+ _selectedDateTime.minute,
+ );
+ }
- // Ensure the selected date doesn't exceed maxDateTime or minDateTime
- if (widget.minDateTime != null &&
- _selectedDateTime.isBefore(widget.minDateTime!)) {
- _selectedDateTime = widget.minDateTime!;
- }
- if (widget.maxDateTime != null &&
- _selectedDateTime.isAfter(widget.maxDateTime!)) {
- _selectedDateTime = widget.maxDateTime!;
- }
- });
- },
+ // Ensure the selected date doesn't exceed maxDateTime or minDateTime
+ if (widget.minDateTime != null &&
+ _selectedDateTime.isBefore(widget.minDateTime!)) {
+ _selectedDateTime = widget.minDateTime!;
+ }
+ if (widget.maxDateTime != null &&
+ _selectedDateTime.isAfter(widget.maxDateTime!)) {
+ _selectedDateTime = widget.maxDateTime!;
+ }
+ });
+ },
+ ),
),
),
- ),
- // 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),
+ // 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,
+ ),
+ ),
+ onPressed: () {
+ if (_showTimePicker) {
+ // Go back to date picker
+ setState(() {
+ _showTimePicker = false;
+ });
+ } else {
+ widget.onCancel();
+ }
+ },
),
- onPressed: () {
- if (_showTimePicker) {
- // Go back to date picker
- setState(() {
- _showTimePicker = 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,
+ // 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,
+ ),
),
+ onPressed: () {
+ if (_showTimePicker) {
+ // We're done, call the callback
+ widget.onDateTimeSelected(_selectedDateTime);
+ } else {
+ // Move to time picker
+ setState(() {
+ _showTimePicker = true;
+ });
+ }
+ },
),
- onPressed: () {
- if (_showTimePicker) {
- // We're done, call the callback
- widget.onDateTimeSelected(_selectedDateTime);
- } else {
- // Move to time picker
- setState(() {
- _showTimePicker = true;
- });
- }
- },
- ),
- ],
+ ],
+ ),
),
- ),
- ],
+ ],
+ ),
),
);
}