Conversation
|
|
| self.drawable = drawable | ||
| } | ||
|
|
||
| public func makeUIView(context: UIViewRepresentableContext<VectorDrawableView>) -> VectorView { |
There was a problem hiding this comment.
shouldn't there be a body function for swiftui?
There was a problem hiding this comment.
No, this isn't a View. It's a UIViewRepresentable.
There was a problem hiding this comment.
Okay technically this is a View. But its Body is already specified as Never in UIKitRepresentable, which is a subtype of View.
There was a problem hiding this comment.
Wait really? UIViewRepresentable is a View as well so it can have all of the standard modifiers applied to it?
| developmentRegion = English; | ||
| hasScannedForEncodings = 0; | ||
| knownRegions = ( | ||
| English, |
There was a problem hiding this comment.
I assume this is some sort of Xcode 11 artifact?
There was a problem hiding this comment.
I think so. I didn't add it deliberately.
| } | ||
|
|
||
| /// The key for Vector Drawable themes. | ||
| public struct ThemeKey: EnvironmentKey { |
There was a problem hiding this comment.
Having watched a couple more WWDC videos on SwiftUI do think it is worthwhile to create your own Theme environment variable? Could we use the \.colorScheme key and accentColor modifier instead? Or I guess add our own accentColor method to make it feel like a first class citizen?
There was a problem hiding this comment.
How would that work?
ColorScheme limits us in terms of what colors we can read (I don't think we can even get system colors from it).
accentColor only seems to work as a tint, and we need to support arbitrary colors.
I agree that this is kind of bad, but I don't see any other options.
There was a problem hiding this comment.
In my mind to be a first class citizen of SwiftUI modifiers like foregroundColor, tintColor, etc should work for a custom view. Requiring custom environment values for a single custom view seems heavy handed. If you had half a dozen custom views that all required unique environment variables to style them I can't see that being enjoyable. Also if we wanted to create another custom view in a different open source repository that also had a theme we'd have to make these repos dependent on one another which isn't ideal.
If there is no way know if a modifier has been applied to your custom view I would think that implementing the modifiers would be the next step. If a modifier is called you then store the values locally and use it to update the look of your custom view.
With respect to dark mode I will admit I don't have first hand experience but I read that Apple allows you to define a color set for normal mode as well as dark mode and that we would expect developers to leverage this and our custom views should also work in this system and not require developers to do any extra work.
There was a problem hiding this comment.
I don't think you can get the environment values out of SwiftUI in a form that you can put into UIKit. If you print the contents of EnvironmentValues, there's a bunch of private types that are used as keys.
As the title. See the comments for details on what this entails and what parts can use more work.