make colors and padding optional
This commit is contained in:
@@ -1,10 +1,9 @@
|
|||||||
struct PHThemePadding: Decodable {
|
struct PHThemePadding: Decodable {
|
||||||
let leading: Double
|
let trailing: Double?
|
||||||
let trailing: Double
|
let leading: Double?
|
||||||
|
|
||||||
var total: Double { leading + trailing }
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case trailing = "right"
|
||||||
static var zero: PHThemePadding {
|
case leading = "left"
|
||||||
Self.init(leading: 0, trailing: 0)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
struct PHThemeStyle: Decodable {
|
struct PHThemeStyle: Decodable {
|
||||||
let name: String
|
let name: String
|
||||||
let foreground: PHThemeColor
|
let foreground: PHThemeColor?
|
||||||
let background: PHThemeColor
|
let background: PHThemeColor?
|
||||||
let padding: PHThemePadding
|
let padding: PHThemePadding?
|
||||||
|
|
||||||
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: 10, trailing: 10)
|
padding: .init(trailing: 12, leading: 12)
|
||||||
)
|
)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,16 +10,13 @@ blur = 0.0
|
|||||||
name = "default"
|
name = "default"
|
||||||
foreground = { color = "#aed3f3" }
|
foreground = { color = "#aed3f3" }
|
||||||
background = { color = "#010408", alpha = 0.825 }
|
background = { color = "#010408", alpha = 0.825 }
|
||||||
padding = { leading = 0.0, trailing = 0.0 }
|
|
||||||
|
|
||||||
[[style]]
|
[[style]]
|
||||||
name = "floating"
|
name = "floating"
|
||||||
foreground = { color = "#aed3f3" }
|
foreground = { color = "#aed3f3" }
|
||||||
background = { color = "#000000", alpha = 0 }
|
|
||||||
padding = { leading = 0.0, trailing = 0.0 }
|
|
||||||
|
|
||||||
[[style]]
|
[[style]]
|
||||||
name = "tinted"
|
name = "tinted"
|
||||||
foreground = { color = "#aed3f3" }
|
foreground = { color = "#aed3f3" }
|
||||||
background = { color = "#0f304a" }
|
background = { color = "#0f304a" }
|
||||||
padding = { leading = 12.0, trailing = 12.0 }
|
padding = { left = 12.0, right = 12.0 }
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ struct SpaceBlockView: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Rectangle()
|
Rectangle()
|
||||||
.fill(block.style.background)
|
.fill(block.style.background?.uiColor ?? .clear)
|
||||||
.frame(width: width)
|
.frame(width: width)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,16 +15,16 @@ struct TextBlockView: View {
|
|||||||
if let label = block.label, !label.isEmpty {
|
if let label = block.label, !label.isEmpty {
|
||||||
ZStack(alignment: .center) {
|
ZStack(alignment: .center) {
|
||||||
RoundedRectangle(cornerRadius: 0)
|
RoundedRectangle(cornerRadius: 0)
|
||||||
.fill(block.style.background)
|
.foregroundStyle(block.style.background?.uiColor ?? .clear)
|
||||||
|
|
||||||
Group {
|
Group {
|
||||||
Text(label)
|
Text(label)
|
||||||
.foregroundStyle(block.style.foreground)
|
.foregroundStyle(block.style.foreground?.uiColor ?? .clear)
|
||||||
.transformEffect(adjustOffset)
|
.transformEffect(adjustOffset)
|
||||||
.border(bar.debug ? .blue : .clear)
|
.border(bar.debug ? .blue : .clear)
|
||||||
}
|
}
|
||||||
.padding(.leading, block.style.padding.leading)
|
.padding(.trailing, block.style.padding?.trailing ?? 0)
|
||||||
.padding(.trailing, block.style.padding.trailing)
|
.padding(.leading, block.style.padding?.leading ?? 0)
|
||||||
}
|
}
|
||||||
.fixedSize(horizontal: true, vertical: false)
|
.fixedSize(horizontal: true, vertical: false)
|
||||||
.border(bar.debug ? .red : .clear)
|
.border(bar.debug ? .red : .clear)
|
||||||
|
|||||||
Reference in New Issue
Block a user