gemenon

[ACTIVE] The Safari of the Gemini ecosystem
git clone git://git.figbert.com/gemenon.git
Log | Files | Refs

commit 0fd5843561d2cb514325a3b4cbe35f69c7f2a6f5
parent 647c341494b2af5ac24ea5db7fab9f9ff40b77fc
Author: FIGBERT <figbert@figbert.com>
Date:   Mon, 17 Oct 2022 10:46:53 -0700

Add primitive reload button

Diffstat:
MShared/BrowserFunctions.swift | 3+++
MShared/ContentView.swift | 54+++++++++++++++++++++++++++++++++---------------------
Mtodo | 2+-
3 files changed, 37 insertions(+), 22 deletions(-)

diff --git a/Shared/BrowserFunctions.swift b/Shared/BrowserFunctions.swift @@ -21,6 +21,9 @@ class BrowserData: ObservableObject { } extension BrowserData { + func reload() async { + await self.openURL(self.tab.url!) + } func goToStartPage() { guard !self.tab.home else { return } self.tab = Tab(prev: self.tab) diff --git a/Shared/ContentView.swift b/Shared/ContentView.swift @@ -11,6 +11,7 @@ struct ContentView: View { @EnvironmentObject var data: BrowserData @State private var columnVisibility = NavigationSplitViewVisibility.detailOnly + @State private var hoveringURLBar = false var body: some View { NavigationSplitView(columnVisibility: $columnVisibility) { @@ -45,35 +46,46 @@ struct ContentView: View { } .toolbar { ToolbarItem(placement: .principal) { - TextField("Search or enter website name", text: $data.tab.urlBar) - .frame(minWidth: 500) - .textFieldStyle(.roundedBorder) - .autocorrectionDisabled(true) - .onSubmit { - Task { - if let url = URL(string: data.tab.urlBar) { - if var components = URLComponents(url: url, resolvingAgainstBaseURL: false) { - if components.scheme?.isEmpty ?? true { - if components.host?.isEmpty ?? true { - let index = components.path.firstIndex(of: "/") ?? components.path.endIndex - components.host = String(components.path[..<index]) - components.path = String(components.path[index...]) + ZStack(alignment: .trailing) { + TextField("Search or enter website name", text: $data.tab.urlBar) + .frame(minWidth: 500) + .textFieldStyle(.roundedBorder) + .autocorrectionDisabled(true) + .onHover(perform: { hovering in hoveringURLBar = hovering }) + .onSubmit { + Task { + if let url = URL(string: data.tab.urlBar) { + if var components = URLComponents(url: url, resolvingAgainstBaseURL: false) { + if components.scheme?.isEmpty ?? true { + if components.host?.isEmpty ?? true { + let index = components.path.firstIndex(of: "/") ?? components.path.endIndex + components.host = String(components.path[..<index]) + components.path = String(components.path[index...]) + } + components.scheme = "gemini" + } + if let url = components.url { + await data.openURL(url) } - components.scheme = "gemini" } - if let url = components.url { + } else { + var components = URLComponents(string: "gemini://geminispace.info/search") + components?.query = data.tab.urlBar + if let url = components?.url { await data.openURL(url) } } - } else { - var components = URLComponents(string: "gemini://geminispace.info/search") - components?.query = data.tab.urlBar - if let url = components?.url { - await data.openURL(url) - } } } + if data.tab.response != nil && hoveringURLBar { + Button(action: { Task { await data.reload() } }) { + Label("Reload page", systemImage: "arrow.clockwise") + .labelStyle(.iconOnly) + } + .buttonStyle(.borderless) + .padding(.trailing, 8) } + } } ToolbarItem(placement: .navigation) { Button(action: { data.goToStartPage() }) { diff --git a/todo b/todo @@ -2,7 +2,7 @@ [ ] TOFU [ ] ANSI in preformatted blocks [ ] bookmarks/favorites -[ ] reload page +[X] reload page [ ] share menu (link?) [ ] better home/startpage [ ] settings/preferences