Skip to content

Commit 4f526b7

Browse files
authored
Improve native loader UI (#5126)
<!-- 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 --> - Include server it is loading - Include icon representation of type of URL ## 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. -->
1 parent 5355bb2 commit 4f526b7

7 files changed

Lines changed: 388 additions & 70 deletions

File tree

Sources/App/Frontend/Extensions/WebViewGestureHandler.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,7 @@ final class WebViewGestureHandler {
142142
let nextServer = servers[nextIndex]
143143

144144
Current.sceneManager.appCoordinator.done { coordinator in
145-
coordinator.open(server: nextServer).done { frontend in
146-
guard let window = frontend.presentationWindow else { return }
147-
let hud = ProgressHUD.showAdded(to: window, animated: true)
148-
hud.isUserInteractionEnabled = false
149-
hud.mode = .text
150-
hud.label.text = nextServer.info.name
151-
hud.hide(animated: true, afterDelay: 1.0)
152-
}
145+
coordinator.open(server: nextServer)
153146
}
154147
}
155148
}

Sources/App/Frontend/WebView/HomeAssistantView/HomeAssistantView.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ struct HomeAssistantView: View, WebFrontendView {
1616
)
1717
}
1818

19-
// The themed status-bar strip is rendered outside the web-view opacity group so reloads don't blink or
20-
// resize it. It keeps the last frontend-provided colour until WebKit sends a new theme-colour update.
19+
// The themed status-bar strip keeps the last frontend-provided colour until WebKit sends a new update.
2120
private var themedStatusBar: some View {
2221
GeometryReader { proxy in
2322
if let color = viewModel.overlayState.statusBarColor {
@@ -32,15 +31,15 @@ struct HomeAssistantView: View, WebFrontendView {
3231

3332
var body: some View {
3433
ZStack {
35-
themedStatusBar
36-
// The web content group is separate from the standby overlay and status-bar strip so those layers can
37-
// stay stable while the frontend reloads.
34+
// The frontend content group is separate from the standby overlay so it can fade with pull-to-refresh and
35+
// reloads.
3836
ZStack(alignment: .topLeading) {
37+
themedStatusBar
3938
homeAssistant
4039
pullToRefreshIndicator
4140
macTitleBar
4241
}
43-
.opacity(viewModel.contentOpacity)
42+
.opacity(viewModel.webViewContentOpacity)
4443
noActiveURLState
4544
standByView
4645
}

Sources/App/Frontend/WebView/HomeAssistantView/HomeAssistantViewModel.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ final class HomeAssistantViewModel: ObservableObject {
7272
isFullScreenLoaderMounted || overlayState.emptyState != nil
7373
}
7474

75+
var webViewContentOpacity: Double {
76+
if overlayState.emptyState != nil || isFullScreenLoaderVisible || isPullToRefreshActive {
77+
return 0
78+
}
79+
80+
guard pullToRefreshProgress > 0 else { return contentOpacity }
81+
return contentOpacity * Double(1 - min(1, max(0, pullToRefreshProgress)))
82+
}
83+
7584
var showsPullToRefresh: Bool {
7685
pullToRefreshProgress > 0 || isPullToRefreshActive
7786
}

0 commit comments

Comments
 (0)