add support for corner radius
This commit is contained in:
@@ -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
|
||||
)
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user