From 205c8ea9b2c6dfa62bc8b2342d1aa71e2da7d6ac Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Tue, 14 Apr 2026 10:42:05 -0500 Subject: fix: remove prototype screens from developer menu - removed prototype screens - limited Recent section to 3 items - added initial support for tips Fixes: https://todo.sr.ht/~ccleberg/hutch/65 --- Hutch.xcodeproj/project.pbxproj | 16 ++-- Hutch/App/RootView.swift | 3 + Hutch/Views/Home/HomePrototypeView.swift | 7 -- Hutch/Views/Home/HomeView.swift | 2 +- Hutch/Views/Lookup/LookupView.swift | 2 + Hutch/Views/More/AboutView.swift | 146 +++++++++++++++++++++++++++++++ Hutch/Views/More/MoreView.swift | 5 ++ Hutch/Views/More/TipStoreViewModel.swift | 44 ++++++++++ Hutch/Views/Settings/SettingsView.swift | 134 ---------------------------- Hutch/Views/Work/WorkPrototypeView.swift | 7 -- 10 files changed, 209 insertions(+), 157 deletions(-) delete mode 100644 Hutch/Views/Home/HomePrototypeView.swift create mode 100644 Hutch/Views/More/AboutView.swift create mode 100644 Hutch/Views/More/TipStoreViewModel.swift delete mode 100644 Hutch/Views/Work/WorkPrototypeView.swift diff --git a/Hutch.xcodeproj/project.pbxproj b/Hutch.xcodeproj/project.pbxproj index 68ef58c..100148c 100644 --- a/Hutch.xcodeproj/project.pbxproj +++ b/Hutch.xcodeproj/project.pbxproj @@ -515,7 +515,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = Hutch/Hutch.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 73; + CURRENT_PROJECT_VERSION = 74; DEVELOPMENT_TEAM = ZCNAX3VL9D; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; @@ -532,7 +532,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 3.1.5; + MARKETING_VERSION = 3.1.6; PRODUCT_BUNDLE_IDENTIFIER = net.cleberg.Hutch; PRODUCT_NAME = "$(TARGET_NAME)"; STRING_CATALOG_GENERATE_SYMBOLS = YES; @@ -552,7 +552,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = Hutch/Hutch.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 73; + CURRENT_PROJECT_VERSION = 74; DEVELOPMENT_TEAM = ZCNAX3VL9D; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; @@ -569,7 +569,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 3.1.5; + MARKETING_VERSION = 3.1.6; PRODUCT_BUNDLE_IDENTIFIER = net.cleberg.Hutch; PRODUCT_NAME = "$(TARGET_NAME)"; STRING_CATALOG_GENERATE_SYMBOLS = YES; @@ -632,7 +632,7 @@ APPLICATION_EXTENSION_API_ONLY = YES; CODE_SIGN_ENTITLEMENTS = HutchWidgetExtension/HutchWidgetExtension.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 73; + CURRENT_PROJECT_VERSION = 74; DEVELOPMENT_TEAM = ZCNAX3VL9D; GENERATE_INFOPLIST_FILE = NO; INFOPLIST_FILE = HutchWidgetExtension/Info.plist; @@ -642,7 +642,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 3.1.5; + MARKETING_VERSION = 3.1.6; PRODUCT_BUNDLE_IDENTIFIER = net.cleberg.Hutch.HutchWidgetExtension; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -661,7 +661,7 @@ APPLICATION_EXTENSION_API_ONLY = YES; CODE_SIGN_ENTITLEMENTS = HutchWidgetExtension/HutchWidgetExtension.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 73; + CURRENT_PROJECT_VERSION = 74; DEVELOPMENT_TEAM = ZCNAX3VL9D; GENERATE_INFOPLIST_FILE = NO; INFOPLIST_FILE = HutchWidgetExtension/Info.plist; @@ -671,7 +671,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 3.1.5; + MARKETING_VERSION = 3.1.6; PRODUCT_BUNDLE_IDENTIFIER = net.cleberg.Hutch.HutchWidgetExtension; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; diff --git a/Hutch/App/RootView.swift b/Hutch/App/RootView.swift index ed029bb..ac20f0c 100644 --- a/Hutch/App/RootView.swift +++ b/Hutch/App/RootView.swift @@ -336,6 +336,7 @@ enum MoreRoute: Hashable { case profile case systemStatus case settings + case about case mailingList(InboxMailingListReference) case thread(InboxThreadSummary) case manPageBrowser @@ -363,6 +364,8 @@ private struct MoreNavigationRoot: View { SystemStatusView() case .settings: SettingsView() + case .about: + AboutView() case .mailingList(let mailingList): MailingListDetailView(mailingList: mailingList) case .thread(let thread): diff --git a/Hutch/Views/Home/HomePrototypeView.swift b/Hutch/Views/Home/HomePrototypeView.swift deleted file mode 100644 index 77c360a..0000000 --- a/Hutch/Views/Home/HomePrototypeView.swift +++ /dev/null @@ -1,7 +0,0 @@ -import SwiftUI - -struct HomePrototypeView: View { - var body: some View { - HomeView() - } -} diff --git a/Hutch/Views/Home/HomeView.swift b/Hutch/Views/Home/HomeView.swift index b4b809d..fa7de86 100644 --- a/Hutch/Views/Home/HomeView.swift +++ b/Hutch/Views/Home/HomeView.swift @@ -118,7 +118,7 @@ struct HomeView: View { private var recentSection: some View { if !recentItems.isEmpty { Section("Recent") { - ForEach(recentItems) { item in + ForEach(recentItems.prefix(3)) { item in Button { openRecentItem(item) } label: { diff --git a/Hutch/Views/Lookup/LookupView.swift b/Hutch/Views/Lookup/LookupView.swift index 64ca39d..f464da5 100644 --- a/Hutch/Views/Lookup/LookupView.swift +++ b/Hutch/Views/Lookup/LookupView.swift @@ -441,6 +441,8 @@ struct LookupView: View { SystemStatusView() case .settings: SettingsView() + case .about: + AboutView() case .mailingList(let mailingList): MailingListDetailView(mailingList: mailingList) case .thread(let thread): diff --git a/Hutch/Views/More/AboutView.swift b/Hutch/Views/More/AboutView.swift new file mode 100644 index 0000000..887bef1 --- /dev/null +++ b/Hutch/Views/More/AboutView.swift @@ -0,0 +1,146 @@ +import StoreKit +import SwiftUI + +struct AboutView: View { + @Environment(AppState.self) private var appState + private let appName = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String + ?? Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String + ?? "Hutch" + private let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String + ?? "Unknown" + private let build = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String + ?? "Unknown" + @State private var developerRevealCount = 0 + @State private var storeViewModel = TipStoreViewModel() + + private var developerToolsVisible: Bool { + appState.isDebugModeEnabled || developerRevealCount >= 5 + } + + private var developerRevealFooterText: String { + developerRevealCount >= 5 + ? "Debug toggle unlocked. Scroll down to Developer to enable it." + : "Tap the build number 5 times to reveal the debug toggle." + } + + var body: some View { + Form { + Section { + VStack(alignment: .leading, spacing: 6) { + Text(appName) + .font(.title2.weight(.semibold)) + Text("A native SourceHut client for iOS.") + .font(.subheadline) + .foregroundStyle(.secondary) + } + .padding(.vertical, 4) + .themedRow() + + LabeledContent("Version", value: version) + .onTapGesture { + developerRevealCount = min(developerRevealCount + 1, 5) + } + .themedRow() + LabeledContent("Build", value: build) + .onTapGesture { + developerRevealCount = min(developerRevealCount + 1, 5) + } + .themedRow() + } footer: { + Text(developerRevealFooterText) + } + + Section("Links") { + Link(destination: URL(string: "https://sr.ht")!) { + SwiftUI.Label("SourceHut", systemImage: "link") + } + .themedRow() + Link(destination: URL(string: "https://man.sr.ht")!) { + SwiftUI.Label("SourceHut Manuals", systemImage: "book") + } + .themedRow() + Link(destination: URL(string: "https://sr.ht/~ccleberg/Hutch")!) { + SwiftUI.Label("Project Repository", systemImage: "folder") + } + .themedRow() + } + + Section("Support") { + Link(destination: URL(string: "mailto:hello@cleberg.net")!) { + SwiftUI.Label("Email Support", systemImage: "envelope") + } + .themedRow() + } + + Section("Privacy") { + Text("Hutch uses your SourceHut personal access token to make requests on your behalf. The token is stored locally in the iOS keychain.") + .font(.subheadline) + .foregroundStyle(.secondary) + .themedRow() + + Link(destination: URL(string: "https://zerolabs.sh/hutch/privacy-policy/")!) { + SwiftUI.Label("Privacy Policy", systemImage: "hand.raised") + } + .themedRow() + } + + Section("Acknowledgements") { + Text("Built for SourceHut users who want quick access to repositories, builds, and tickets on iOS.") + .font(.subheadline) + .foregroundStyle(.secondary) + .themedRow() + } + + Section { + if storeViewModel.isLoading { + ProgressView() + .themedRow() + } else if storeViewModel.products.isEmpty { + Text("Tips unavailable") + .foregroundStyle(.secondary) + .themedRow() + } else { + ForEach(storeViewModel.products, id: \.id) { product in + Button { + Task { + await storeViewModel.purchase(product) + } + } label: { + HStack { + Text(product.displayName) + Spacer() + Text(product.displayPrice) + .foregroundStyle(.secondary) + } + } + .themedRow() + } + } + } header: { + Text("Support Development") + } footer: { + Text("Tips help cover the costs of development and App Store distribution. They are one-time purchases and do not unlock any features.") + } + + if developerToolsVisible { + Section { + Toggle("Debug Mode", isOn: Binding( + get: { appState.isDebugModeEnabled }, + set: { appState.isDebugModeEnabled = $0 } + )) + .themedRow() + } header: { + Text("Developer") + } footer: { + Text("Shows raw API payloads and diagnostic details on builds and tickets screens. This stays hidden until explicitly enabled.") + } + } + } + .themedList() + .navigationTitle("About") + .navigationBarTitleDisplayMode(.inline) + .task { + await storeViewModel.loadProducts() + } + } +} diff --git a/Hutch/Views/More/MoreView.swift b/Hutch/Views/More/MoreView.swift index 4666e53..5c757ef 100644 --- a/Hutch/Views/More/MoreView.swift +++ b/Hutch/Views/More/MoreView.swift @@ -61,6 +61,11 @@ struct MoreView: View { Label("Settings", systemImage: "gear") } .themedRow() + + NavigationLink(value: MoreRoute.about) { + Label("About Hutch", systemImage: "info.circle") + } + .themedRow() } Section { diff --git a/Hutch/Views/More/TipStoreViewModel.swift b/Hutch/Views/More/TipStoreViewModel.swift new file mode 100644 index 0000000..54868ba --- /dev/null +++ b/Hutch/Views/More/TipStoreViewModel.swift @@ -0,0 +1,44 @@ +import StoreKit + +@Observable +final class TipStoreViewModel { + var products: [Product] = [] + var isLoading = false + var errorMessage: String? + + private let productIDs = [ + "net.cleberg.hutch.tip.small", + "net.cleberg.hutch.tip.medium", + "net.cleberg.hutch.tip.large" + ] + + func loadProducts() async { + isLoading = true + defer { isLoading = false } + do { + let fetched = try await Product.products(for: productIDs) + // Sort by price ascending to maintain small/medium/large order + products = fetched.sorted { $0.price < $1.price } + } catch { + errorMessage = error.localizedDescription + } + } + + func purchase(_ product: Product) async { + do { + let result = try await product.purchase() + switch result { + case .success(let verification): + if case .verified(let transaction) = verification { + await transaction.finish() + } + case .userCancelled, .pending: + break + @unknown default: + break + } + } catch { + errorMessage = error.localizedDescription + } + } +} diff --git a/Hutch/Views/Settings/SettingsView.swift b/Hutch/Views/Settings/SettingsView.swift index 577de8a..0046f92 100644 --- a/Hutch/Views/Settings/SettingsView.swift +++ b/Hutch/Views/Settings/SettingsView.swift @@ -14,7 +14,6 @@ struct SettingsView: View { appearanceSection() behaviorSection() authenticationSection() - aboutSection() } .themedList() .navigationTitle("Settings") @@ -142,17 +141,6 @@ struct SettingsView: View { } } - @ViewBuilder - private func aboutSection() -> some View { - Section("App") { - NavigationLink { - AboutView() - } label: { - SwiftUI.Label("About Hutch", systemImage: "info.circle") - } - .themedRow() - } - } } func settingsBioAttributedString(_ markdown: String) -> AttributedString { @@ -191,125 +179,3 @@ private enum SettingsDestructiveAction { } } -private struct AboutView: View { - @Environment(AppState.self) private var appState - private let appName = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String - ?? Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String - ?? "Hutch" - private let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String - ?? "Unknown" - private let build = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String - ?? "Unknown" - @State private var developerRevealCount = 0 - - private var developerToolsVisible: Bool { - appState.isDebugModeEnabled || developerRevealCount >= 5 - } - - private var developerRevealFooterText: String { - developerRevealCount >= 5 - ? "Debug toggle unlocked. Scroll down to Developer to enable it." - : "Tap the build number 5 times to reveal the debug toggle." - } - - var body: some View { - Form { - Section { - VStack(alignment: .leading, spacing: 6) { - Text(appName) - .font(.title2.weight(.semibold)) - Text("A native SourceHut client for iOS.") - .font(.subheadline) - .foregroundStyle(.secondary) - } - .padding(.vertical, 4) - .themedRow() - - LabeledContent("Version", value: version) - .onTapGesture { - developerRevealCount = min(developerRevealCount + 1, 5) - } - .themedRow() - LabeledContent("Build", value: build) - .onTapGesture { - developerRevealCount = min(developerRevealCount + 1, 5) - } - .themedRow() - } footer: { - Text(developerRevealFooterText) - } - - Section("Links") { - Link(destination: URL(string: "https://sr.ht")!) { - SwiftUI.Label("SourceHut", systemImage: "link") - } - .themedRow() - Link(destination: URL(string: "https://man.sr.ht")!) { - SwiftUI.Label("SourceHut Manuals", systemImage: "book") - } - .themedRow() - Link(destination: URL(string: "https://sr.ht/~ccleberg/Hutch")!) { - SwiftUI.Label("Project Repository", systemImage: "folder") - } - .themedRow() - } - - Section("Support") { - Link(destination: URL(string: "mailto:hello@cleberg.net")!) { - SwiftUI.Label("Email Support", systemImage: "envelope") - } - .themedRow() - } - - Section("Privacy") { - Text("Hutch uses your SourceHut personal access token to make requests on your behalf. The token is stored locally in the iOS keychain.") - .font(.subheadline) - .foregroundStyle(.secondary) - .themedRow() - - Link(destination: URL(string: "https://zerolabs.sh/hutch/privacy-policy/")!) { - SwiftUI.Label("Privacy Policy", systemImage: "hand.raised") - } - .themedRow() - } - - Section("Acknowledgements") { - Text("Built for SourceHut users who want quick access to repositories, builds, and tickets on iOS.") - .font(.subheadline) - .foregroundStyle(.secondary) - .themedRow() - } - - if developerToolsVisible { - Section { - Toggle("Debug Mode", isOn: Binding( - get: { appState.isDebugModeEnabled }, - set: { appState.isDebugModeEnabled = $0 } - )) - .themedRow() - - NavigationLink { - HomePrototypeView() - } label: { - SwiftUI.Label("Home Prototype", systemImage: "house") - } - .themedRow() - - NavigationLink { - WorkPrototypeView() - } label: { - SwiftUI.Label("Work Prototype", systemImage: "tray.full") - } - .themedRow() - } header: { - Text("Developer") - } footer: { - Text("Shows raw API payloads and diagnostic details on builds and tickets screens. Home Prototype explores the dashboard structure, while Work Prototype evaluates the personal queue surface. This stays hidden until explicitly enabled.") - } - } - } - .themedList() - .navigationTitle("About") - .navigationBarTitleDisplayMode(.inline) - } -} diff --git a/Hutch/Views/Work/WorkPrototypeView.swift b/Hutch/Views/Work/WorkPrototypeView.swift deleted file mode 100644 index fb5c977..0000000 --- a/Hutch/Views/Work/WorkPrototypeView.swift +++ /dev/null @@ -1,7 +0,0 @@ -import SwiftUI - -struct WorkPrototypeView: View { - var body: some View { - WorkView() - } -} -- cgit v1.2.3