Compare commits
4 Commits
6e4f89df4a
...
905b6a0a21
Author | SHA1 | Date |
---|---|---|
Shadowfacts | 905b6a0a21 | |
Shadowfacts | 6ab8f99cc2 | |
Shadowfacts | 8bb6e9403d | |
Shadowfacts | d52875cf25 |
|
@ -246,8 +246,10 @@ public class Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Notifications
|
// MARK: - Notifications
|
||||||
public func getNotifications(range: RequestRange = .default) -> Request<[Notification]> {
|
public func getNotifications(excludeTypes: [Notification.Kind], range: RequestRange = .default) -> Request<[Notification]> {
|
||||||
var request = Request<[Notification]>(method: .get, path: "/api/v1/notifications")
|
var request = Request<[Notification]>(method: .get, path: "/api/v1/notifications", queryParameters:
|
||||||
|
"exclude_types" => excludeTypes.map { $0.rawValue }
|
||||||
|
)
|
||||||
request.range = range
|
request.range = range
|
||||||
return request
|
return request
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class Notification: Decodable {
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Notification {
|
extension Notification {
|
||||||
public enum Kind: String, Decodable {
|
public enum Kind: String, Decodable, CaseIterable {
|
||||||
case mention
|
case mention
|
||||||
case reblog
|
case reblog
|
||||||
case favourite
|
case favourite
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
//
|
||||||
|
// InstanceType.swift
|
||||||
|
// Pachyderm
|
||||||
|
//
|
||||||
|
// Created by Shadowfacts on 9/11/19.
|
||||||
|
// Copyright © 2019 Shadowfacts. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
public enum InstanceType {
|
||||||
|
case mastodon, pleroma
|
||||||
|
}
|
||||||
|
|
||||||
|
public extension Instance {
|
||||||
|
var instanceType: InstanceType {
|
||||||
|
let lowercased = version.lowercased()
|
||||||
|
if lowercased.contains("pleroma") {
|
||||||
|
return .pleroma
|
||||||
|
} else {
|
||||||
|
return .mastodon
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -103,6 +103,7 @@
|
||||||
D663626C21361C6700C9CBA2 /* Account+Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = D663626B21361C6700C9CBA2 /* Account+Preferences.swift */; };
|
D663626C21361C6700C9CBA2 /* Account+Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = D663626B21361C6700C9CBA2 /* Account+Preferences.swift */; };
|
||||||
D66362712136338600C9CBA2 /* ComposeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D66362702136338600C9CBA2 /* ComposeViewController.swift */; };
|
D66362712136338600C9CBA2 /* ComposeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D66362702136338600C9CBA2 /* ComposeViewController.swift */; };
|
||||||
D66362752137068A00C9CBA2 /* Visibility+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = D66362742137068A00C9CBA2 /* Visibility+Helpers.swift */; };
|
D66362752137068A00C9CBA2 /* Visibility+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = D66362742137068A00C9CBA2 /* Visibility+Helpers.swift */; };
|
||||||
|
D667383C23299340000A2373 /* InstanceType.swift in Sources */ = {isa = PBXBuildFile; fileRef = D667383B23299340000A2373 /* InstanceType.swift */; };
|
||||||
D667E5E12134937B0057A976 /* StatusTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D667E5E02134937B0057A976 /* StatusTableViewCell.xib */; };
|
D667E5E12134937B0057A976 /* StatusTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D667E5E02134937B0057A976 /* StatusTableViewCell.xib */; };
|
||||||
D667E5E721349D4C0057A976 /* ProfileTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D667E5E621349D4C0057A976 /* ProfileTableViewController.swift */; };
|
D667E5E721349D4C0057A976 /* ProfileTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D667E5E621349D4C0057A976 /* ProfileTableViewController.swift */; };
|
||||||
D667E5E921349EE50057A976 /* ProfileHeaderTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D667E5E821349EE50057A976 /* ProfileHeaderTableViewCell.xib */; };
|
D667E5E921349EE50057A976 /* ProfileHeaderTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D667E5E821349EE50057A976 /* ProfileHeaderTableViewCell.xib */; };
|
||||||
|
@ -142,6 +143,7 @@
|
||||||
D68632AA21ED8319008C716E /* GMGridViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D686329021ED8319008C716E /* GMGridViewController.m */; };
|
D68632AA21ED8319008C716E /* GMGridViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D686329021ED8319008C716E /* GMGridViewController.m */; };
|
||||||
D68632AB21ED8319008C716E /* GMImagePickerController.h in Headers */ = {isa = PBXBuildFile; fileRef = D686329121ED8319008C716E /* GMImagePickerController.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
D68632AB21ED8319008C716E /* GMImagePickerController.h in Headers */ = {isa = PBXBuildFile; fileRef = D686329121ED8319008C716E /* GMImagePickerController.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
D68632AC21ED8319008C716E /* GMImagePicker.strings in Resources */ = {isa = PBXBuildFile; fileRef = D686329321ED8319008C716E /* GMImagePicker.strings */; };
|
D68632AC21ED8319008C716E /* GMImagePicker.strings in Resources */ = {isa = PBXBuildFile; fileRef = D686329321ED8319008C716E /* GMImagePicker.strings */; };
|
||||||
|
D68FEC4F232C5BC300C84F23 /* SegmentedPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D68FEC4E232C5BC300C84F23 /* SegmentedPageViewController.swift */; };
|
||||||
D6A3BC7723218E1300FD64D5 /* TimelineSegment.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6A3BC7323218C6E00FD64D5 /* TimelineSegment.swift */; };
|
D6A3BC7723218E1300FD64D5 /* TimelineSegment.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6A3BC7323218C6E00FD64D5 /* TimelineSegment.swift */; };
|
||||||
D6A3BC7923218E9200FD64D5 /* NotificationGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6A3BC7823218E9200FD64D5 /* NotificationGroup.swift */; };
|
D6A3BC7923218E9200FD64D5 /* NotificationGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6A3BC7823218E9200FD64D5 /* NotificationGroup.swift */; };
|
||||||
D6A3BC7C232195C600FD64D5 /* ActionNotificationGroupTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6A3BC7A232195C600FD64D5 /* ActionNotificationGroupTableViewCell.swift */; };
|
D6A3BC7C232195C600FD64D5 /* ActionNotificationGroupTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6A3BC7A232195C600FD64D5 /* ActionNotificationGroupTableViewCell.swift */; };
|
||||||
|
@ -164,6 +166,9 @@
|
||||||
D6BC874521961F73006163F1 /* Gifu.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6BC874421961F73006163F1 /* Gifu.framework */; };
|
D6BC874521961F73006163F1 /* Gifu.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6BC874421961F73006163F1 /* Gifu.framework */; };
|
||||||
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 */; };
|
||||||
|
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 */; };
|
||||||
|
@ -348,6 +353,7 @@
|
||||||
D663626B21361C6700C9CBA2 /* Account+Preferences.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Account+Preferences.swift"; sourceTree = "<group>"; };
|
D663626B21361C6700C9CBA2 /* Account+Preferences.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Account+Preferences.swift"; sourceTree = "<group>"; };
|
||||||
D66362702136338600C9CBA2 /* ComposeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposeViewController.swift; sourceTree = "<group>"; };
|
D66362702136338600C9CBA2 /* ComposeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposeViewController.swift; sourceTree = "<group>"; };
|
||||||
D66362742137068A00C9CBA2 /* Visibility+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Visibility+Helpers.swift"; sourceTree = "<group>"; };
|
D66362742137068A00C9CBA2 /* Visibility+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Visibility+Helpers.swift"; sourceTree = "<group>"; };
|
||||||
|
D667383B23299340000A2373 /* InstanceType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstanceType.swift; sourceTree = "<group>"; };
|
||||||
D667E5E02134937B0057A976 /* StatusTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = StatusTableViewCell.xib; sourceTree = "<group>"; };
|
D667E5E02134937B0057A976 /* StatusTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = StatusTableViewCell.xib; sourceTree = "<group>"; };
|
||||||
D667E5E621349D4C0057A976 /* ProfileTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileTableViewController.swift; sourceTree = "<group>"; };
|
D667E5E621349D4C0057A976 /* ProfileTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileTableViewController.swift; sourceTree = "<group>"; };
|
||||||
D667E5E821349EE50057A976 /* ProfileHeaderTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ProfileHeaderTableViewCell.xib; sourceTree = "<group>"; };
|
D667E5E821349EE50057A976 /* ProfileHeaderTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ProfileHeaderTableViewCell.xib; sourceTree = "<group>"; };
|
||||||
|
@ -387,6 +393,7 @@
|
||||||
D686329021ED8319008C716E /* GMGridViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GMGridViewController.m; sourceTree = "<group>"; };
|
D686329021ED8319008C716E /* GMGridViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GMGridViewController.m; sourceTree = "<group>"; };
|
||||||
D686329121ED8319008C716E /* GMImagePickerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GMImagePickerController.h; sourceTree = "<group>"; };
|
D686329121ED8319008C716E /* GMImagePickerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GMImagePickerController.h; sourceTree = "<group>"; };
|
||||||
D686329421ED8319008C716E /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = GMImagePicker.strings; sourceTree = "<group>"; };
|
D686329421ED8319008C716E /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = GMImagePicker.strings; sourceTree = "<group>"; };
|
||||||
|
D68FEC4E232C5BC300C84F23 /* SegmentedPageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SegmentedPageViewController.swift; sourceTree = "<group>"; };
|
||||||
D6A3BC7323218C6E00FD64D5 /* TimelineSegment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineSegment.swift; sourceTree = "<group>"; };
|
D6A3BC7323218C6E00FD64D5 /* TimelineSegment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineSegment.swift; sourceTree = "<group>"; };
|
||||||
D6A3BC7823218E9200FD64D5 /* NotificationGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationGroup.swift; sourceTree = "<group>"; };
|
D6A3BC7823218E9200FD64D5 /* NotificationGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationGroup.swift; sourceTree = "<group>"; };
|
||||||
D6A3BC7A232195C600FD64D5 /* ActionNotificationGroupTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionNotificationGroupTableViewCell.swift; sourceTree = "<group>"; };
|
D6A3BC7A232195C600FD64D5 /* ActionNotificationGroupTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionNotificationGroupTableViewCell.swift; sourceTree = "<group>"; };
|
||||||
|
@ -408,6 +415,9 @@
|
||||||
D6B8DB332182A59300424AF7 /* UIAlertController+Visibility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIAlertController+Visibility.swift"; sourceTree = "<group>"; };
|
D6B8DB332182A59300424AF7 /* UIAlertController+Visibility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIAlertController+Visibility.swift"; sourceTree = "<group>"; };
|
||||||
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>"; };
|
||||||
|
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>"; };
|
||||||
|
@ -734,6 +744,7 @@
|
||||||
D641C786213DD852004B4513 /* Notifications */ = {
|
D641C786213DD852004B4513 /* Notifications */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
D6BC9DB0232C61BC002CA326 /* NotificationsPageViewController.swift */,
|
||||||
D641C772213CAA25004B4513 /* NotificationsTableViewController.swift */,
|
D641C772213CAA25004B4513 /* NotificationsTableViewController.swift */,
|
||||||
);
|
);
|
||||||
path = Notifications;
|
path = Notifications;
|
||||||
|
@ -766,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 */,
|
||||||
);
|
);
|
||||||
|
@ -828,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>";
|
||||||
|
@ -947,6 +960,7 @@
|
||||||
D6E6F26221603F8B006A8599 /* CharacterCounter.swift */,
|
D6E6F26221603F8B006A8599 /* CharacterCounter.swift */,
|
||||||
D6A3BC7323218C6E00FD64D5 /* TimelineSegment.swift */,
|
D6A3BC7323218C6E00FD64D5 /* TimelineSegment.swift */,
|
||||||
D6A3BC7823218E9200FD64D5 /* NotificationGroup.swift */,
|
D6A3BC7823218E9200FD64D5 /* NotificationGroup.swift */,
|
||||||
|
D667383B23299340000A2373 /* InstanceType.swift */,
|
||||||
);
|
);
|
||||||
path = Utilities;
|
path = Utilities;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -1026,6 +1040,7 @@
|
||||||
D6538944214D6D7500E3CEFC /* TableViewSwipeActionProvider.swift */,
|
D6538944214D6D7500E3CEFC /* TableViewSwipeActionProvider.swift */,
|
||||||
D6B8DB332182A59300424AF7 /* UIAlertController+Visibility.swift */,
|
D6B8DB332182A59300424AF7 /* UIAlertController+Visibility.swift */,
|
||||||
D6BC8747219738E1006163F1 /* EnhancedTableViewController.swift */,
|
D6BC8747219738E1006163F1 /* EnhancedTableViewController.swift */,
|
||||||
|
D68FEC4E232C5BC300C84F23 /* SegmentedPageViewController.swift */,
|
||||||
);
|
);
|
||||||
path = Utilities;
|
path = Utilities;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -1428,6 +1443,7 @@
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
D61099E5214561AB00432DC2 /* Application.swift in Sources */,
|
D61099E5214561AB00432DC2 /* Application.swift in Sources */,
|
||||||
|
D667383C23299340000A2373 /* InstanceType.swift in Sources */,
|
||||||
D61099FF21456A4C00432DC2 /* Status.swift in Sources */,
|
D61099FF21456A4C00432DC2 /* Status.swift in Sources */,
|
||||||
D61099E32144C38900432DC2 /* Emoji.swift in Sources */,
|
D61099E32144C38900432DC2 /* Emoji.swift in Sources */,
|
||||||
D6109A0D214599E100432DC2 /* RequestRange.swift in Sources */,
|
D6109A0D214599E100432DC2 /* RequestRange.swift in Sources */,
|
||||||
|
@ -1487,10 +1503,13 @@
|
||||||
D6757A822157E8FA00721E32 /* XCBSession.swift in Sources */,
|
D6757A822157E8FA00721E32 /* XCBSession.swift in Sources */,
|
||||||
04DACE8C212CB14B009840C4 /* MainTabBarViewController.swift in Sources */,
|
04DACE8C212CB14B009840C4 /* MainTabBarViewController.swift in Sources */,
|
||||||
D6AEBB412321642700E5038B /* SendMesasgeActivity.swift in Sources */,
|
D6AEBB412321642700E5038B /* SendMesasgeActivity.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 */,
|
||||||
|
D68FEC4F232C5BC300C84F23 /* SegmentedPageViewController.swift in Sources */,
|
||||||
0450531F22B0097E00100BA2 /* Timline+UI.swift in Sources */,
|
0450531F22B0097E00100BA2 /* Timline+UI.swift in Sources */,
|
||||||
D667E5F52135BCD50057A976 /* ConversationTableViewController.swift in Sources */,
|
D667E5F52135BCD50057A976 /* ConversationTableViewController.swift in Sources */,
|
||||||
D6C7D27D22B6EBF800071952 /* AttachmentsContainerView.swift in Sources */,
|
D6C7D27D22B6EBF800071952 /* AttachmentsContainerView.swift in Sources */,
|
||||||
|
@ -1551,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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -35,34 +35,79 @@ class Preferences: Codable, ObservableObject {
|
||||||
|
|
||||||
private init() {}
|
private init() {}
|
||||||
|
|
||||||
|
required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
|
self.showRepliesInProfiles = try container.decode(Bool.self, forKey: .showRepliesInProfiles)
|
||||||
|
self.avatarStyle = try container.decode(AvatarStyle.self, forKey: .avatarStyle)
|
||||||
|
self.hideCustomEmojiInUsernames = try container.decode(Bool.self, forKey: .hideCustomEmojiInUsernames)
|
||||||
|
|
||||||
|
self.defaultPostVisibility = try container.decode(Status.Visibility.self, forKey: .defaultPostVisibility)
|
||||||
|
self.automaticallySaveDrafts = try container.decode(Bool.self, forKey: .automaticallySaveDrafts)
|
||||||
|
self.contentWarningCopyMode = try container.decode(ContentWarningCopyMode.self, forKey: .contentWarningCopyMode)
|
||||||
|
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.statusContentType = try container.decode(StatusContentType.self, forKey: .statusContentType)
|
||||||
|
}
|
||||||
|
|
||||||
|
func encode(to encoder: Encoder) throws {
|
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
|
try container.encode(showRepliesInProfiles, forKey: .showRepliesInProfiles)
|
||||||
|
try container.encode(avatarStyle, forKey: .avatarStyle)
|
||||||
|
try container.encode(hideCustomEmojiInUsernames, forKey: .hideCustomEmojiInUsernames)
|
||||||
|
|
||||||
|
try container.encode(defaultPostVisibility, forKey: .defaultPostVisibility)
|
||||||
|
try container.encode(automaticallySaveDrafts, forKey: .automaticallySaveDrafts)
|
||||||
|
try container.encode(contentWarningCopyMode, forKey: .contentWarningCopyMode)
|
||||||
|
try container.encode(openLinksInApps, forKey: .openLinksInApps)
|
||||||
|
|
||||||
|
try container.encode(defaultNotificationsMode, forKey: .defaultNotificationsType)
|
||||||
|
|
||||||
|
try container.encode(silentActions, forKey: .silentActions)
|
||||||
|
try container.encode(statusContentType, forKey: .statusContentType)
|
||||||
|
}
|
||||||
|
|
||||||
typealias ObjectWillChangePublisher = PassthroughSubject<Preferences, Never>
|
typealias ObjectWillChangePublisher = PassthroughSubject<Preferences, Never>
|
||||||
let objectWillChange = PassthroughSubject<Preferences, Never>()
|
let objectWillChange = PassthroughSubject<Preferences, Never>()
|
||||||
|
|
||||||
// MARK: - Appearance
|
// MARK: - Appearance
|
||||||
var showRepliesInProfiles = false { willSet { objectWillChange.send(self) } }
|
@Published var showRepliesInProfiles = false
|
||||||
var avatarStyle = AvatarStyle.roundRect { willSet { objectWillChange.send(self) } }
|
@Published var avatarStyle = AvatarStyle.roundRect
|
||||||
var hideCustomEmojiInUsernames = false { willSet { objectWillChange.send(self) } }
|
@Published var hideCustomEmojiInUsernames = false
|
||||||
|
|
||||||
// MARK: - Behavior
|
// MARK: - Behavior
|
||||||
var defaultPostVisibility = Status.Visibility.public { willSet { objectWillChange.send(self) } }
|
@Published var defaultPostVisibility = Status.Visibility.public
|
||||||
var automaticallySaveDrafts = true { willSet { objectWillChange.send(self) } }
|
@Published var automaticallySaveDrafts = true
|
||||||
var contentWarningCopyMode = ContentWarningCopyMode.asIs { willSet { objectWillChange.send(self) } }
|
@Published var contentWarningCopyMode = ContentWarningCopyMode.asIs
|
||||||
var openLinksInApps = true { willSet { objectWillChange.send(self) } }
|
@Published var openLinksInApps = true
|
||||||
|
|
||||||
|
// MARK: - Digital Wellness
|
||||||
|
@Published var defaultNotificationsMode = NotificationsMode.allNotifications
|
||||||
|
|
||||||
// MARK: - Advanced
|
// MARK: - Advanced
|
||||||
var silentActions: [String: Permission] = [:] { willSet { objectWillChange.send(self) } }
|
@Published var silentActions: [String: Permission] = [:]
|
||||||
var statusContentType: StatusContentType = .plain { willSet { objectWillChange.send(self) } }
|
@Published var statusContentType: StatusContentType = .plain
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
extension PassthroughSubject: Codable {
|
enum CodingKeys: String, CodingKey {
|
||||||
public convenience init(from decoder: Decoder) throws {
|
case showRepliesInProfiles
|
||||||
self.init()
|
case avatarStyle
|
||||||
|
case hideCustomEmojiInUsernames
|
||||||
|
|
||||||
|
case defaultPostVisibility
|
||||||
|
case automaticallySaveDrafts
|
||||||
|
case contentWarningCopyMode
|
||||||
|
case openLinksInApps
|
||||||
|
|
||||||
|
case defaultNotificationsType
|
||||||
|
|
||||||
|
case silentActions
|
||||||
|
case statusContentType
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Preferences {
|
extension Preferences {
|
||||||
|
|
|
@ -283,7 +283,12 @@ class ComposeViewController: UIViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateAddAttachmentButton() {
|
func updateAddAttachmentButton() {
|
||||||
addAttachmentButton.isEnabled = selectedAssets.count < 5 // 4 attachments + 1 button
|
switch MastodonController.instance.instanceType {
|
||||||
|
case .pleroma:
|
||||||
|
addAttachmentButton.isEnabled = true
|
||||||
|
case .mastodon:
|
||||||
|
addAttachmentButton.isEnabled = selectedAssets.count <= 4 && selectedAssets.first(where: { $0.mediaType == .video }) == nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateAttachmentViews() {
|
func updateAttachmentViews() {
|
||||||
|
@ -311,7 +316,6 @@ class ComposeViewController: UIViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
func saveDraft() {
|
func saveDraft() {
|
||||||
// TODO: save CW to draft
|
|
||||||
var attachments = [DraftsManager.DraftAttachment]()
|
var attachments = [DraftsManager.DraftAttachment]()
|
||||||
for asset in selectedAssets {
|
for asset in selectedAssets {
|
||||||
let index = attachments.count
|
let index = attachments.count
|
||||||
|
@ -559,7 +563,15 @@ extension ComposeViewController: GMImagePickerControllerDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
func assetsPickerController(_ picker: GMImagePickerController!, shouldSelect asset: PHAsset!) -> Bool {
|
func assetsPickerController(_ picker: GMImagePickerController!, shouldSelect asset: PHAsset!) -> Bool {
|
||||||
return selectedAssets.count + picker.selectedAssets.count < 4
|
switch MastodonController.instance.instanceType {
|
||||||
|
case .pleroma:
|
||||||
|
return true
|
||||||
|
case .mastodon:
|
||||||
|
if (asset.mediaType == .video && selectedAssets.count > 0) || selectedAssets.first(where: { $0.mediaType == .video }) != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return selectedAssets.count + picker.selectedAssets.count < 4
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ class MainTabBarViewController: UITabBarController, UITabBarControllerDelegate {
|
||||||
|
|
||||||
viewControllers = [
|
viewControllers = [
|
||||||
embedInNavigationController(TimelineTableViewController(for: .home)),
|
embedInNavigationController(TimelineTableViewController(for: .home)),
|
||||||
embedInNavigationController(NotificationsTableViewController()),
|
embedInNavigationController(NotificationsPageViewController()),
|
||||||
ComposeViewController(),
|
ComposeViewController(),
|
||||||
embedInNavigationController(TimelineTableViewController(for: .public(local: false))),
|
embedInNavigationController(TimelineTableViewController(for: .public(local: false))),
|
||||||
embedInNavigationController(MyProfileTableViewController()),
|
embedInNavigationController(MyProfileTableViewController()),
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
//
|
||||||
|
// NotificationsPageViewController.swift
|
||||||
|
// Tusker
|
||||||
|
//
|
||||||
|
// Created by Shadowfacts on 9/13/19.
|
||||||
|
// Copyright © 2019 Shadowfacts. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
import Pachyderm
|
||||||
|
|
||||||
|
class NotificationsPageViewController: SegmentedPageViewController {
|
||||||
|
|
||||||
|
private let notificationsTitle = NSLocalizedString("Notifications", comment: "notifications tab title")
|
||||||
|
private let mentionsTitle = NSLocalizedString("Mentions", comment: "mentions tab title")
|
||||||
|
|
||||||
|
init() {
|
||||||
|
let notifications = NotificationsTableViewController(allowedTypes: Pachyderm.Notification.Kind.allCases)
|
||||||
|
notifications.title = notificationsTitle
|
||||||
|
|
||||||
|
let mentions = NotificationsTableViewController(allowedTypes: [.mention])
|
||||||
|
mentions.title = mentionsTitle
|
||||||
|
|
||||||
|
super.init(titles: [
|
||||||
|
notificationsTitle,
|
||||||
|
mentionsTitle
|
||||||
|
], pageControllers: [
|
||||||
|
notifications,
|
||||||
|
mentions
|
||||||
|
])
|
||||||
|
|
||||||
|
title = notificationsTitle
|
||||||
|
tabBarItem.image = UIImage(systemName: "bell.fill")
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder: NSCoder) {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -15,8 +15,9 @@ class NotificationsTableViewController: EnhancedTableViewController {
|
||||||
private let actionGroupCell = "actionGroupCell"
|
private let actionGroupCell = "actionGroupCell"
|
||||||
private let followGroupCell = "followGroupCell"
|
private let followGroupCell = "followGroupCell"
|
||||||
|
|
||||||
|
let excludedTypes: [Pachyderm.Notification.Kind]
|
||||||
let groupTypes = [Notification.Kind.favourite, .reblog, .follow]
|
let groupTypes = [Notification.Kind.favourite, .reblog, .follow]
|
||||||
|
|
||||||
var groups: [NotificationGroup] = [] {
|
var groups: [NotificationGroup] = [] {
|
||||||
didSet {
|
didSet {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
|
@ -28,12 +29,11 @@ class NotificationsTableViewController: EnhancedTableViewController {
|
||||||
var newer: RequestRange?
|
var newer: RequestRange?
|
||||||
var older: RequestRange?
|
var older: RequestRange?
|
||||||
|
|
||||||
init() {
|
init(allowedTypes: [Pachyderm.Notification.Kind]) {
|
||||||
|
self.excludedTypes = Array(Set(Pachyderm.Notification.Kind.allCases).subtracting(allowedTypes))
|
||||||
|
|
||||||
super.init(style: .plain)
|
super.init(style: .plain)
|
||||||
|
|
||||||
title = "Notifications"
|
|
||||||
tabBarItem.image = UIImage(systemName: "bell.fill")
|
|
||||||
|
|
||||||
self.refreshControl = UIRefreshControl()
|
self.refreshControl = UIRefreshControl()
|
||||||
refreshControl!.addTarget(self, action: #selector(refreshNotifications(_:)), for: .valueChanged)
|
refreshControl!.addTarget(self, action: #selector(refreshNotifications(_:)), for: .valueChanged)
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ class NotificationsTableViewController: EnhancedTableViewController {
|
||||||
|
|
||||||
tableView.prefetchDataSource = self
|
tableView.prefetchDataSource = self
|
||||||
|
|
||||||
let request = MastodonController.client.getNotifications()
|
let request = MastodonController.client.getNotifications(excludeTypes: excludedTypes)
|
||||||
MastodonController.client.run(request) { result in
|
MastodonController.client.run(request) { result in
|
||||||
guard case let .success(notifications, pagination) = result else { fatalError() }
|
guard case let .success(notifications, pagination) = result else { fatalError() }
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ class NotificationsTableViewController: EnhancedTableViewController {
|
||||||
if indexPath.row == groups.count - 1 {
|
if indexPath.row == groups.count - 1 {
|
||||||
guard let older = older else { return }
|
guard let older = older else { return }
|
||||||
|
|
||||||
let request = MastodonController.client.getNotifications(range: older)
|
let request = MastodonController.client.getNotifications(excludeTypes: excludedTypes, range: older)
|
||||||
MastodonController.client.run(request) { result in
|
MastodonController.client.run(request) { result in
|
||||||
guard case let .success(newNotifications, pagination) = result else { fatalError() }
|
guard case let .success(newNotifications, pagination) = result else { fatalError() }
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ class NotificationsTableViewController: EnhancedTableViewController {
|
||||||
@objc func refreshNotifications(_ sender: Any) {
|
@objc func refreshNotifications(_ sender: Any) {
|
||||||
guard let newer = newer else { return }
|
guard let newer = newer else { return }
|
||||||
|
|
||||||
let request = MastodonController.client.getNotifications(range: newer)
|
let request = MastodonController.client.getNotifications(excludeTypes: excludedTypes, range: newer)
|
||||||
MastodonController.client.run(request) { result in
|
MastodonController.client.run(request) { result in
|
||||||
guard case let .success(newNotifications, pagination) = result else { fatalError() }
|
guard case let .success(newNotifications, pagination) = result else { fatalError() }
|
||||||
|
|
||||||
|
|
|
@ -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()
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
//
|
||||||
|
// SegmentedPageViewController.swift
|
||||||
|
// Tusker
|
||||||
|
//
|
||||||
|
// Created by Shadowfacts on 9/13/19.
|
||||||
|
// Copyright © 2019 Shadowfacts. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
class SegmentedPageViewController: UIPageViewController, UIPageViewControllerDataSource, UIPageViewControllerDelegate {
|
||||||
|
|
||||||
|
let titles: [String]
|
||||||
|
let pageControllers: [UIViewController]
|
||||||
|
|
||||||
|
private(set) var currentIndex: Int!
|
||||||
|
|
||||||
|
var segmentedControl: UISegmentedControl!
|
||||||
|
|
||||||
|
init(titles: [String], pageControllers: [UIViewController]) {
|
||||||
|
self.titles = titles
|
||||||
|
self.pageControllers = pageControllers
|
||||||
|
|
||||||
|
super.init(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
|
||||||
|
|
||||||
|
self.dataSource = self
|
||||||
|
self.delegate = self
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
|
||||||
|
view.backgroundColor = .systemBackground
|
||||||
|
|
||||||
|
segmentedControl = UISegmentedControl(items: titles)
|
||||||
|
segmentedControl.addTarget(self, action: #selector(segmentedControlChanged), for: .valueChanged)
|
||||||
|
navigationItem.titleView = segmentedControl
|
||||||
|
|
||||||
|
segmentedControl.selectedSegmentIndex = 0
|
||||||
|
selectPage(at: 0, animated: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func selectPage(at index: Int, animated: Bool) {
|
||||||
|
let direction: UIPageViewController.NavigationDirection = currentIndex == nil ? .forward : index - currentIndex > 0 ? .forward : .reverse
|
||||||
|
setViewControllers([pageControllers[index]], direction: direction, animated: animated)
|
||||||
|
navigationItem.title = pageControllers[index].title
|
||||||
|
currentIndex = index
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func segmentedControlChanged() {
|
||||||
|
selectPage(at: segmentedControl.selectedSegmentIndex, animated: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Page View Controller Data Source
|
||||||
|
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
|
||||||
|
guard let index = pageControllers.firstIndex(of: viewController),
|
||||||
|
index > 0 else { return nil }
|
||||||
|
return pageControllers[index - 1]
|
||||||
|
}
|
||||||
|
|
||||||
|
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
|
||||||
|
guard let index = pageControllers.firstIndex(of: viewController),
|
||||||
|
index < pageControllers.count - 1 else { return nil }
|
||||||
|
return pageControllers[index + 1]
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Page View Controller Delegate
|
||||||
|
func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {
|
||||||
|
currentIndex = pageControllers.firstIndex(of: viewControllers!.first!)!
|
||||||
|
segmentedControl.selectedSegmentIndex = currentIndex
|
||||||
|
navigationItem.title = viewControllers!.first!.title
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue