Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
fix(mobile): selecting date from cupertino date widget resets time (#6791)
Richard Shiue8120656198fe
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/date_picker/mobile_date_picker.dart b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/date_picker/mobile_date_picker.dartindex 06c3f3975b..e9f3262cc3 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/date_picker/mobile_date_picker.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/date_picker/mobile_date_picker.dart@@ -336,7 +336,7 @@ class _TimePicker extends StatelessWidget {use24hFormat: timeFormat == TimeFormatPB.TwentyFourHour,mode: CupertinoDatePickerMode.date,);- handleDateTimePickerResult(result, isStartDay);+ handleDateTimePickerResult(result, isStartDay, true);},child: Padding(padding: const EdgeInsets.symmetric(@@ -363,7 +363,7 @@ class _TimePicker extends StatelessWidget {use24hFormat: timeFormat == TimeFormatPB.TwentyFourHour,mode: CupertinoDatePickerMode.date,);- handleDateTimePickerResult(result, isStartDay);+ handleDateTimePickerResult(result, isStartDay, true);},child: Padding(padding: const EdgeInsets.symmetric(vertical: 8.0),@@ -389,7 +389,7 @@ class _TimePicker extends StatelessWidget {use24hFormat: timeFormat == TimeFormatPB.TwentyFourHour,mode: CupertinoDatePickerMode.time,);- handleDateTimePickerResult(result, isStartDay);+ handleDateTimePickerResult(result, isStartDay, false);},child: Padding(padding: const EdgeInsets.symmetric(vertical: 8.0),@@ -461,11 +461,27 @@ class _TimePicker extends StatelessWidget {);}- void handleDateTimePickerResult(DateTime? result, bool isStartDay) {+ void handleDateTimePickerResult(+ DateTime? result,+ bool isStartDay,+ bool isDate,+ ) {if (result == null) {return;- } else if (isStartDay) {- onStartTimeChanged(result);+ }++ if (isDate) {+ final date = isStartDay ? dateTime : endDateTime;++ if (date != null) {+ final timeComponent = Duration(hours: date.hour, minutes: date.minute);+ result =+ DateTime(result.year, result.month, result.day).add(timeComponent);+ }+ }++ if (isStartDay) {+ onStartTimeChanged.call(result);} else {onEndTimeChanged?.call(result);}