Skip to content

Commit

Permalink
Use same variable for status bar color as frontend (#2757)
Browse files Browse the repository at this point in the history
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->

## Summary
<!-- Provide a brief summary of the changes you have made and most
importantly what they aim to achieve -->
We were using `--app-header-background-color` for status bar in the app
and frontend uses `--app-theme-color`, this PR changes that to keep
consistency with frontend

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->

## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
<!-- If there is any other information of note, like if this Pull
Request is part of a bigger change, please include it here. -->
  • Loading branch information
bgoncal committed May 7, 2024
1 parent 9a83285 commit 71e5dd8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions Sources/App/Resources/WebSocketBridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const notifyThemeColors = () => {

[
'--app-header-background-color',
'--app-theme-color',
'--primary-background-color',
'--text-primary-color',
'--primary-color',
Expand Down
2 changes: 2 additions & 0 deletions Sources/App/Utilities/ThemeColors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public struct ThemeColors: Codable {
public enum Color: String, CaseIterable {
// these are in WebSocketBridge.js in this repo (we inject it)
case appHeaderBackgroundColor = "--app-header-background-color"
case appThemeColor = "--app-theme-color"
case primaryBackgroundColor = "--primary-background-color"
case textPrimaryColor = "--text-primary-color"
case primaryColor = "--primary-color"
Expand Down Expand Up @@ -77,6 +78,7 @@ private extension ThemeColors.Color {
case .primaryBackgroundColor: return UIColor(red: 0.98, green: 0.98, blue: 0.98, alpha: 1.0)
case .primaryColor: return UIColor.white
case .textPrimaryColor: return UIColor.white
case .appThemeColor: return UIColor(red: 0.01, green: 0.66, blue: 0.96, alpha: 1.0)
}
}
}
4 changes: 2 additions & 2 deletions Sources/App/WebView/WebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,12 @@ final class WebViewController: UIViewController, WKNavigationDelegate, WKUIDeleg
webView?.scrollView.backgroundColor = cachedColors[.primaryBackgroundColor]

if let statusBarView = view.viewWithTag(111) {
statusBarView.backgroundColor = cachedColors[.appHeaderBackgroundColor]
statusBarView.backgroundColor = cachedColors[.appThemeColor]
}

refreshControl.tintColor = cachedColors[.primaryColor]

let headerBackgroundIsLight = cachedColors[.appHeaderBackgroundColor].isLight
let headerBackgroundIsLight = cachedColors[.appThemeColor].isLight
underlyingPreferredStatusBarStyle = headerBackgroundIsLight ? .darkContent : .lightContent

setNeedsStatusBarAppearanceUpdate()
Expand Down

0 comments on commit 71e5dd8

Please sign in to comment.