aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2024-02-07 13:30:03 -0700
committerNavan Chauhan <navanchauhan@gmail.com>2024-02-07 13:30:03 -0700
commita22ff62c83717fb09285dbc66441b8b1c1583c68 (patch)
treea88b7bf252b4f7ba3f8f0df1628cca3370a1203f
parent11a99d4d14c9d1a83a03e12b151d372b11fa9e8e (diff)
add share button
-rw-r--r--iGopherBrowser/BookmarksView.swift36
-rw-r--r--iGopherBrowser/BrowserView.swift24
-rw-r--r--iGopherBrowser/SettingsView.swift12
3 files changed, 71 insertions, 1 deletions
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()