Add push notification settings in profile context menu

This commit is contained in:
Thomas Ricouard 2023-01-27 12:18:17 +01:00
parent 0f4fccf1a5
commit de4346c47e
5 changed files with 39 additions and 20 deletions

View file

@ -78,6 +78,13 @@ extension View {
SettingsTabs(popToRootTab: .constant(.settings)) SettingsTabs(popToRootTab: .constant(.settings))
.withEnvironments() .withEnvironments()
.preferredColorScheme(Theme.shared.selectedScheme == .dark ? .dark : .light) .preferredColorScheme(Theme.shared.selectedScheme == .dark ? .dark : .light)
case .accountPushNotficationsSettings:
if let subscription = PushNotificationsService.shared.subscriptions.first(where: { $0.account.token == AppAccountsManager.shared.currentAccount.oauthToken }) {
PushNotificationsView(subscription: subscription)
.withEnvironments()
} else {
EmptyView()
}
} }
} }
} }
@ -88,5 +95,6 @@ extension View {
.environmentObject(CurrentInstance.shared) .environmentObject(CurrentInstance.shared)
.environmentObject(Theme.shared) .environmentObject(Theme.shared)
.environmentObject(AppAccountsManager.shared) .environmentObject(AppAccountsManager.shared)
.environmentObject(PushNotificationsService.shared)
} }
} }

View file

@ -107,10 +107,8 @@ struct SettingsTabs: View {
} }
Link(destination: URL(string: UIApplication.openSettingsURLString)!) { Link(destination: URL(string: UIApplication.openSettingsURLString)!) {
Label("settings.system", systemImage: "gear") Label("settings.system", systemImage: "gear")
// Tint our label black, so that it matches the other NavigationLink instead of
// defaulting to highlighted like a Link
.tint(.black)
} }
.tint(theme.labelColor)
} }
.listRowBackground(theme.primaryBackgroundColor) .listRowBackground(theme.primaryBackgroundColor)
} }

View file

@ -25,6 +25,7 @@ public struct AccountDetailView: View {
@State private var isCurrentUser: Bool = false @State private var isCurrentUser: Bool = false
@State private var isCreateListAlertPresented: Bool = false @State private var isCreateListAlertPresented: Bool = false
@State private var createListTitle: String = "" @State private var createListTitle: String = ""
@State private var isEditingAccount: Bool = false @State private var isEditingAccount: Bool = false
@State private var isEditingFilters: Bool = false @State private var isEditingFilters: Bool = false
@ -520,6 +521,12 @@ public struct AccountDetailView: View {
Label("account.action.edit-filters", systemImage: "line.3.horizontal.decrease.circle") Label("account.action.edit-filters", systemImage: "line.3.horizontal.decrease.circle")
} }
} }
Button {
routerPath.presentedSheet = .accountPushNotficationsSettings
} label: {
Label("settings.push.navigation-title", systemImage: "bell")
}
} }
} }
} }

View file

@ -19,27 +19,31 @@ public struct FiltersListView: View {
public var body: some View { public var body: some View {
NavigationStack { NavigationStack {
Form { Form {
Section { if !isLoading && filters.isEmpty {
if isLoading && filters.isEmpty { EmptyView()
ProgressView() } else {
} else { Section {
ForEach(filters) { filter in if isLoading && filters.isEmpty {
NavigationLink(destination: EditFilterView(filter: filter)) { ProgressView()
VStack(alignment: .leading) { } else {
Text(filter.title) ForEach(filters) { filter in
.font(.scaledSubheadline) NavigationLink(destination: EditFilterView(filter: filter)) {
Text("\(filter.context.map{ $0.name }.joined(separator: ", "))") VStack(alignment: .leading) {
.font(.scaledBody) Text(filter.title)
.foregroundColor(.gray) .font(.scaledSubheadline)
Text("\(filter.context.map{ $0.name }.joined(separator: ", "))")
.font(.scaledBody)
.foregroundColor(.gray)
}
} }
} }
} .onDelete { indexes in
.onDelete { indexes in deleteFilter(indexes: indexes)
deleteFilter(indexes: indexes) }
} }
} }
.listRowBackground(theme.primaryBackgroundColor)
} }
.listRowBackground(theme.primaryBackgroundColor)
Section { Section {
NavigationLink(destination: EditFilterView(filter: nil)) { NavigationLink(destination: EditFilterView(filter: nil)) {

View file

@ -30,10 +30,12 @@ public enum SheetDestinations: Identifiable {
case addRemoteLocalTimeline case addRemoteLocalTimeline
case statusEditHistory(status: String) case statusEditHistory(status: String)
case settings case settings
case accountPushNotficationsSettings
public var id: String { public var id: String {
switch self { switch self {
case .editStatusEditor, .newStatusEditor, .replyToStatusEditor, .quoteStatusEditor, .mentionStatusEditor, .settings: case .editStatusEditor, .newStatusEditor, .replyToStatusEditor, .quoteStatusEditor,
.mentionStatusEditor, .settings, .accountPushNotficationsSettings:
return "statusEditor" return "statusEditor"
case .listEdit: case .listEdit:
return "listEdit" return "listEdit"