commit b5d0cf5b52b2b11191117629782c5ff8d8ded73e
parent 78d06cd6d15e70ff6cc3b6ebc0dcf18776d41584
Author: FIGBERT <figbert@figbert.com>
Date: Tue, 18 Oct 2022 14:34:00 -0700
Add ProgressView when loading requests
Diffstat:
3 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/Shared/BrowserFunctions.swift b/Shared/BrowserFunctions.swift
@@ -12,6 +12,7 @@ import SwiftGemtext
@MainActor
class BrowserData: ObservableObject {
@Published var tab = Tab()
+ @Published var loading = false
@Published var currentView: GemenonView = .Capsule
@Published var views: [GemenonView] = [.Capsule, .History]
@@ -40,10 +41,12 @@ extension BrowserData {
extension BrowserData {
func openURL(_ url: URL) async {
+ self.loading = true
let response = try! await self.engine.request(url)
self.tab = Tab(url, prev: self.tab, response: response)
self.tab.prev?.next = self.tab
self.currentView = .Capsule
+ self.loading = false
}
}
diff --git a/Shared/ContentView.swift b/Shared/ContentView.swift
@@ -52,7 +52,10 @@ struct ContentView: View {
.autocorrectionDisabled(true)
.onHover(perform: { hovering in hoveringURLBar = hovering })
.onSubmit { Task { await submitURLBar() } }
- .overlay(reloadButton, alignment: .trailing)
+ .overlay(HStack {
+ reloadButton
+ loading
+ }, alignment: .trailing)
}
ToolbarItem(placement: .navigation) {
Button(action: { data.goToStartPage() }) {
@@ -95,7 +98,14 @@ struct ContentView: View {
.labelStyle(.iconOnly)
}
.buttonStyle(.borderless)
- .padding(.trailing, 8)
+ .padding(.trailing, data.loading ? 2 : 8)
+ }
+ }
+ @ViewBuilder private var loading: some View {
+ if data.loading {
+ ProgressView()
+ .scaleEffect(0.5)
+ .padding(.trailing, 4)
}
}
diff --git a/todo b/todo
@@ -20,4 +20,4 @@
[ ] table of contents for pages
[ ] search in pages
[ ] persist history
-[ ] page load ui
+[X] page load ui