damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 2ce0a771ea02ca3bfd76233bfc0947eabb73027a
parent 0436c68ec580b1141aa593ae416bc7fbdc650e30
Author: William Casarin <jb55@jb55.com>
Date:   Wed,  5 Apr 2023 08:49:15 -0700

refactor: move notification settings to its own file

Diffstat:
Mdamus.xcodeproj/project.pbxproj | 12++++++++++++
Mdamus/Views/ConfigView.swift | 28+---------------------------
Adamus/Views/Settings/NotificationSettingsView.swift | 41+++++++++++++++++++++++++++++++++++++++++
3 files changed, 54 insertions(+), 27 deletions(-)

diff --git a/damus.xcodeproj/project.pbxproj b/damus.xcodeproj/project.pbxproj @@ -38,6 +38,7 @@ 4C0A3F91280F6528000448DE /* ChatView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0A3F90280F6528000448DE /* ChatView.swift */; }; 4C0A3F93280F66F5000448DE /* ReplyMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0A3F92280F66F5000448DE /* ReplyMap.swift */; }; 4C1A9A1A29DCA17E00516EAC /* ReplyCounter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C1A9A1929DCA17E00516EAC /* ReplyCounter.swift */; }; + 4C1A9A1D29DDCF9B00516EAC /* NotificationSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C1A9A1C29DDCF9B00516EAC /* NotificationSettingsView.swift */; }; 4C216F32286E388800040376 /* DMChatView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C216F31286E388800040376 /* DMChatView.swift */; }; 4C216F34286F5ACD00040376 /* DMView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C216F33286F5ACD00040376 /* DMView.swift */; }; 4C216F362870A9A700040376 /* InputDismissKeyboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C216F352870A9A700040376 /* InputDismissKeyboard.swift */; }; @@ -401,6 +402,7 @@ 4C0A3F90280F6528000448DE /* ChatView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatView.swift; sourceTree = "<group>"; }; 4C0A3F92280F66F5000448DE /* ReplyMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReplyMap.swift; sourceTree = "<group>"; }; 4C1A9A1929DCA17E00516EAC /* ReplyCounter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReplyCounter.swift; sourceTree = "<group>"; }; + 4C1A9A1C29DDCF9B00516EAC /* NotificationSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationSettingsView.swift; sourceTree = "<group>"; }; 4C216F31286E388800040376 /* DMChatView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DMChatView.swift; sourceTree = "<group>"; }; 4C216F33286F5ACD00040376 /* DMView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DMView.swift; sourceTree = "<group>"; }; 4C216F352870A9A700040376 /* InputDismissKeyboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputDismissKeyboard.swift; sourceTree = "<group>"; }; @@ -813,6 +815,14 @@ path = Models; sourceTree = "<group>"; }; + 4C1A9A1B29DDCF8B00516EAC /* Settings */ = { + isa = PBXGroup; + children = ( + 4C1A9A1C29DDCF9B00516EAC /* NotificationSettingsView.swift */, + ); + path = Settings; + sourceTree = "<group>"; + }; 4C30AC7029A5676F00E2BD5A /* Notifications */ = { isa = PBXGroup; children = ( @@ -836,6 +846,7 @@ 4C75EFA227FA576C0006080F /* Views */ = { isa = PBXGroup; children = ( + 4C1A9A1B29DDCF8B00516EAC /* Settings */, 4CFF8F6129CC9A80008DB934 /* Images */, 4CCEB7AC29B53D180078AA28 /* Search */, 4C30AC7029A5676F00E2BD5A /* Notifications */, @@ -1648,6 +1659,7 @@ 4CC7AAF4297F18B400430951 /* ReplyDescription.swift in Sources */, 4C75EFA427FA577B0006080F /* PostView.swift in Sources */, 4C30AC7229A5677A00E2BD5A /* NotificationsView.swift in Sources */, + 4C1A9A1D29DDCF9B00516EAC /* NotificationSettingsView.swift in Sources */, 4C75EFB528049D790006080F /* Relay.swift in Sources */, 4CEE2AF1280B216B00AB5EEF /* EventDetailView.swift in Sources */, 4CC7AAFA297F64AC00430951 /* EventMenu.swift in Sources */, diff --git a/damus/Views/ConfigView.swift b/damus/Views/ConfigView.swift @@ -147,7 +147,7 @@ struct ConfigView: View { .toggleStyle(.switch) } - NavigationLink(destination: NotificationView(settings: settings)) { + NavigationLink(destination: NotificationSettingsView(settings: settings)) { Section(NSLocalizedString("Local Notifications", comment: "Section header for damus local notifications user configuration")) { } } @@ -390,32 +390,6 @@ struct ConfigView: View { } } -struct NotificationView: View { - @ObservedObject var settings: UserSettingsStore - - var body: some View { - Form { - Section(header: Text(NSLocalizedString("Local Notifications", comment: "Section header for damus local notifications user configuration"))) { - Toggle(NSLocalizedString("Zaps", comment: "Setting to enable Zap Local Notification"), isOn: $settings.zap_notification) - .toggleStyle(.switch) - Toggle(NSLocalizedString("Mentions", comment: "Setting to enable Mention Local Notification"), isOn: $settings.mention_notification) - .toggleStyle(.switch) - Toggle(NSLocalizedString("Reposts", comment: "Setting to enable Repost Local Notification"), isOn: $settings.repost_notification) - .toggleStyle(.switch) - Toggle(NSLocalizedString("Likes", comment: "Setting to enable Like Local Notification"), isOn: $settings.like_notification) - .toggleStyle(.switch) - Toggle(NSLocalizedString("DMs", comment: "Setting to enable DM Local Notification"), isOn: $settings.dm_notification) - .toggleStyle(.switch) - } - - Section(header: Text(NSLocalizedString("Notification Preference", comment: "Section header for Notification Preferences"))) { - Toggle(NSLocalizedString("Show only from users you follow", comment: "Setting to Show notifications only associated to users your follow"), isOn: $settings.notification_only_from_following) - .toggleStyle(.switch) - } - } - } -} - struct ConfigView_Previews: PreviewProvider { static var previews: some View { NavigationView { diff --git a/damus/Views/Settings/NotificationSettingsView.swift b/damus/Views/Settings/NotificationSettingsView.swift @@ -0,0 +1,41 @@ +// +// NotificationSettings.swift +// damus +// +// Created by William Casarin on 2023-04-05. +// + +import SwiftUI + +struct NotificationSettingsView: View { + @ObservedObject var settings: UserSettingsStore + + var body: some View { + Form { + Section(header: Text(NSLocalizedString("Local Notifications", comment: "Section header for damus local notifications user configuration"))) { + Toggle(NSLocalizedString("Zaps", comment: "Setting to enable Zap Local Notification"), isOn: $settings.zap_notification) + .toggleStyle(.switch) + Toggle(NSLocalizedString("Mentions", comment: "Setting to enable Mention Local Notification"), isOn: $settings.mention_notification) + .toggleStyle(.switch) + Toggle(NSLocalizedString("Reposts", comment: "Setting to enable Repost Local Notification"), isOn: $settings.repost_notification) + .toggleStyle(.switch) + Toggle(NSLocalizedString("Likes", comment: "Setting to enable Like Local Notification"), isOn: $settings.like_notification) + .toggleStyle(.switch) + Toggle(NSLocalizedString("DMs", comment: "Setting to enable DM Local Notification"), isOn: $settings.dm_notification) + .toggleStyle(.switch) + } + + Section(header: Text(NSLocalizedString("Notification Preference", comment: "Section header for Notification Preferences"))) { + Toggle(NSLocalizedString("Show only from users you follow", comment: "Setting to Show notifications only associated to users your follow"), isOn: $settings.notification_only_from_following) + .toggleStyle(.switch) + } + } + } +} + + +struct NotificationSettings_Previews: PreviewProvider { + static var previews: some View { + NotificationSettingsView(settings: UserSettingsStore()) + } +}