From efd90bca3ebe2eb7fb91cf558910ec11c0e05365 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 7 Apr 2024 22:28:30 -0400 Subject: [PATCH 1/3] Add Account Settings button to preferences --- .../PreferencesNavigationController.swift | 13 +++++++++++++ Tusker/Screens/Preferences/PreferencesView.swift | 11 +++++++++++ 2 files changed, 24 insertions(+) diff --git a/Tusker/Screens/Preferences/PreferencesNavigationController.swift b/Tusker/Screens/Preferences/PreferencesNavigationController.swift index a36aee6d..165a2841 100644 --- a/Tusker/Screens/Preferences/PreferencesNavigationController.swift +++ b/Tusker/Screens/Preferences/PreferencesNavigationController.swift @@ -9,12 +9,17 @@ import UIKit import SwiftUI import UserAccounts +import SafariServices class PreferencesNavigationController: UINavigationController { + private let mastodonController: MastodonController + private var isSwitchingAccounts = false init(mastodonController: MastodonController) { + self.mastodonController = mastodonController + let view = PreferencesView(mastodonController: mastodonController) let hostingController = UIHostingController(rootView: view) super.init(rootViewController: hostingController) @@ -31,6 +36,7 @@ class PreferencesNavigationController: UINavigationController { NotificationCenter.default.addObserver(self, selector: #selector(showAddAccount), name: .addAccount, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(activateAccount(_:)), name: .activateAccount, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(userLoggedOut), name: .userLoggedOut, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(showMastodonSettings), name: .showMastodonSettings, object: nil) } override func viewWillDisappear(_ animated: Bool) { @@ -92,6 +98,13 @@ class PreferencesNavigationController: UINavigationController { UIApplication.shared.requestSceneSessionDestruction(windowScene.session, options: nil) } } + + @objc private func showMastodonSettings() { + var components = URLComponents(url: mastodonController.accountInfo!.instanceURL, resolvingAgainstBaseURL: false)! + components.path = "/auth/edit" + let vc = SFSafariViewController(url: components.url!) + present(vc, animated: true) + } } diff --git a/Tusker/Screens/Preferences/PreferencesView.swift b/Tusker/Screens/Preferences/PreferencesView.swift index 6739d89e..7169a826 100644 --- a/Tusker/Screens/Preferences/PreferencesView.swift +++ b/Tusker/Screens/Preferences/PreferencesView.swift @@ -82,6 +82,7 @@ struct PreferencesView: View { }) { Text("Add Account...") } + Button(action: { self.showingLogoutConfirmation = true }) { @@ -89,6 +90,12 @@ struct PreferencesView: View { }.alert(isPresented: $showingLogoutConfirmation) { Alert(title: Text("Are you sure you want to logout?"), message: nil, primaryButton: .destructive(Text("Logout"), action: self.logoutPressed), secondaryButton: .cancel()) } + + Button { + NotificationCenter.default.post(name: .showMastodonSettings, object: nil) + } label: { + Text("Account Settings") + } } header: { Text("Accounts") } @@ -139,6 +146,10 @@ struct PreferencesView: View { } } +extension Notification.Name { + static let showMastodonSettings = Notification.Name("Tusker.showMastodonSettings") +} + //#if DEBUG //struct PreferencesView_Previews : PreviewProvider { // static var previews: some View { From d0bb197e8ce81943fa00aeea37639f27e9e20ffa Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 7 Apr 2024 22:29:48 -0400 Subject: [PATCH 2/3] Correct button titles --- Tusker/Screens/Preferences/PreferencesView.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tusker/Screens/Preferences/PreferencesView.swift b/Tusker/Screens/Preferences/PreferencesView.swift index 7169a826..1ad074bb 100644 --- a/Tusker/Screens/Preferences/PreferencesView.swift +++ b/Tusker/Screens/Preferences/PreferencesView.swift @@ -80,13 +80,13 @@ struct PreferencesView: View { Button(action: { NotificationCenter.default.post(name: .addAccount, object: nil) }) { - Text("Add Account...") + Text("Add Account…") } Button(action: { self.showingLogoutConfirmation = true }) { - Text("Logout from current") + Text("Logout from Current…") }.alert(isPresented: $showingLogoutConfirmation) { Alert(title: Text("Are you sure you want to logout?"), message: nil, primaryButton: .destructive(Text("Logout"), action: self.logoutPressed), secondaryButton: .cancel()) } From ec767542705075b34977ecc8c6ac208998b784f4 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 7 Apr 2024 22:36:56 -0400 Subject: [PATCH 3/3] Bump build number and update changelog --- CHANGELOG.md | 4 ++++ Version.xcconfig | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b34ac72..005ff424 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 2024.1 (119) +Features/Improvements: +- Add Account Settings button to Preferences + ## 2024.1 (118) Bugfixes: - Fix music not pausing/resuming when video playback starts diff --git a/Version.xcconfig b/Version.xcconfig index 773d5fc2..4031abc4 100644 --- a/Version.xcconfig +++ b/Version.xcconfig @@ -10,7 +10,7 @@ // https://help.apple.com/xcode/#/dev745c5c974 MARKETING_VERSION = 2024.1 -CURRENT_PROJECT_VERSION = 118 +CURRENT_PROJECT_VERSION = 119 CURRENT_PROJECT_VERSION = $(inherited)$(CURRENT_PROJECT_VERSION_BUILD_SUFFIX_$(CONFIGURATION)) CURRENT_PROJECT_VERSION_BUILD_SUFFIX_Debug=-dev