Workaround for invalid opaque background color decoding

This commit is contained in:
Ali
2021-06-15 12:03:12 +04:00
parent c06ed7062f
commit 3dd5e94715
3 changed files with 30 additions and 7 deletions

View File

@@ -428,6 +428,13 @@ extension PresentationThemeRootNavigationBar: Codable {
let values = try decoder.container(keyedBy: CodingKeys.self)
let blurredBackgroundColor = try decodeColor(values, .background)
let opaqueBackgroundColor: UIColor
if blurredBackgroundColor.alpha >= 0.99 {
opaqueBackgroundColor = blurredBackgroundColor
} else {
opaqueBackgroundColor = (try? decodeColor(values, .opaqueBackground)) ?? blurredBackgroundColor
}
self.init(
buttonColor: try decodeColor(values, .button),
disabledButtonColor: try decodeColor(values, .disabledButton),
@@ -436,7 +443,7 @@ extension PresentationThemeRootNavigationBar: Codable {
controlColor: try decodeColor(values, .control),
accentTextColor: try decodeColor(values, .accentText),
blurredBackgroundColor: blurredBackgroundColor,
opaqueBackgroundColor: (try? decodeColor(values, .opaqueBackground)) ?? blurredBackgroundColor.withAlphaComponent(1.0),
opaqueBackgroundColor: opaqueBackgroundColor,
separatorColor: try decodeColor(values, .separator),
badgeBackgroundColor: try decodeColor(values, .badgeFill),
badgeStrokeColor: try decodeColor(values, .badgeStroke),