CatalystControlsGallery
CatalystControlsGallery copied to clipboard
Replace UIViewRepresentable with native SwiftUI where possible
See commit messages for details.
This PR does not remove HIActivityIndicatorView
because there is currently no way to produce a non-spinning activity indicator from SwiftUI. I’m not sure this is a good UI practice so perhaps that part of the gallery should be removed entirely?
Hey there
Pure-SwiftUI is not a goal of this project, and in fact most of the changes made here make it less Mac-like. Default action buttons do not work in macOS 11's Catalyst, native TextFields don't have the correct styling for macOS or focus mechanics, and the DatePicker is less customizable. If you're trying to make a great Mac app, I would avoid all of these parts of SwiftUI, and not try and simulate it with SwiftUI styles.
This pull request might be useful to folks translating to/from their own SwiftUI development, however.
Cheers
Wow, thanks for pointing those issues out! Do you think it’s still worth pulling the other changes in? (particularly the color picker and progress view, which seem to have similar functionality). I’d be happy to make a PR with just those commits.
I'm happy to have a mix of UIKit and SwiftUI in the project; I think if SwiftUI was used for everything it might turn away UIKit developers, and it's healthy to show that intermixing is possible and fairly easy. In many cases when I go to add variants or more examples for controls, I find I have to move them back to UIKit anyway as SwiftUI doesn't expose enough options, or the SwiftUI version is 'incorrect' as per bordered text fields above, or the Default Button style.
I know when I start adding sample tables & collection views to the project that they will lean heavily on UIKit & UICollectionViewController, as the SwiftUI versions, especially those available to Catalyst, are just not good enough for Mac-like UI.
I'll take a look at the color well/progress bar controls when I get a chance, it's possible that the SwiftUI wrappers might do. Good to have this conversation, though, I think it'll be educational as others come to the project!