Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vaIerika
Copy link

Changes:

  • Added a configuration to support custom appearance for InputField by using .inputFieldStyle(.custom) modifier.
  • Logic to setup a global appearance with configureAppearance remains.

Screenshots:
https://github.com/user-attachments/assets/223a842b-2b1d-4e71-a8ad-7837e49e74b7

@@ -390,6 +393,12 @@ public extension InputField {
return modifiedSelf
}

func inputFieldStyle(_ appearance: InputFieldAppearance) -> Self {
Copy link
Contributor

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.

Comment on lines +567 to +570
func setup(with model: Model, customAppearance: InputFieldAppearance? = nil) {
if let customAppearance {
standardAppearance = customAppearance
setupAppearance()
Copy link
Contributor

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.

Suggested change
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) {

Copy link
Contributor

@andrej-jasso andrej-jasso left a 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.

@plajdo
Copy link
Contributor

plajdo commented Apr 7, 2025

Note to self: needs to be updated before merging to prevent introducing breaking changes/conflicts ⚠️

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.

4 participants