Add preference for default notifications display mode
This commit is contained in:
parent
6ab8f99cc2
commit
905b6a0a21
|
@ -167,6 +167,8 @@
|
||||||
D6BC874621961F73006163F1 /* Gifu.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D6BC874421961F73006163F1 /* Gifu.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
D6BC874621961F73006163F1 /* Gifu.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D6BC874421961F73006163F1 /* Gifu.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||||
D6BC8748219738E1006163F1 /* EnhancedTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6BC8747219738E1006163F1 /* EnhancedTableViewController.swift */; };
|
D6BC8748219738E1006163F1 /* EnhancedTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6BC8747219738E1006163F1 /* EnhancedTableViewController.swift */; };
|
||||||
D6BC9DB1232C61BC002CA326 /* NotificationsPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6BC9DB0232C61BC002CA326 /* NotificationsPageViewController.swift */; };
|
D6BC9DB1232C61BC002CA326 /* NotificationsPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6BC9DB0232C61BC002CA326 /* NotificationsPageViewController.swift */; };
|
||||||
|
D6BC9DB3232D4C07002CA326 /* WellnessPrefsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6BC9DB2232D4C07002CA326 /* WellnessPrefsView.swift */; };
|
||||||
|
D6BC9DB5232D4CE3002CA326 /* NotificationsMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6BC9DB4232D4CE3002CA326 /* NotificationsMode.swift */; };
|
||||||
D6BED170212663DA00F02DA0 /* SwiftSoup.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D6BED16E212663DA00F02DA0 /* SwiftSoup.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
D6BED170212663DA00F02DA0 /* SwiftSoup.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D6BED16E212663DA00F02DA0 /* SwiftSoup.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||||
D6BED174212667E900F02DA0 /* StatusTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6BED173212667E900F02DA0 /* StatusTableViewCell.swift */; };
|
D6BED174212667E900F02DA0 /* StatusTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6BED173212667E900F02DA0 /* StatusTableViewCell.swift */; };
|
||||||
D6C693EF216192C2007D6A6D /* TuskerNavigationDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C693EE216192C2007D6A6D /* TuskerNavigationDelegate.swift */; };
|
D6C693EF216192C2007D6A6D /* TuskerNavigationDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C693EE216192C2007D6A6D /* TuskerNavigationDelegate.swift */; };
|
||||||
|
@ -414,6 +416,8 @@
|
||||||
D6BC874421961F73006163F1 /* Gifu.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Gifu.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
D6BC874421961F73006163F1 /* Gifu.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Gifu.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
D6BC8747219738E1006163F1 /* EnhancedTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnhancedTableViewController.swift; sourceTree = "<group>"; };
|
D6BC8747219738E1006163F1 /* EnhancedTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnhancedTableViewController.swift; sourceTree = "<group>"; };
|
||||||
D6BC9DB0232C61BC002CA326 /* NotificationsPageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsPageViewController.swift; sourceTree = "<group>"; };
|
D6BC9DB0232C61BC002CA326 /* NotificationsPageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsPageViewController.swift; sourceTree = "<group>"; };
|
||||||
|
D6BC9DB2232D4C07002CA326 /* WellnessPrefsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WellnessPrefsView.swift; sourceTree = "<group>"; };
|
||||||
|
D6BC9DB4232D4CE3002CA326 /* NotificationsMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsMode.swift; sourceTree = "<group>"; };
|
||||||
D6BED16E212663DA00F02DA0 /* SwiftSoup.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = SwiftSoup.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
D6BED16E212663DA00F02DA0 /* SwiftSoup.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = SwiftSoup.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
D6BED173212667E900F02DA0 /* StatusTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusTableViewCell.swift; sourceTree = "<group>"; };
|
D6BED173212667E900F02DA0 /* StatusTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusTableViewCell.swift; sourceTree = "<group>"; };
|
||||||
D6C693EE216192C2007D6A6D /* TuskerNavigationDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TuskerNavigationDelegate.swift; sourceTree = "<group>"; };
|
D6C693EE216192C2007D6A6D /* TuskerNavigationDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TuskerNavigationDelegate.swift; sourceTree = "<group>"; };
|
||||||
|
@ -773,6 +777,7 @@
|
||||||
04586B4022B2FFB10021BD04 /* PreferencesView.swift */,
|
04586B4022B2FFB10021BD04 /* PreferencesView.swift */,
|
||||||
04586B4222B301470021BD04 /* AppearancePrefsView.swift */,
|
04586B4222B301470021BD04 /* AppearancePrefsView.swift */,
|
||||||
0427033722B30F5F000D31B6 /* BehaviorPrefsView.swift */,
|
0427033722B30F5F000D31B6 /* BehaviorPrefsView.swift */,
|
||||||
|
D6BC9DB2232D4C07002CA326 /* WellnessPrefsView.swift */,
|
||||||
0427033922B31269000D31B6 /* AdvancedPrefsView.swift */,
|
0427033922B31269000D31B6 /* AdvancedPrefsView.swift */,
|
||||||
0427037B22B316B9000D31B6 /* SilentActionPrefs.swift */,
|
0427037B22B316B9000D31B6 /* SilentActionPrefs.swift */,
|
||||||
);
|
);
|
||||||
|
@ -835,6 +840,7 @@
|
||||||
0427033522B30B3D000D31B6 /* Preference.swift */,
|
0427033522B30B3D000D31B6 /* Preference.swift */,
|
||||||
D6DD353C22F28CD000A9563A /* ContentWarningCopyMode.swift */,
|
D6DD353C22F28CD000A9563A /* ContentWarningCopyMode.swift */,
|
||||||
D6DD353E22F502EC00A9563A /* Preferences+Notification.swift */,
|
D6DD353E22F502EC00A9563A /* Preferences+Notification.swift */,
|
||||||
|
D6BC9DB4232D4CE3002CA326 /* NotificationsMode.swift */,
|
||||||
);
|
);
|
||||||
path = Preferences;
|
path = Preferences;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -1499,6 +1505,7 @@
|
||||||
D6AEBB412321642700E5038B /* SendMesasgeActivity.swift in Sources */,
|
D6AEBB412321642700E5038B /* SendMesasgeActivity.swift in Sources */,
|
||||||
D6BC9DB1232C61BC002CA326 /* NotificationsPageViewController.swift in Sources */,
|
D6BC9DB1232C61BC002CA326 /* NotificationsPageViewController.swift in Sources */,
|
||||||
D6C693F92162E4DB007D6A6D /* StatusContentLabel.swift in Sources */,
|
D6C693F92162E4DB007D6A6D /* StatusContentLabel.swift in Sources */,
|
||||||
|
D6BC9DB3232D4C07002CA326 /* WellnessPrefsView.swift in Sources */,
|
||||||
D6D58DF922074B74009C8DD9 /* LinkLabel.swift in Sources */,
|
D6D58DF922074B74009C8DD9 /* LinkLabel.swift in Sources */,
|
||||||
0454DDAF22B462EF00B8BB8E /* GalleryExpandAnimationController.swift in Sources */,
|
0454DDAF22B462EF00B8BB8E /* GalleryExpandAnimationController.swift in Sources */,
|
||||||
D6A3BC8A2321F79B00FD64D5 /* AccountTableViewCell.swift in Sources */,
|
D6A3BC8A2321F79B00FD64D5 /* AccountTableViewCell.swift in Sources */,
|
||||||
|
@ -1563,6 +1570,7 @@
|
||||||
D6A3BC7C232195C600FD64D5 /* ActionNotificationGroupTableViewCell.swift in Sources */,
|
D6A3BC7C232195C600FD64D5 /* ActionNotificationGroupTableViewCell.swift in Sources */,
|
||||||
D6F953EC212519E700CF0F2B /* TimelineTableViewController.swift in Sources */,
|
D6F953EC212519E700CF0F2B /* TimelineTableViewController.swift in Sources */,
|
||||||
04586B4122B2FFB10021BD04 /* PreferencesView.swift in Sources */,
|
04586B4122B2FFB10021BD04 /* PreferencesView.swift in Sources */,
|
||||||
|
D6BC9DB5232D4CE3002CA326 /* NotificationsMode.swift in Sources */,
|
||||||
D667E5EB21349EF80057A976 /* ProfileHeaderTableViewCell.swift in Sources */,
|
D667E5EB21349EF80057A976 /* ProfileHeaderTableViewCell.swift in Sources */,
|
||||||
04D14BB022B34A2800642648 /* GalleryViewController.swift in Sources */,
|
04D14BB022B34A2800642648 /* GalleryViewController.swift in Sources */,
|
||||||
D641C773213CAA25004B4513 /* NotificationsTableViewController.swift in Sources */,
|
D641C773213CAA25004B4513 /* NotificationsTableViewController.swift in Sources */,
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
//
|
||||||
|
// NotificationsMode.swift
|
||||||
|
// Tusker
|
||||||
|
//
|
||||||
|
// Created by Shadowfacts on 9/14/19.
|
||||||
|
// Copyright © 2019 Shadowfacts. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
enum NotificationsMode: String, Codable, CaseIterable {
|
||||||
|
case allNotifications
|
||||||
|
case mentionsOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
extension NotificationsMode {
|
||||||
|
var displayName: String {
|
||||||
|
switch self {
|
||||||
|
case .allNotifications:
|
||||||
|
return NSLocalizedString("All Notifications", comment: "display all notifications mode")
|
||||||
|
case .mentionsOnly:
|
||||||
|
return NSLocalizedString("Mentions Only", comment: "display only mentions mode")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -47,6 +47,8 @@ class Preferences: Codable, ObservableObject {
|
||||||
self.contentWarningCopyMode = try container.decode(ContentWarningCopyMode.self, forKey: .contentWarningCopyMode)
|
self.contentWarningCopyMode = try container.decode(ContentWarningCopyMode.self, forKey: .contentWarningCopyMode)
|
||||||
self.openLinksInApps = try container.decode(Bool.self, forKey: .openLinksInApps)
|
self.openLinksInApps = try container.decode(Bool.self, forKey: .openLinksInApps)
|
||||||
|
|
||||||
|
self.defaultNotificationsMode = try container.decode(NotificationsMode.self, forKey: .defaultNotificationsType)
|
||||||
|
|
||||||
self.silentActions = try container.decode([String: Permission].self, forKey: .silentActions)
|
self.silentActions = try container.decode([String: Permission].self, forKey: .silentActions)
|
||||||
self.statusContentType = try container.decode(StatusContentType.self, forKey: .statusContentType)
|
self.statusContentType = try container.decode(StatusContentType.self, forKey: .statusContentType)
|
||||||
}
|
}
|
||||||
|
@ -63,6 +65,8 @@ class Preferences: Codable, ObservableObject {
|
||||||
try container.encode(contentWarningCopyMode, forKey: .contentWarningCopyMode)
|
try container.encode(contentWarningCopyMode, forKey: .contentWarningCopyMode)
|
||||||
try container.encode(openLinksInApps, forKey: .openLinksInApps)
|
try container.encode(openLinksInApps, forKey: .openLinksInApps)
|
||||||
|
|
||||||
|
try container.encode(defaultNotificationsMode, forKey: .defaultNotificationsType)
|
||||||
|
|
||||||
try container.encode(silentActions, forKey: .silentActions)
|
try container.encode(silentActions, forKey: .silentActions)
|
||||||
try container.encode(statusContentType, forKey: .statusContentType)
|
try container.encode(statusContentType, forKey: .statusContentType)
|
||||||
}
|
}
|
||||||
|
@ -81,6 +85,9 @@ class Preferences: Codable, ObservableObject {
|
||||||
@Published var contentWarningCopyMode = ContentWarningCopyMode.asIs
|
@Published var contentWarningCopyMode = ContentWarningCopyMode.asIs
|
||||||
@Published var openLinksInApps = true
|
@Published var openLinksInApps = true
|
||||||
|
|
||||||
|
// MARK: - Digital Wellness
|
||||||
|
@Published var defaultNotificationsMode = NotificationsMode.allNotifications
|
||||||
|
|
||||||
// MARK: - Advanced
|
// MARK: - Advanced
|
||||||
@Published var silentActions: [String: Permission] = [:]
|
@Published var silentActions: [String: Permission] = [:]
|
||||||
@Published var statusContentType: StatusContentType = .plain
|
@Published var statusContentType: StatusContentType = .plain
|
||||||
|
@ -95,6 +102,8 @@ class Preferences: Codable, ObservableObject {
|
||||||
case contentWarningCopyMode
|
case contentWarningCopyMode
|
||||||
case openLinksInApps
|
case openLinksInApps
|
||||||
|
|
||||||
|
case defaultNotificationsType
|
||||||
|
|
||||||
case silentActions
|
case silentActions
|
||||||
case statusContentType
|
case statusContentType
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,5 +36,19 @@ class NotificationsPageViewController: SegmentedPageViewController {
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
|
||||||
|
let index: Int
|
||||||
|
switch Preferences.shared.defaultNotificationsMode {
|
||||||
|
case .allNotifications:
|
||||||
|
index = 0
|
||||||
|
case .mentionsOnly:
|
||||||
|
index = 1
|
||||||
|
}
|
||||||
|
segmentedControl.selectedSegmentIndex = index
|
||||||
|
selectPage(at: index, animated: false)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ struct BehaviorPrefsView : View {
|
||||||
}
|
}
|
||||||
|
|
||||||
var section1: some View {
|
var section1: some View {
|
||||||
Section {
|
Section(header: Text("COMPOSING")) {
|
||||||
Picker(selection: _defaultPostVisibility.binding, label: Text("Default Post Visibility")) {
|
Picker(selection: _defaultPostVisibility.binding, label: Text("Default Post Visibility")) {
|
||||||
ForEach(Status.Visibility.allCases, id: \.self) { visibility in
|
ForEach(Status.Visibility.allCases, id: \.self) { visibility in
|
||||||
HStack {
|
HStack {
|
||||||
|
@ -46,7 +46,7 @@ struct BehaviorPrefsView : View {
|
||||||
}
|
}
|
||||||
|
|
||||||
var section2: some View {
|
var section2: some View {
|
||||||
Section {
|
Section(header: Text("READING")) {
|
||||||
Toggle(isOn: _openLinksInApps.binding) {
|
Toggle(isOn: _openLinksInApps.binding) {
|
||||||
Text("Open Links in Apps")
|
Text("Open Links in Apps")
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,9 @@ struct PreferencesView : View {
|
||||||
NavigationLink(destination: BehaviorPrefsView()) {
|
NavigationLink(destination: BehaviorPrefsView()) {
|
||||||
Text("Behavior")
|
Text("Behavior")
|
||||||
}
|
}
|
||||||
|
NavigationLink(destination: WellnessPrefsView()) {
|
||||||
|
Text("Digital Wellness")
|
||||||
|
}
|
||||||
NavigationLink(destination: AdvancedPrefsView()) {
|
NavigationLink(destination: AdvancedPrefsView()) {
|
||||||
Text("Advanced")
|
Text("Advanced")
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
//
|
||||||
|
// WellnessPrefsView.swift
|
||||||
|
// Tusker
|
||||||
|
//
|
||||||
|
// Created by Shadowfacts on 9/14/19.
|
||||||
|
// Copyright © 2019 Shadowfacts. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct WellnessPrefsView: View {
|
||||||
|
@Preference(\.defaultNotificationsMode) var defaultNotificationsMode: NotificationsMode
|
||||||
|
var body: some View {
|
||||||
|
List {
|
||||||
|
notificationsModeSection
|
||||||
|
}.listStyle(GroupedListStyle())
|
||||||
|
.navigationBarTitle(Text("Digital Wellness"))
|
||||||
|
}
|
||||||
|
|
||||||
|
var notificationsModeSection: some View {
|
||||||
|
Section(footer: notificationsModeFooter) {
|
||||||
|
Picker(selection: _defaultNotificationsMode.binding, label: Text("Default Notifications Mode")) {
|
||||||
|
ForEach(NotificationsMode.allCases, id: \.self) { type in
|
||||||
|
Text(type.displayName).tag(type)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var notificationsModeFooter: some View {
|
||||||
|
Text("Choose which kinds of notifications will be shown by default in the Notifications tab.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct WellnessPrefsView_Previews: PreviewProvider {
|
||||||
|
static var previews: some View {
|
||||||
|
WellnessPrefsView()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue