dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.04k stars 1.73k forks source link

.Net Maui DatePicker control's PreferredDatePickerStyle for iOS is not working properly. #20285

Open divyesh008 opened 8 months ago

divyesh008 commented 8 months ago

Description

I have added the DatePicker control inside the CollectionView, whenever I open the DatePicker CollectionView and other control above it gets shift down.

The similar bug is reported here: https://github.com/dotnet/maui/issues/16160

For work around I have tried to use PreferredDatePickerStyle.Compact using handler for iOS, because it gives same UI like Android's dialog for DatePicker. But though I have set style to Compact it first open's picker from bottom and in that it gives option to select date. When I click that than it shows compact view but it still shift down's the view because its still open like bottom shit in iOS.

Expectation:

The anticipated behavior is for the iOS application to display the DatePicker in a compact format rather than as a bottom sheet with this configurations.

Check this video for reference:

https://github.com/dotnet/maui/assets/10617244/83a16b27-cea0-4452-8b10-6991dbe7f874

Steps to Reproduce

1. First way

Create a new MAUI App. Add a CollectionView and put a DatePicker inside it.

2. Second way

Create a new MAUI App. Create CustomDatePicker control by overriding DatePicker control Add it inside CollectionView or scroll view control.

Link to public reproduction project repository

https://github.com/divyesh008/DatePicker_Bug

Version with bug

8.0.3

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

7.0.52

Affected platforms

iOS

Affected platform versions

iOS 17.2

Did you find any workaround?

Not yet

Relevant log output

No response

borrmann commented 8 months ago

I have had a look in this source code because I dont really like the wheels either. I think this is basically not supported. MAUI does not use the native UI for the DatePicker initially. Instead, it uses a UITextField and then opens an AccessoryView with the native UI. The platform code doesn't provide a property to change the UIDatePickerStyle, I guess because it doesnt support it.

If you want to use a different style you could create your own control. Alternatively you could try to tweak the handler so that the AccessoryView has different styling (the MauiDoneAccessoryView is inaccessible so I am not sure if you could achieve it that way), or maybe ommited completely (which would make sense for Compact styling).

divyesh008 commented 8 months ago

It does provides the options to select the PreferredDatePickerStyle in maui. But not sure why its not working. https://github.com/dotnet/maui/discussions/19879

I have used the same in my source code if you have check properly. And the thing is inline style is working fine. The only problem it have it with compact style.

picker.PreferredDatePickerStyle = UIDatePickerStyle.Inline;

Screenshot 2024-02-01 at 9 46 09 PM
ghost commented 8 months ago

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.