-
Notifications
You must be signed in to change notification settings - Fork 33
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
KOA-5072 Add BPKBadge to SwiftUI #1355
Conversation
} | ||
|
||
private var content: some View { | ||
HStack(spacing: BPKSpacing.sm.value) { |
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.
not necessarily part of this pr, but may be nice to add an HStack init that accepts bpkspacing to allow for HStack(spacing: .sm)
.foregroundColor(style.foregroundColor) | ||
} | ||
// Align text and icon frame. | ||
.frame(minHeight: BPKSpacing.base.value) |
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.
not sure what would happen (and what we want to happen) if the user has the font size set to Large on their phone. will the text grow and not the icon?
Think the best is to set height
instead
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.
Setting the min-height will allow the font to grow in the future.
We can also consider setting the height of the whole badge to 24, this follows design but will not allow for spacing or font adjustments.
.padding([.top, .bottom], .sm) | ||
.background(style.backgroundColor) | ||
.clipShape(RoundedRectangle(cornerRadius: .xs)) | ||
.overlay( |
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.
could we make it so that only the outline style adds an overlay?
If it'd be the case that a specific style adds an icon on the right, you wouldn't add it for every style and make it transparent, you would add it just in that case right?
open to debate it tho!
} | ||
} | ||
|
||
var borderColor: BPKColor { |
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 like this, but see my comment on the bpkbadge file
Example/Backpack/SwiftUI/Components/Badge/BadgeExampleVIew.swift
Outdated
Show resolved
Hide resolved
guard let color = color else { | ||
return AnyView(self) | ||
} | ||
|
||
return AnyView( | ||
ModifiedContent( | ||
content: self, | ||
modifier: Outline(color: color, cornerRadius: cornerRadius) | ||
) |
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 think this can be a @ViewBuilder, to remove the need for AnyView-ing
like this: https://www.swiftbysundell.com/articles/avoiding-anyview-in-swiftui/
@ViewBuilder
func outline(_ color: BPKColor?, cornerRadius: BPKCornerRadius) -> some View {
if let color = color {
self
} else {
ModifiedContent(..)
}
}
We have created the SwiftUI version of the BPKBadge. This version also includes the newer 'strong' and 'normal' styles.
Remember to include the following changes:
README.md
Backpack.h
header fileIf you are curious about how we review, please read through the code review guidelines