-
Notifications
You must be signed in to change notification settings - Fork 45
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
Allow for customization of the preview name #478
Conversation
@@ -67,6 +67,7 @@ public struct ElementPreview: View { | |||
public typealias ElementProvider = () -> Element | |||
|
|||
private let name: String | |||
private let previewName: String? |
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 believe this is only used for previews—I think we might want to just remove the prefix when using name
.
I think we just want an optional previewName
override on the Market side.
Thoughts?
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.
Okay, here's the result of that suggestion:
@kyleve do you have opinions? is keeping the prefix - name
worthwhile in any cases?
24baa94
to
de5d23a
Compare
return "" | ||
} | ||
}() | ||
let formattedName: String? = name.isEmpty ? nil : name |
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 not actually sure, and fine keeping this in, but should we just allow empty string here? We could document that it maps to .previewDisplayName()
so consumers know it matches that behavior.
What happens if you do provide empty string?
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.
errr
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.
if you pass in an empty string you get the SwiftUI default, if you pass in a name it shows the name. I could have made this trinary (String?
) and have nil
give you the swiftUI default, empty string keep the same behavior ("size that fits" etc.), and a non-empty string override the preview name.
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.
Eh, I kinda like the idea of having the name
match the type of previewDisplayName
but probably not worth the churn. Fine keeping as is!
|
de5d23a
to
145606e
Compare
…ller * origin/main: (62 commits) AccessibilityBlocker aggressively blocking. (#483) Bumping version to 3.0.0 (#482) Allow for customization of the preview name (#478) Update CHANGELOG for AttributedLabel fixes (#480) Fix link detection for stretched labels (#476) chore: Updated minimum deployment target from iOS 14 to iOS 15 [UI-5185] (#479) chore(ios): Bump to Xcode 15.1 and Ruby 3.2.2 [UI-5184] (#477) AXCustomContent Support (#471) Bumping versions to 2.2.0 (#470) Update concatenation logic and unit tests update changelog never cache subelements optionally do not cache subelements Feature: add TintAdjustmentMode, modifiers, and tests Add to CHANGELOG Add tintAdjustmentMode to Image Bumping versions to 2.1.0 (#466) Resolved a Swift 5.9 compilation warning (#465) Update KeyboardObserver (#463) Bump activesupport from 7.0.4.3 to 7.0.7.2 ...
Before, there was no way to explicitly set preview name, leading to things like this in the Xcode canvas view:
With no way to make it look prettier.
With this change we either use the Xcode SwiftUI Previews default, or just the name:
now shows:
much better!