make styles optional in theme
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
struct PHTheme: Decodable {
|
struct PHTheme: Decodable {
|
||||||
let window: PHThemeWindow
|
let window: PHThemeWindow
|
||||||
let texts: [PHThemeText]?
|
let texts: [PHThemeText]?
|
||||||
let styles: [PHThemeStyle]
|
let styles: [PHThemeStyle]?
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case window
|
case window
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ extension BarController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func style(for block: PHBlock) -> PHThemeStyle {
|
func style(for block: PHBlock) -> PHThemeStyle {
|
||||||
guard let style = theme.styles.first(where: { $0.name == block.styleName }) else {
|
guard let style = theme.styles?.first(where: { $0.name == block.styleName }) else {
|
||||||
guard let defaultStyle = theme.styles.first(where: { $0.name == "default" }) else {
|
guard let defaultStyle = theme.styles?.first(where: { $0.name == "default" }) else {
|
||||||
return PHThemeStyle.default
|
return PHThemeStyle.default
|
||||||
}
|
}
|
||||||
return defaultStyle
|
return defaultStyle
|
||||||
|
|||||||
Reference in New Issue
Block a user