add support for corner radius
This commit is contained in:
@@ -3,13 +3,15 @@ struct PHThemeStyle: Decodable {
|
|||||||
let foreground: PHThemeStyleColor?
|
let foreground: PHThemeStyleColor?
|
||||||
let background: PHThemeStyleColor?
|
let background: PHThemeStyleColor?
|
||||||
let padding: PHThemeStylePadding?
|
let padding: PHThemeStylePadding?
|
||||||
|
let corner: PHThemeStyleCorner?
|
||||||
|
|
||||||
static let `default`: Self = {
|
static let `default`: Self = {
|
||||||
PHThemeStyle(
|
PHThemeStyle(
|
||||||
name: "_default",
|
name: "_default",
|
||||||
foreground: .init(color: "#000000", alpha: nil),
|
foreground: .init(color: "#000000", alpha: nil),
|
||||||
background: .init(color: "#ffffff", 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,7 +14,13 @@ struct TextBlockView: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
if let label = block.label, !label.isEmpty {
|
if let label = block.label, !label.isEmpty {
|
||||||
ZStack(alignment: .center) {
|
ZStack(alignment: .center) {
|
||||||
RoundedRectangle(cornerRadius: 0)
|
Group {
|
||||||
|
if let corner = block.style.corner {
|
||||||
|
RoundedRectangle(cornerRadius: corner.radius, style: corner.style)
|
||||||
|
} else {
|
||||||
|
Rectangle()
|
||||||
|
}
|
||||||
|
}
|
||||||
.foregroundStyle(block.style.background?.uiColor ?? .clear)
|
.foregroundStyle(block.style.background?.uiColor ?? .clear)
|
||||||
|
|
||||||
Group {
|
Group {
|
||||||
|
|||||||
Reference in New Issue
Block a user