-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Support local appearance configuration #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@@ -390,6 +393,12 @@ public extension InputField { | |||
return modifiedSelf | |||
} | |||
|
|||
func inputFieldStyle(_ appearance: InputFieldAppearance) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer the modifier to be named .inputFieldAppearance
, as "Style
" reminds me of native SwiftUI modifiers, but those work in a different way, with their own Styles and Configurations. Setting the look of the input field globally is also named defaultAppearance
/globalAppearance
.
func setup(with model: Model, customAppearance: InputFieldAppearance? = nil) { | ||
if let customAppearance { | ||
standardAppearance = customAppearance | ||
setupAppearance() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm adding a suggestion - separating the appearance from behaviour. This is so that existing implementations in UIKit can modify the appearance in their own way (for example: one can modify the appearance by subclassing, accessing the properties, assigning a new appearance proxy or even by modifying the UIKit hierarchy directly). We've got all kinds of mess in our projects, and I hope this should make it more compatible.
Also it supports the "separation of responsibilities" principle, since setting the appearance will be its own function, decoupled from the "model"/traits of the input field.
func setup(with model: Model, customAppearance: InputFieldAppearance? = nil) { | |
if let customAppearance { | |
standardAppearance = customAppearance | |
setupAppearance() | |
func setupAppearance(_ appearance: InputFieldAppearance) { | |
standardAppearance = customAppearance | |
setupAppearance() | |
} | |
func setup(with model: Model) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@plajdo made good points I don't have anything else to add but I do agree with his suggestions.
Note to self: needs to be updated before merging to prevent introducing breaking changes/conflicts |
Changes:
InputField
by using.inputFieldStyle(.custom)
modifier.configureAppearance
remains.Screenshots:
https://github.com/user-attachments/assets/223a842b-2b1d-4e71-a8ad-7837e49e74b7