feat: Moves flagged styles into their view files
This commit is contained in:
@@ -22,6 +22,28 @@ public struct FlaggedMessageLabel: View {
|
||||
}
|
||||
}
|
||||
|
||||
private struct FlaggedMessageLabelStyleKey: EnvironmentKey {
|
||||
static var defaultValue = AnyTextLabelStyle(style: .font(.caption))
|
||||
}
|
||||
|
||||
extension EnvironmentValues {
|
||||
var flaggedMessageLabelStyle: AnyTextLabelStyle {
|
||||
get { self[FlaggedMessageLabelStyleKey.self] }
|
||||
set { self[FlaggedMessageLabelStyleKey.self] = newValue }
|
||||
}
|
||||
}
|
||||
|
||||
extension View {
|
||||
public func flaggedMessageLabelStyle(_ style: AnyTextLabelStyle) -> some View {
|
||||
environment(\.flaggedMessageLabelStyle, style)
|
||||
}
|
||||
|
||||
public func flaggedMessageLabelStyle<S: TextLabelStyle>(_ style: S) -> some View {
|
||||
flaggedMessageLabelStyle(AnyTextLabelStyle(style: style))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#Preview {
|
||||
FlaggedStatusLabel(status: .warning)
|
||||
.flaggedStatusLabelStyle(.textLabel(.heavyTitle2))
|
||||
|
||||
Reference in New Issue
Block a user