Clearer notification settings

This commit is contained in:
Justin Mazzocchi 2021-02-25 19:45:44 -08:00
parent 767e815f61
commit 2bab10b0fb
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C
4 changed files with 53 additions and 36 deletions

View file

@ -209,7 +209,7 @@
"preferences.notification-types.reblog" = "Reblog"; "preferences.notification-types.reblog" = "Reblog";
"preferences.notification-types.mention" = "Mention"; "preferences.notification-types.mention" = "Mention";
"preferences.notification-types.poll" = "Poll"; "preferences.notification-types.poll" = "Poll";
"preferences.notification-types.status" = "Status"; "preferences.notification-types.status" = "Subscription";
"preferences.notifications" = "Notifications"; "preferences.notifications" = "Notifications";
"preferences.notifications.include-account-name" = "Include account name"; "preferences.notifications.include-account-name" = "Include account name";
"preferences.notifications.include-pictures" = "Include pictures"; "preferences.notifications.include-pictures" = "Include pictures";

View file

@ -23,7 +23,7 @@ struct NotificationPreferencesView: View {
} }
Section(header: Text("preferences.notifications.sounds")) { Section(header: Text("preferences.notifications.sounds")) {
ForEach(MastodonNotification.NotificationType.allCasesExceptUnknown) { type in ForEach(MastodonNotification.NotificationType.allCasesExceptUnknown) { type in
Toggle(type.localizedStringKey, isOn: .init { Toggle(isOn: .init {
viewModel.identityContext.appPreferences.notificationSounds.contains(type) viewModel.identityContext.appPreferences.notificationSounds.contains(type)
} set: { } set: {
if $0 { if $0 {
@ -31,7 +31,9 @@ struct NotificationPreferencesView: View {
} else { } else {
viewModel.identityContext.appPreferences.notificationSounds.remove(type) viewModel.identityContext.appPreferences.notificationSounds.remove(type)
} }
}) }) {
Label(type.localizedStringKey, systemImage: type.systemImageName)
}
} }
} }
} }
@ -60,6 +62,25 @@ extension MastodonNotification.NotificationType {
return "" return ""
} }
} }
var systemImageName: String {
switch self {
case .follow, .followRequest:
return "person.badge.plus"
case .mention:
return "at"
case .reblog:
return "arrow.2.squarepath"
case .favourite:
return "star.fill"
case .poll:
return "chart.bar.xaxis"
case .status:
return "bell.fill"
case .unknown:
return "app.badge"
}
}
} }
#if DEBUG #if DEBUG

View file

@ -1,5 +1,6 @@
// Copyright © 2020 Metabolist. All rights reserved. // Copyright © 2020 Metabolist. All rights reserved.
import Mastodon
import SwiftUI import SwiftUI
import ViewModels import ViewModels
@ -8,20 +9,34 @@ struct NotificationTypesPreferencesView: View {
var body: some View { var body: some View {
Form { Form {
Toggle("preferences.notification-types.follow", Toggle(isOn: $viewModel.pushSubscriptionAlerts.follow) {
isOn: $viewModel.pushSubscriptionAlerts.follow) Label(MastodonNotification.NotificationType.follow.localizedStringKey,
Toggle("preferences.notification-types.favourite", systemImage: MastodonNotification.NotificationType.follow.systemImageName)
isOn: $viewModel.pushSubscriptionAlerts.favourite) }
Toggle("preferences.notification-types.reblog", Toggle(isOn: $viewModel.pushSubscriptionAlerts.favourite) {
isOn: $viewModel.pushSubscriptionAlerts.reblog) Label(MastodonNotification.NotificationType.favourite.localizedStringKey,
Toggle("preferences.notification-types.mention", systemImage: MastodonNotification.NotificationType.favourite.systemImageName)
isOn: $viewModel.pushSubscriptionAlerts.mention) }
Toggle("preferences.notification-types.follow-request", Toggle(isOn: $viewModel.pushSubscriptionAlerts.reblog) {
isOn: $viewModel.pushSubscriptionAlerts.followRequest) Label(MastodonNotification.NotificationType.reblog.localizedStringKey,
Toggle("preferences.notification-types.poll", systemImage: MastodonNotification.NotificationType.reblog.systemImageName)
isOn: $viewModel.pushSubscriptionAlerts.poll) }
Toggle("preferences.notification-types.status", Toggle(isOn: $viewModel.pushSubscriptionAlerts.mention) {
isOn: $viewModel.pushSubscriptionAlerts.status) Label(MastodonNotification.NotificationType.mention.localizedStringKey,
systemImage: MastodonNotification.NotificationType.mention.systemImageName)
}
Toggle(isOn: $viewModel.pushSubscriptionAlerts.followRequest) {
Label(MastodonNotification.NotificationType.followRequest.localizedStringKey,
systemImage: MastodonNotification.NotificationType.followRequest.systemImageName)
}
Toggle(isOn: $viewModel.pushSubscriptionAlerts.poll) {
Label(MastodonNotification.NotificationType.poll.localizedStringKey,
systemImage: MastodonNotification.NotificationType.poll.systemImageName)
}
Toggle(isOn: $viewModel.pushSubscriptionAlerts.status) {
Label(MastodonNotification.NotificationType.status.localizedStringKey,
systemImage: MastodonNotification.NotificationType.status.systemImageName)
}
} }
.navigationTitle("preferences.notification-types") .navigationTitle("preferences.notification-types")
.alertItem($viewModel.alertItem) .alertItem($viewModel.alertItem)

View file

@ -253,22 +253,3 @@ private extension NotificationView {
} }
// swiftlint:enable function_body_length // swiftlint:enable function_body_length
} }
extension MastodonNotification.NotificationType {
var systemImageName: String {
switch self {
case .follow, .followRequest:
return "person.badge.plus"
case .reblog:
return "arrow.2.squarepath"
case .favourite:
return "star.fill"
case .poll:
return "chart.bar.doc.horizontal"
case .status:
return "house"
case .mention, .unknown:
return "at"
}
}
}