Add support / about shortcuts in account selector bottom sheet
This commit is contained in:
parent
b6370aef98
commit
6850fcd928
|
@ -15,6 +15,7 @@
|
|||
639CDF9C296AC82F00C35E58 /* SafariRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 639CDF9B296AC82F00C35E58 /* SafariRouter.swift */; };
|
||||
9F15D6002B3D6A850008C220 /* NavigationTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F15D5FF2B3D6A850008C220 /* NavigationTab.swift */; };
|
||||
9F15D6022B3D6E280008C220 /* TabbarEntriesSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F15D6012B3D6E280008C220 /* TabbarEntriesSettingsView.swift */; };
|
||||
9F15D6042B3DC2180008C220 /* NavigationSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F15D6032B3DC2180008C220 /* NavigationSheet.swift */; };
|
||||
9F18801229AE477F00D85459 /* tabSelection.wav in Resources */ = {isa = PBXBuildFile; fileRef = 9F18800A29AE477E00D85459 /* tabSelection.wav */; };
|
||||
9F18801329AE477F00D85459 /* share.wav in Resources */ = {isa = PBXBuildFile; fileRef = 9F18800B29AE477E00D85459 /* share.wav */; };
|
||||
9F18801429AE477F00D85459 /* bookmark.wav in Resources */ = {isa = PBXBuildFile; fileRef = 9F18800C29AE477E00D85459 /* bookmark.wav */; };
|
||||
|
@ -164,6 +165,7 @@
|
|||
9664F1A8299BA5F700CBE70E /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
9F15D5FF2B3D6A850008C220 /* NavigationTab.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationTab.swift; sourceTree = "<group>"; };
|
||||
9F15D6012B3D6E280008C220 /* TabbarEntriesSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabbarEntriesSettingsView.swift; sourceTree = "<group>"; };
|
||||
9F15D6032B3DC2180008C220 /* NavigationSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationSheet.swift; sourceTree = "<group>"; };
|
||||
9F18800A29AE477E00D85459 /* tabSelection.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = tabSelection.wav; sourceTree = "<group>"; };
|
||||
9F18800B29AE477E00D85459 /* share.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = share.wav; sourceTree = "<group>"; };
|
||||
9F18800C29AE477E00D85459 /* bookmark.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = bookmark.wav; sourceTree = "<group>"; };
|
||||
|
@ -429,6 +431,7 @@
|
|||
9F2B92F5295AE04800DE16D0 /* Tabs.swift */,
|
||||
9F4A48182976B21900A1A038 /* ProfileTab.swift */,
|
||||
9F15D5FF2B3D6A850008C220 /* NavigationTab.swift */,
|
||||
9F15D6032B3DC2180008C220 /* NavigationSheet.swift */,
|
||||
);
|
||||
path = Tabs;
|
||||
sourceTree = "<group>";
|
||||
|
@ -824,6 +827,7 @@
|
|||
069709AA298C9AD7006E4CB5 /* AboutView.swift in Sources */,
|
||||
9F2B92FC295DA94500DE16D0 /* InstanceInfoView.swift in Sources */,
|
||||
C9B22677297F6C2E001F9EFE /* ContentSettingsView.swift in Sources */,
|
||||
9F15D6042B3DC2180008C220 /* NavigationSheet.swift in Sources */,
|
||||
9FA6FD6229C04A8800E2312C /* TranslationSettingsView.swift in Sources */,
|
||||
9FB183272AE9279F00BBB692 /* IceCubesApp+Tabbar.swift in Sources */,
|
||||
9F35DB4C2952005C00B3281A /* MessagesTab.swift in Sources */,
|
||||
|
|
|
@ -97,10 +97,14 @@ extension View {
|
|||
.preferredColorScheme(Theme.shared.selectedScheme == .dark ? .dark : .light)
|
||||
case .accountPushNotficationsSettings:
|
||||
if let subscription = PushNotificationsService.shared.subscriptions.first(where: { $0.account.token == AppAccountsManager.shared.currentAccount.oauthToken }) {
|
||||
PushNotificationsViewWrapper(subscription: subscription)
|
||||
NavigationSheet { PushNotificationsView(subscription: subscription) }
|
||||
} else {
|
||||
EmptyView()
|
||||
}
|
||||
case .about:
|
||||
NavigationSheet { AboutView() }
|
||||
case .support:
|
||||
NavigationSheet { SupportAppView() }
|
||||
case let .report(status):
|
||||
ReportView(status: status)
|
||||
case let .shareImage(image, status):
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
import SwiftUI
|
||||
import Env
|
||||
import AppAccount
|
||||
import DesignSystem
|
||||
|
||||
@MainActor
|
||||
struct NavigationSheet<Content: View>: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
var content: () -> Content
|
||||
|
||||
init(@ViewBuilder content: @escaping () -> Content) {
|
||||
self.content = content
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
content()
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
Button {
|
||||
dismiss()
|
||||
} label: {
|
||||
Image(systemName: "xmark.circle")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,27 +7,6 @@ import NukeUI
|
|||
import SwiftUI
|
||||
import UserNotifications
|
||||
|
||||
struct PushNotificationsViewWrapper: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
public let subscription: PushNotificationSubscriptionSettings
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
PushNotificationsView(subscription: subscription)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
Button {
|
||||
dismiss()
|
||||
} label: {
|
||||
Image(systemName: "xmark.circle")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
struct PushNotificationsView: View {
|
||||
@Environment(Theme.self) private var theme
|
||||
|
|
|
@ -26,7 +26,7 @@ public struct AppAccountsSelectorView: View {
|
|||
}
|
||||
|
||||
private var preferredHeight: CGFloat {
|
||||
var baseHeight: CGFloat = 220
|
||||
var baseHeight: CGFloat = 310
|
||||
baseHeight += CGFloat(60 * accountsViewModel.count)
|
||||
return baseHeight
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ public struct AppAccountsSelectorView: View {
|
|||
ForEach(accountsViewModel.sorted { $0.acct < $1.acct }, id: \.appAccount.id) { viewModel in
|
||||
AppAccountView(viewModel: viewModel)
|
||||
}
|
||||
addAccountButton
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
|
@ -102,16 +103,9 @@ public struct AppAccountsSelectorView: View {
|
|||
|
||||
if accountCreationEnabled {
|
||||
Section {
|
||||
Button {
|
||||
isPresented = false
|
||||
HapticManager.shared.fireHaptic(.buttonPress)
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
routerPath.presentedSheet = .addAccount
|
||||
}
|
||||
} label: {
|
||||
Label("app-account.button.add", systemImage: "person.badge.plus")
|
||||
}
|
||||
settingsButton
|
||||
aboutButton
|
||||
supportButton
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
|
@ -135,6 +129,18 @@ public struct AppAccountsSelectorView: View {
|
|||
.environment(routerPath)
|
||||
}
|
||||
}
|
||||
|
||||
private var addAccountButton: some View {
|
||||
Button {
|
||||
isPresented = false
|
||||
HapticManager.shared.fireHaptic(.buttonPress)
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
routerPath.presentedSheet = .addAccount
|
||||
}
|
||||
} label: {
|
||||
Label("app-account.button.add", systemImage: "person.badge.plus")
|
||||
}
|
||||
}
|
||||
|
||||
private var settingsButton: some View {
|
||||
Button {
|
||||
|
@ -147,6 +153,30 @@ public struct AppAccountsSelectorView: View {
|
|||
Label("tab.settings", systemImage: "gear")
|
||||
}
|
||||
}
|
||||
|
||||
private var supportButton: some View {
|
||||
Button {
|
||||
isPresented = false
|
||||
HapticManager.shared.fireHaptic(.buttonPress)
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
routerPath.presentedSheet = .support
|
||||
}
|
||||
} label: {
|
||||
Label("settings.app.support", systemImage: "wand.and.stars")
|
||||
}
|
||||
}
|
||||
|
||||
private var aboutButton: some View {
|
||||
Button {
|
||||
isPresented = false
|
||||
HapticManager.shared.fireHaptic(.buttonPress)
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
routerPath.presentedSheet = .about
|
||||
}
|
||||
} label: {
|
||||
Label("account.edit.about", systemImage: "info.circle")
|
||||
}
|
||||
}
|
||||
|
||||
private func refreshAccounts() {
|
||||
accountsViewModel = []
|
||||
|
|
|
@ -50,6 +50,8 @@ public enum SheetDestination: Identifiable {
|
|||
case addTagGroup
|
||||
case statusEditHistory(status: String)
|
||||
case settings
|
||||
case about
|
||||
case support
|
||||
case accountPushNotficationsSettings
|
||||
case report(status: Status)
|
||||
case shareImage(image: UIImage, status: Status)
|
||||
|
@ -58,7 +60,7 @@ public enum SheetDestination: Identifiable {
|
|||
public var id: String {
|
||||
switch self {
|
||||
case .editStatusEditor, .newStatusEditor, .replyToStatusEditor, .quoteStatusEditor,
|
||||
.mentionStatusEditor, .settings, .accountPushNotficationsSettings:
|
||||
.mentionStatusEditor:
|
||||
"statusEditor"
|
||||
case .listCreate:
|
||||
"listCreate"
|
||||
|
@ -80,6 +82,8 @@ public enum SheetDestination: Identifiable {
|
|||
"shareImage"
|
||||
case .editTagGroup:
|
||||
"editTagGroup"
|
||||
case .settings, .support, .about, .accountPushNotficationsSettings:
|
||||
"settings"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue