aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2024-02-07 15:02:31 -0700
committerNavan Chauhan <navanchauhan@gmail.com>2024-02-07 15:02:31 -0700
commit6dff2cef31cc3aacc1589775d4dfbe31a79b87a2 (patch)
treebfcc2e8f95a31109ef098fea5a6130aa1524f34a
parent30e80066d426b15e2e3dc4c5ca5370a86bc8126f (diff)
format
-rw-r--r--iGopherBrowser/BookmarksView.swift37
-rw-r--r--iGopherBrowser/BrowserView.swift60
-rw-r--r--iGopherBrowser/SettingsView.swift29
-rw-r--r--iGopherBrowser/iGopherBrowserApp.swift2
4 files changed, 66 insertions, 62 deletions
diff --git a/iGopherBrowser/BookmarksView.swift b/iGopherBrowser/BookmarksView.swift
index 06307d1..b23196b 100644
--- a/iGopherBrowser/BookmarksView.swift
+++ b/iGopherBrowser/BookmarksView.swift
@@ -10,27 +10,28 @@ 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()
+
+ 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()
+ BookmarksView()
}
diff --git a/iGopherBrowser/BrowserView.swift b/iGopherBrowser/BrowserView.swift
index 29c28d0..e7f7dd3 100644
--- a/iGopherBrowser/BrowserView.swift
+++ b/iGopherBrowser/BrowserView.swift
@@ -277,27 +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)
- }
+ if shareThroughProxy {
+ ShareLink(item: URL(string: "https://gopher.navan.dev/\(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()
+ } 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: {
@@ -372,15 +372,15 @@ struct BrowserView: View {
}
//.background(Color.white)
.cornerRadius(30)
- 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)
- }
+ 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)
+ }
+ }
Button(
"Go",
action: {
@@ -403,8 +403,8 @@ struct BrowserView: View {
}
}
.onOpenURL { gopherURL in
- self.url = gopherURL.absoluteString
- performGopherRequest()
+ self.url = gopherURL.absoluteString
+ performGopherRequest()
}
.sheet(
isPresented: $showPreferences,
diff --git a/iGopherBrowser/SettingsView.swift b/iGopherBrowser/SettingsView.swift
index c2a5038..e3e1daf 100644
--- a/iGopherBrowser/SettingsView.swift
+++ b/iGopherBrowser/SettingsView.swift
@@ -21,7 +21,8 @@ extension Color: RawRepresentable {
let color =
try NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as? NSColor ?? .black
#else
- let color = try NSKeyedUnarchiver.unarchivedObject(ofClass: UIColor.self, from: data) ?? .black
+ let color =
+ try NSKeyedUnarchiver.unarchivedObject(ofClass: UIColor.self, from: data) ?? .black
#endif
self = Color(color)
} catch {
@@ -58,7 +59,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
+ @AppStorage("shareThroughProxy", store: .standard) var shareThroughProxy: Bool = true
#if os(macOS)
@AppStorage("homeURL") var homeURL: URL = URL(string: "gopher://gopher.navan.dev:70/")!
@@ -122,17 +123,19 @@ 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)
- }
+
+ 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()
diff --git a/iGopherBrowser/iGopherBrowserApp.swift b/iGopherBrowser/iGopherBrowserApp.swift
index 5698e82..e18d6f5 100644
--- a/iGopherBrowser/iGopherBrowserApp.swift
+++ b/iGopherBrowser/iGopherBrowserApp.swift
@@ -12,7 +12,7 @@ import TelemetryClient
struct iGopherBrowserApp: App {
var body: some Scene {
WindowGroup {
- ContentView()
+ ContentView()
}
.commands {
#if os(macOS)