mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-04-27 02:14:45 +00:00
Add support / about shortcuts in account selector bottom sheet
This commit is contained in:
parent
b6370aef98
commit
6850fcd928
6 changed files with 84 additions and 33 deletions
|
@ -15,6 +15,7 @@
|
||||||
639CDF9C296AC82F00C35E58 /* SafariRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 639CDF9B296AC82F00C35E58 /* SafariRouter.swift */; };
|
639CDF9C296AC82F00C35E58 /* SafariRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 639CDF9B296AC82F00C35E58 /* SafariRouter.swift */; };
|
||||||
9F15D6002B3D6A850008C220 /* NavigationTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F15D5FF2B3D6A850008C220 /* NavigationTab.swift */; };
|
9F15D6002B3D6A850008C220 /* NavigationTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F15D5FF2B3D6A850008C220 /* NavigationTab.swift */; };
|
||||||
9F15D6022B3D6E280008C220 /* TabbarEntriesSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F15D6012B3D6E280008C220 /* TabbarEntriesSettingsView.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 */; };
|
9F18801229AE477F00D85459 /* tabSelection.wav in Resources */ = {isa = PBXBuildFile; fileRef = 9F18800A29AE477E00D85459 /* tabSelection.wav */; };
|
||||||
9F18801329AE477F00D85459 /* share.wav in Resources */ = {isa = PBXBuildFile; fileRef = 9F18800B29AE477E00D85459 /* share.wav */; };
|
9F18801329AE477F00D85459 /* share.wav in Resources */ = {isa = PBXBuildFile; fileRef = 9F18800B29AE477E00D85459 /* share.wav */; };
|
||||||
9F18801429AE477F00D85459 /* bookmark.wav in Resources */ = {isa = PBXBuildFile; fileRef = 9F18800C29AE477E00D85459 /* bookmark.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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
9F18800C29AE477E00D85459 /* bookmark.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = bookmark.wav; sourceTree = "<group>"; };
|
||||||
|
@ -429,6 +431,7 @@
|
||||||
9F2B92F5295AE04800DE16D0 /* Tabs.swift */,
|
9F2B92F5295AE04800DE16D0 /* Tabs.swift */,
|
||||||
9F4A48182976B21900A1A038 /* ProfileTab.swift */,
|
9F4A48182976B21900A1A038 /* ProfileTab.swift */,
|
||||||
9F15D5FF2B3D6A850008C220 /* NavigationTab.swift */,
|
9F15D5FF2B3D6A850008C220 /* NavigationTab.swift */,
|
||||||
|
9F15D6032B3DC2180008C220 /* NavigationSheet.swift */,
|
||||||
);
|
);
|
||||||
path = Tabs;
|
path = Tabs;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -824,6 +827,7 @@
|
||||||
069709AA298C9AD7006E4CB5 /* AboutView.swift in Sources */,
|
069709AA298C9AD7006E4CB5 /* AboutView.swift in Sources */,
|
||||||
9F2B92FC295DA94500DE16D0 /* InstanceInfoView.swift in Sources */,
|
9F2B92FC295DA94500DE16D0 /* InstanceInfoView.swift in Sources */,
|
||||||
C9B22677297F6C2E001F9EFE /* ContentSettingsView.swift in Sources */,
|
C9B22677297F6C2E001F9EFE /* ContentSettingsView.swift in Sources */,
|
||||||
|
9F15D6042B3DC2180008C220 /* NavigationSheet.swift in Sources */,
|
||||||
9FA6FD6229C04A8800E2312C /* TranslationSettingsView.swift in Sources */,
|
9FA6FD6229C04A8800E2312C /* TranslationSettingsView.swift in Sources */,
|
||||||
9FB183272AE9279F00BBB692 /* IceCubesApp+Tabbar.swift in Sources */,
|
9FB183272AE9279F00BBB692 /* IceCubesApp+Tabbar.swift in Sources */,
|
||||||
9F35DB4C2952005C00B3281A /* MessagesTab.swift in Sources */,
|
9F35DB4C2952005C00B3281A /* MessagesTab.swift in Sources */,
|
||||||
|
|
|
@ -97,10 +97,14 @@ extension View {
|
||||||
.preferredColorScheme(Theme.shared.selectedScheme == .dark ? .dark : .light)
|
.preferredColorScheme(Theme.shared.selectedScheme == .dark ? .dark : .light)
|
||||||
case .accountPushNotficationsSettings:
|
case .accountPushNotficationsSettings:
|
||||||
if let subscription = PushNotificationsService.shared.subscriptions.first(where: { $0.account.token == AppAccountsManager.shared.currentAccount.oauthToken }) {
|
if let subscription = PushNotificationsService.shared.subscriptions.first(where: { $0.account.token == AppAccountsManager.shared.currentAccount.oauthToken }) {
|
||||||
PushNotificationsViewWrapper(subscription: subscription)
|
NavigationSheet { PushNotificationsView(subscription: subscription) }
|
||||||
} else {
|
} else {
|
||||||
EmptyView()
|
EmptyView()
|
||||||
}
|
}
|
||||||
|
case .about:
|
||||||
|
NavigationSheet { AboutView() }
|
||||||
|
case .support:
|
||||||
|
NavigationSheet { SupportAppView() }
|
||||||
case let .report(status):
|
case let .report(status):
|
||||||
ReportView(status: status)
|
ReportView(status: status)
|
||||||
case let .shareImage(image, status):
|
case let .shareImage(image, status):
|
||||||
|
|
30
IceCubesApp/App/Tabs/NavigationSheet.swift
Normal file
30
IceCubesApp/App/Tabs/NavigationSheet.swift
Normal file
|
@ -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 SwiftUI
|
||||||
import UserNotifications
|
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
|
@MainActor
|
||||||
struct PushNotificationsView: View {
|
struct PushNotificationsView: View {
|
||||||
@Environment(Theme.self) private var theme
|
@Environment(Theme.self) private var theme
|
||||||
|
|
|
@ -26,7 +26,7 @@ public struct AppAccountsSelectorView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
private var preferredHeight: CGFloat {
|
private var preferredHeight: CGFloat {
|
||||||
var baseHeight: CGFloat = 220
|
var baseHeight: CGFloat = 310
|
||||||
baseHeight += CGFloat(60 * accountsViewModel.count)
|
baseHeight += CGFloat(60 * accountsViewModel.count)
|
||||||
return baseHeight
|
return baseHeight
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,7 @@ public struct AppAccountsSelectorView: View {
|
||||||
ForEach(accountsViewModel.sorted { $0.acct < $1.acct }, id: \.appAccount.id) { viewModel in
|
ForEach(accountsViewModel.sorted { $0.acct < $1.acct }, id: \.appAccount.id) { viewModel in
|
||||||
AppAccountView(viewModel: viewModel)
|
AppAccountView(viewModel: viewModel)
|
||||||
}
|
}
|
||||||
|
addAccountButton
|
||||||
}
|
}
|
||||||
#if !os(visionOS)
|
#if !os(visionOS)
|
||||||
.listRowBackground(theme.primaryBackgroundColor)
|
.listRowBackground(theme.primaryBackgroundColor)
|
||||||
|
@ -102,16 +103,9 @@ public struct AppAccountsSelectorView: View {
|
||||||
|
|
||||||
if accountCreationEnabled {
|
if accountCreationEnabled {
|
||||||
Section {
|
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
|
settingsButton
|
||||||
|
aboutButton
|
||||||
|
supportButton
|
||||||
}
|
}
|
||||||
#if !os(visionOS)
|
#if !os(visionOS)
|
||||||
.listRowBackground(theme.primaryBackgroundColor)
|
.listRowBackground(theme.primaryBackgroundColor)
|
||||||
|
@ -135,6 +129,18 @@ public struct AppAccountsSelectorView: View {
|
||||||
.environment(routerPath)
|
.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 {
|
private var settingsButton: some View {
|
||||||
Button {
|
Button {
|
||||||
|
@ -147,6 +153,30 @@ public struct AppAccountsSelectorView: View {
|
||||||
Label("tab.settings", systemImage: "gear")
|
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() {
|
private func refreshAccounts() {
|
||||||
accountsViewModel = []
|
accountsViewModel = []
|
||||||
|
|
|
@ -50,6 +50,8 @@ public enum SheetDestination: Identifiable {
|
||||||
case addTagGroup
|
case addTagGroup
|
||||||
case statusEditHistory(status: String)
|
case statusEditHistory(status: String)
|
||||||
case settings
|
case settings
|
||||||
|
case about
|
||||||
|
case support
|
||||||
case accountPushNotficationsSettings
|
case accountPushNotficationsSettings
|
||||||
case report(status: Status)
|
case report(status: Status)
|
||||||
case shareImage(image: UIImage, status: Status)
|
case shareImage(image: UIImage, status: Status)
|
||||||
|
@ -58,7 +60,7 @@ public enum SheetDestination: Identifiable {
|
||||||
public var id: String {
|
public var id: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .editStatusEditor, .newStatusEditor, .replyToStatusEditor, .quoteStatusEditor,
|
case .editStatusEditor, .newStatusEditor, .replyToStatusEditor, .quoteStatusEditor,
|
||||||
.mentionStatusEditor, .settings, .accountPushNotficationsSettings:
|
.mentionStatusEditor:
|
||||||
"statusEditor"
|
"statusEditor"
|
||||||
case .listCreate:
|
case .listCreate:
|
||||||
"listCreate"
|
"listCreate"
|
||||||
|
@ -80,6 +82,8 @@ public enum SheetDestination: Identifiable {
|
||||||
"shareImage"
|
"shareImage"
|
||||||
case .editTagGroup:
|
case .editTagGroup:
|
||||||
"editTagGroup"
|
"editTagGroup"
|
||||||
|
case .settings, .support, .about, .accountPushNotficationsSettings:
|
||||||
|
"settings"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue