diff --git a/Sources/phbar/Models/PHTheme/PHThemeStyle.swift b/Sources/phbar/Models/PHTheme/PHThemeStyle.swift index 529aea4..36272a8 100644 --- a/Sources/phbar/Models/PHTheme/PHThemeStyle.swift +++ b/Sources/phbar/Models/PHTheme/PHThemeStyle.swift @@ -3,13 +3,15 @@ struct PHThemeStyle: Decodable { let foreground: PHThemeStyleColor? let background: PHThemeStyleColor? let padding: PHThemeStylePadding? + let corner: PHThemeStyleCorner? static let `default`: Self = { PHThemeStyle( name: "_default", foreground: .init(color: "#000000", alpha: nil), background: .init(color: "#ffffff", alpha: nil), - padding: .init(leading: 12, trailing: 12) + padding: .init(leading: 12, trailing: 12), + corner: nil ) }() } diff --git a/Sources/phbar/Models/PHTheme/PHThemeStyle/PHThemeStyleCorner.swift b/Sources/phbar/Models/PHTheme/PHThemeStyle/PHThemeStyleCorner.swift new file mode 100644 index 0000000..f9e3466 --- /dev/null +++ b/Sources/phbar/Models/PHTheme/PHThemeStyle/PHThemeStyleCorner.swift @@ -0,0 +1,26 @@ +import SwiftUI + +struct PHThemeStyleCorner: Decodable { + let radius: Double + private let _style: PHThemeStyleCornerStyle? + + var style: SwiftUI.RoundedCornerStyle { + switch _style { + case .circular: + return .circular + case .continuous: + return .continuous + default: + return .circular + } + } + + private enum CodingKeys: String, CodingKey { + case radius + case _style = "style" + } +} + +enum PHThemeStyleCornerStyle: String, Decodable { + case circular, continuous +} diff --git a/Sources/phbar/Views/TextBlockView.swift b/Sources/phbar/Views/TextBlockView.swift index 733388f..50c9d5b 100644 --- a/Sources/phbar/Views/TextBlockView.swift +++ b/Sources/phbar/Views/TextBlockView.swift @@ -14,8 +14,14 @@ struct TextBlockView: View { var body: some View { if let label = block.label, !label.isEmpty { ZStack(alignment: .center) { - RoundedRectangle(cornerRadius: 0) - .foregroundStyle(block.style.background?.uiColor ?? .clear) + Group { + if let corner = block.style.corner { + RoundedRectangle(cornerRadius: corner.radius, style: corner.style) + } else { + Rectangle() + } + } + .foregroundStyle(block.style.background?.uiColor ?? .clear) Group { Text(label)