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.

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.

@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.

@bbrk24 bbrk24 requested a review from stackotter December 19, 2025 02:25
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.

Somehow GitHub just had some of these comments pending from a while ago. I guess I must've left the review halfway through?

There's also this comment unresolved from a while ago: #244 (comment) . What do you reckon about that idea?

Looking good now though. Happy to merge once the GDateTime documentation comment is addressed and these changes have been rebased onto main.

bbrk24 added 2 commits January 5, 2026 19:01
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

Address some PR comments

Update some doc comments

Support date-only pickers in AppKitBackend

Change default timezone and calendar from autoupdatingCurrent to current

Address more PR comments

tvOS please compile first try
@stackotter
Copy link
Owner

I think you'll have to run ./generate.sh && ./format_and_lint.sh to fix those Gtk build issues. I changed some things about the generation

@bbrk24
Copy link
Contributor Author

bbrk24 commented Jan 7, 2026

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

Done, and added a #if so that it can still run in Gtk3Backend (which doesn't implement pickers).

VStack {
Text("Selected date: \(date)")

Picker(of: supportedDatePickerStyles, selection: $datePickerStyle)
Copy link
Owner

Choose a reason for hiding this comment

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

Please put this in an HStack along with a label (like above for the flavour picker) so that it's clear what the picker is for


Picker(of: supportedDatePickerStyles, selection: $datePickerStyle)

DatePicker(
Copy link
Owner

Choose a reason for hiding this comment

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

Please put the entirety of ControlsExample into a ScrollView because it's gotten pretty tall now (too tall for my laptop display). I probably should've done that a while ago

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