commit b8039db3f0a6a268bd3b2e7c59f50bb014f5b174
parent c59c43aba6f404adc6ce14565834aee2948ead2b
Author: FIGBERT <figbert@figbert.com>
Date: Mon, 17 Oct 2022 11:15:15 -0700
Use overylay modifier for reload button
Diffstat:
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/Shared/ContentView.swift b/Shared/ContentView.swift
@@ -46,22 +46,13 @@ struct ContentView: View {
}
.toolbar {
ToolbarItem(placement: .principal) {
- 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 { await submitURLBar() } }
- 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)
- }
- }
+ 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 { await submitURLBar() } }
+ .overlay(reloadButton, alignment: .trailing)
}
ToolbarItem(placement: .navigation) {
Button(action: { data.goToStartPage() }) {
@@ -90,6 +81,17 @@ struct ContentView: View {
})
}
+ @ViewBuilder private var reloadButton: some View {
+ 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)
+ }
+ }
+
private func submitURLBar() async {
if let url = URL(string: data.tab.urlBar) {
if var components = URLComponents(url: url, resolvingAgainstBaseURL: false) {