Skip to content
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

Nice Components 2.0 #59

Merged
merged 29 commits into from
Mar 26, 2024
Merged

Nice Components 2.0 #59

merged 29 commits into from
Mar 26, 2024

Conversation

brendanlensink
Copy link
Collaborator

@brendanlensink brendanlensink commented Jan 30, 2024

Introducing Nice Components 2.0

This rather large PR intends to move Nice Components into its 2.0 era, improving on the choices we made in 1.0

You can read the original proposal here.

I think the best way to get familiar with what's changed is probably to start with the README, then dig into the new files

# Conflicts:
#	Sources/NiceComponents/Button/NiceButton.swift
#	Sources/NiceComponents/Color/NiceColorTheme.swift
#	Sources/NiceComponents/Text/NiceText.swift
#	Sources/NiceComponents/Theme/FontTheme.swift
#	Sources/NiceComponents/Theme/NiceButtonStyle.swift
#	Sources/NiceComponents/Theme/NiceFontStyle.swift
#	Sources/NiceComponents/Theme/NiceTextStyle.swift
Copy link
Member

@nbrooke nbrooke left a comment

Choose a reason for hiding this comment

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

Added a couple of minor comments, but overall this looks pretty solid to me.

README.md Outdated Show resolved Hide resolved
Sources/NiceComponents/Components/NiceShadowModifier.swift Outdated Show resolved Hide resolved

set {
guard !hasSetConfig else {
os_log("Error! Config has already been set once, at startup. Ignoring config update. ")
Copy link
Member

Choose a reason for hiding this comment

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

Would suck to introduce a dependancy on Steamclog, or build some pluggable error reporting mechanism just for like a handful of errors, but it ALSO sucks that any errors reported via os_log are basically just going into a black hole in our existing apps. Not sure if there is any near term solution here, but we should maybe think about about if we want to try and get Steamclog supporting os_log in some way eventually.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a great point - I'll file a separate ticket to look into this.

I also think there's an argument for this just being a fatalError as well - ideally this is something that gets caught in dev anyways

Copy link
Member

Choose a reason for hiding this comment

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

This is something that has come up before for Steamclog, and I have done a bit of investigation on: steamclock/steamclog-swift#89.

/// Create a custom Font from a given TextTheme
/// - Parameter fontStyle: The styling to use when creating a Font.
/// - Returns: A Font using the size and weight specified in your NiceTextStyle
static func custom(_ style: NiceTextStyle) -> Font {
Copy link
Member

Choose a reason for hiding this comment

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

I know this is not new to this version, but public extensions on system types, in libraries, with fairly generic names, make me a little nervous. I wonder if this should maybe either have a more unique name that includes "nice" in it somewhere (fromNiceStyle?) or if this should be a method on NiceTextStyle instead.

Copy link
Collaborator Author

@brendanlensink brendanlensink Feb 28, 2024

Choose a reason for hiding this comment

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

I see where you're coming from and totally agree, though it does seem like there's already a number of .custom calls on Font, is it less risky because we're passing in a custom type?

Copy link
Member

Choose a reason for hiding this comment

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

You're right that it is less risky if it's only taking a custom type, because then it can't ever have an unresolvable conflict with another extension with the same name in a different library (which is the most serious risk). There's still some risk of a resolvable ambiguity (particularly if other things were adding similarly named extensions), and there's the possibility for confusion if people reading code using it don't understand that there's an extension being pulled in from a library, so I'd say it's slightly better to not do this in general, but I think you're right that in this specific case it is probably okay because of the custom type thing, so maybe not worth changing right now.

# Conflicts:
#	Sources/NiceComponents/Button/NiceButton.swift
@nbrooke nbrooke assigned brendanlensink and unassigned nbrooke Feb 28, 2024
@brendanlensink brendanlensink merged commit b4cc7e2 into main Mar 26, 2024
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.

2 participants