From a22ff62c83717fb09285dbc66441b8b1c1583c68 Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Wed, 7 Feb 2024 13:30:03 -0700 Subject: add share button --- iGopherBrowser/BookmarksView.swift | 36 ++++++++++++++++++++++++++++++++++++ iGopherBrowser/BrowserView.swift | 24 +++++++++++++++++++++++- iGopherBrowser/SettingsView.swift | 12 ++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 iGopherBrowser/BookmarksView.swift diff --git a/iGopherBrowser/BookmarksView.swift b/iGopherBrowser/BookmarksView.swift new file mode 100644 index 0000000..06307d1 --- /dev/null +++ b/iGopherBrowser/BookmarksView.swift @@ -0,0 +1,36 @@ +// +// BookmarksView.swift +// iGopherBrowser +// +// Created by Navan Chauhan on 2/7/24. +// + +import SwiftUI + +// Bookmarks and History Sheet + +struct BookmarksView: View { + + enum sectionType: String, CaseIterable, Identifiable { + case bookmarks, history + var id: Self {self} + } + + @State private var selectedSection: sectionType = .bookmarks + + var body: some View { + VStack { + Picker("Section", selection: $selectedSection) { + ForEach(sectionType.allCases) { section in + Text(section.rawValue.capitalized) + } + }.pickerStyle(.segmented).padding(.top, 20).padding(.leading, 10).padding(.trailing, 10).padding(.bottom, 10) + Text("You picked \(selectedSection.rawValue.capitalized)") + Spacer() + } + } +} + +#Preview { + BookmarksView() +} diff --git a/iGopherBrowser/BrowserView.swift b/iGopherBrowser/BrowserView.swift index 1ba869c..f745fc8 100644 --- a/iGopherBrowser/BrowserView.swift +++ b/iGopherBrowser/BrowserView.swift @@ -31,6 +31,7 @@ struct BrowserView: View { @AppStorage("homeURL") var homeURL: URL = URL(string: "gopher://gopher.navan.dev:70/")! @AppStorage("accentColour", store: .standard) var accentColour: Color = Color(.blue) @AppStorage("linkColour", store: .standard) var linkColour: Color = Color(.white) + @AppStorage("shareThroughProxy", store: .standard) var shareThroughProxy: Bool = true @State var homeURLString = "gopher://gopher.navan.dev:70/" @@ -48,6 +49,7 @@ struct BrowserView: View { @State var selectedSearchItem: Int? @State private var showPreferences = false + @State private var showBookmarks = false @Namespace var topID @State private var scrollToTop: Bool = false @@ -147,7 +149,6 @@ struct BrowserView: View { } }.id(topID) - .background(Color.white) .cornerRadius(10) .onChange(of: scrollToTop) { @@ -276,6 +277,27 @@ struct BrowserView: View { } .disabled(forwardStack.isEmpty) Spacer() + if (shareThroughProxy) { + ShareLink(item: URL(string: "https://gopher.navan.dev/\(url)")!) { + Label("Share", systemImage: "square.and.arrow.up").labelStyle(.iconOnly) + } + } else { + ShareLink(item: URL(string: "gopher://\(url)")!) { + Label("Share", systemImage: "square.and.arrow.up").labelStyle(.iconOnly) + } + } + Spacer() +// Button { +// showBookmarks = true +// } label: { +// Label("Bookmarks", systemImage: "book") +// .labelStyle(.iconOnly) +// }.sheet(isPresented: $showBookmarks) { +// BookmarksView() +// .presentationDetents([.height(400), .medium, .large]) +// .presentationDragIndicator(.automatic) +// } +// Spacer() Button { self.showPreferences = true } label: { diff --git a/iGopherBrowser/SettingsView.swift b/iGopherBrowser/SettingsView.swift index 11081a3..c2a5038 100644 --- a/iGopherBrowser/SettingsView.swift +++ b/iGopherBrowser/SettingsView.swift @@ -58,6 +58,7 @@ struct SettingsView: View { @AppStorage("accentColour", store: .standard) var accentColour: Color = Color(.blue) @AppStorage("linkColour", store: .standard) var linkColour: Color = Color(.white) + @AppStorage("shareThroughProxy", store: .standard) var shareThroughProxy: Bool = true #if os(macOS) @AppStorage("homeURL") var homeURL: URL = URL(string: "gopher://gopher.navan.dev:70/")! @@ -121,6 +122,17 @@ struct SettingsView: View { self.accentColour = Color(.blue) } } + + Section { + Toggle("Share links through HTTP(s) proxy", isOn: $shareThroughProxy) + .toggleStyle(.switch) + } header: { + Text("Share Settings") + } footer: { + Text("Enabling this option shares Gopher URLs through an HTTP proxy, allowing people to view the page without needing a Gopher client") + .font(.caption) + .foregroundColor(.gray) + } #if os(visionOS) Button("Done") { dismiss() -- cgit v1.2.3