From 2bab10b0fb4dcff599c466cc0a75e9211cf1adcc Mon Sep 17 00:00:00 2001 From: Justin Mazzocchi <2831158+jzzocc@users.noreply.github.com> Date: Thu, 25 Feb 2021 19:45:44 -0800 Subject: [PATCH] Clearer notification settings --- Localizations/Localizable.strings | 2 +- .../SwiftUI/NotificationPreferencesView.swift | 25 ++++++++++- .../NotificationTypesPreferencesView.swift | 43 +++++++++++++------ .../Content Views/NotificationView.swift | 19 -------- 4 files changed, 53 insertions(+), 36 deletions(-) diff --git a/Localizations/Localizable.strings b/Localizations/Localizable.strings index cf534a0..fb7460e 100644 --- a/Localizations/Localizable.strings +++ b/Localizations/Localizable.strings @@ -209,7 +209,7 @@ "preferences.notification-types.reblog" = "Reblog"; "preferences.notification-types.mention" = "Mention"; "preferences.notification-types.poll" = "Poll"; -"preferences.notification-types.status" = "Status"; +"preferences.notification-types.status" = "Subscription"; "preferences.notifications" = "Notifications"; "preferences.notifications.include-account-name" = "Include account name"; "preferences.notifications.include-pictures" = "Include pictures"; diff --git a/Views/SwiftUI/NotificationPreferencesView.swift b/Views/SwiftUI/NotificationPreferencesView.swift index 4c0880a..3a7fb39 100644 --- a/Views/SwiftUI/NotificationPreferencesView.swift +++ b/Views/SwiftUI/NotificationPreferencesView.swift @@ -23,7 +23,7 @@ struct NotificationPreferencesView: View { } Section(header: Text("preferences.notifications.sounds")) { ForEach(MastodonNotification.NotificationType.allCasesExceptUnknown) { type in - Toggle(type.localizedStringKey, isOn: .init { + Toggle(isOn: .init { viewModel.identityContext.appPreferences.notificationSounds.contains(type) } set: { if $0 { @@ -31,7 +31,9 @@ struct NotificationPreferencesView: View { } else { viewModel.identityContext.appPreferences.notificationSounds.remove(type) } - }) + }) { + Label(type.localizedStringKey, systemImage: type.systemImageName) + } } } } @@ -60,6 +62,25 @@ extension MastodonNotification.NotificationType { 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 diff --git a/Views/SwiftUI/NotificationTypesPreferencesView.swift b/Views/SwiftUI/NotificationTypesPreferencesView.swift index c522b5a..70c6581 100644 --- a/Views/SwiftUI/NotificationTypesPreferencesView.swift +++ b/Views/SwiftUI/NotificationTypesPreferencesView.swift @@ -1,5 +1,6 @@ // Copyright © 2020 Metabolist. All rights reserved. +import Mastodon import SwiftUI import ViewModels @@ -8,20 +9,34 @@ struct NotificationTypesPreferencesView: View { var body: some View { Form { - Toggle("preferences.notification-types.follow", - isOn: $viewModel.pushSubscriptionAlerts.follow) - Toggle("preferences.notification-types.favourite", - isOn: $viewModel.pushSubscriptionAlerts.favourite) - Toggle("preferences.notification-types.reblog", - isOn: $viewModel.pushSubscriptionAlerts.reblog) - Toggle("preferences.notification-types.mention", - isOn: $viewModel.pushSubscriptionAlerts.mention) - Toggle("preferences.notification-types.follow-request", - isOn: $viewModel.pushSubscriptionAlerts.followRequest) - Toggle("preferences.notification-types.poll", - isOn: $viewModel.pushSubscriptionAlerts.poll) - Toggle("preferences.notification-types.status", - isOn: $viewModel.pushSubscriptionAlerts.status) + Toggle(isOn: $viewModel.pushSubscriptionAlerts.follow) { + Label(MastodonNotification.NotificationType.follow.localizedStringKey, + systemImage: MastodonNotification.NotificationType.follow.systemImageName) + } + Toggle(isOn: $viewModel.pushSubscriptionAlerts.favourite) { + Label(MastodonNotification.NotificationType.favourite.localizedStringKey, + systemImage: MastodonNotification.NotificationType.favourite.systemImageName) + } + Toggle(isOn: $viewModel.pushSubscriptionAlerts.reblog) { + Label(MastodonNotification.NotificationType.reblog.localizedStringKey, + systemImage: MastodonNotification.NotificationType.reblog.systemImageName) + } + Toggle(isOn: $viewModel.pushSubscriptionAlerts.mention) { + 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") .alertItem($viewModel.alertItem) diff --git a/Views/UIKit/Content Views/NotificationView.swift b/Views/UIKit/Content Views/NotificationView.swift index e494f58..7fc35f5 100644 --- a/Views/UIKit/Content Views/NotificationView.swift +++ b/Views/UIKit/Content Views/NotificationView.swift @@ -253,22 +253,3 @@ private extension NotificationView { } // 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" - } - } -}