Skip to content

Conversation

@bbrk24
Copy link
Contributor

@bbrk24 bbrk24 commented Nov 6, 2025

Fixes #233

Each backend has its own shortcomings:

  • UIKitBackend has weird availability constraints on each picker style, doesn't support hourMinuteAndSecond, and doesn't respect font color
    • Furthermore, UIDatePicker doesn't exist on tvOS
  • AppKitBackend doesn't support the wheel picker style
  • WinUIBackend doesn't support hourMinuteAndSecond, doesn't respect font color, and doesn't respect environment.timeZone (instead always using the current time zone)
  • GtkBackend only supports the graphical picker style, doesn't respect environment.timeZone (instead always using UTC), and only supports picking the date, not the time
  • Gtk3Backend is unimplemented as I have no way to test it.

@bbrk24
Copy link
Contributor Author

bbrk24 commented Nov 6, 2025

The thought just occurred to me to observe NSSystemTimeZoneDidChange to properly redraw views that use @Environment(\.timeZone), but I'm unsure how that would work, and regardless I don't see an equivalent for the calendar.

@stackotter
Copy link
Owner

There’s a backend method called setEnvironmentChangeHandler or something like that. That’s where we currently observe system theme changes and would be where timezone observation should live as well.

@bbrk24
Copy link
Contributor Author

bbrk24 commented Nov 7, 2025

Right, I'll go see if I can get that to work in UIKitBackend and AppKitBackend first, and then maybe the other backends. I don't think it'll necessarily work on Linux though

@bbrk24 bbrk24 marked this pull request as draft November 7, 2025 18:53
@bbrk24
Copy link
Contributor Author

bbrk24 commented Nov 7, 2025

Marking this as draft because UIDatePicker (at least on iOS 17) completely misbehaves if the user changes the time zone in settings

@bbrk24 bbrk24 marked this pull request as ready for review November 8, 2025 00:34
Copy link
Owner

@stackotter stackotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this super detailed PR! Safari was lagging the entire time that I was reviewing your changes lol. I've left a bunch of requests and comments from an initial read through of all of the code.

I haven't had time to test out the changes myself yet, but I'll make sure to do that before merging and will update the PR with any additional feedback I have after testing things out.

Comment on lines +130 to +143
#if os(tvOS)
preconditionFailure()
#else
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With my comment about making updateDatePicker available on tvOS, I think this conditional compilation should be made redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, already done

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub is showing conditional compilation here, but I am trying the beta pr review layout, so not sure whether it's telling the truth or not.

Add DatePicker for AppKitBackend

Add DatePickerExample to macOS CI

Fix DatePicker update logic for AppKitBackend

Update argument name to match SwiftUI

Add more availability annotations

Shut up tvOS let me see if the iOS CI will pass

please work.

Fine, here's your view

Initial WinUI implementation

Reformat WinUI code

Implement minYear/maxYear for DatePicker

Improve WinUI sizing code

Fix CalendarDatePicker size

Minor cleanup

Generate GTK classes and improve manual type conversion

oops

Fix casing of calendar name

Saving partial work on GtkBackend

More partial work

Use Gtk.Calendar

Add missing parts to GtkBackend.updateDatePicker

Add DatePickerExample to Linux CI

Fix one Mac availability error

Add availability annotation on unused widget

Add time zone listener for UIKitBackend

Add listener for AppKitBackend
Update some doc comments

Support date-only pickers in AppKitBackend

Change default timezone and calendar from autoupdatingCurrent to current
Copy link
Owner

@stackotter stackotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the DatePicker example is relatively simple, I reckon it could make sense to merge it into ControlsExample.


func createDatePicker() -> Widget

#if !os(tvOS)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you make DatePickerComponents available on tvOS would it be possible? I feel like there's not an issue with making that available.

/// The display style used by ``DatePicker``.
public var datePickerStyle: DatePickerStyle

/// The display styles supported by ``DatePicker``. ``datePickerStyle`` must be one of these.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second sentence isn't true cause under Gtk3Backend the supported styles list is empty, but the datePickerStyle is .automatic by default (which isn't in the list).

Maybe automatic should always be allowed even if the backend doesn't state so (cause the date picker style is kinda inconsequential if DatePicker doesn't work anyway). Another reason for doing so is that it feels like .datePickerStyle(environment.datePickerStyle) should probably be allowed in all circumstances, cause it's kinda an identity operation (and allowing automatic in all circumstances would make it act like one).

Comment on lines +130 to +143
#if os(tvOS)
preconditionFailure()
#else
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub is showing conditional compilation here, but I am trying the beta pr review layout, so not sure whether it's telling the truth or not.

@stackotter
Copy link
Owner

I think I've gone through and closed all of the review comments that have been addressed and commented on ones that I have more questions about.

Regarding the GtkBackend TimePicker implementation: when I originally reviewed it I didn't realise that it's unused. If you'd like, feel free to turn my current comments on it into todo comments and document clearly that the class is neither ready nor used, and I'd count those comments as resolved. I more just want to avoid another contributor coming along and trying to use it assuming that it's meant to work properly in its current form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Date Picker

2 participants