Compare commits
No commits in common. "905b6a0a213d376eae5228584799c55b7be68b52" and "6e4f89df4a5a799ef6b6568710c731576db27b5e" have entirely different histories.
905b6a0a21
...
6e4f89df4a
|
@ -246,10 +246,8 @@ public class Client {
|
|||
}
|
||||
|
||||
// MARK: - Notifications
|
||||
public func getNotifications(excludeTypes: [Notification.Kind], range: RequestRange = .default) -> Request<[Notification]> {
|
||||
var request = Request<[Notification]>(method: .get, path: "/api/v1/notifications", queryParameters:
|
||||
"exclude_types" => excludeTypes.map { $0.rawValue }
|
||||
)
|
||||
public func getNotifications(range: RequestRange = .default) -> Request<[Notification]> {
|
||||
var request = Request<[Notification]>(method: .get, path: "/api/v1/notifications")
|
||||
request.range = range
|
||||
return request
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class Notification: Decodable {
|
|||
}
|
||||
|
||||
extension Notification {
|
||||
public enum Kind: String, Decodable, CaseIterable {
|
||||
public enum Kind: String, Decodable {
|
||||
case mention
|
||||
case reblog
|
||||
case favourite
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
//
|
||||
// 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,7 +103,6 @@
|
|||
D663626C21361C6700C9CBA2 /* Account+Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = D663626B21361C6700C9CBA2 /* Account+Preferences.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 */; };
|
||||
D667383C23299340000A2373 /* InstanceType.swift in Sources */ = {isa = PBXBuildFile; fileRef = D667383B23299340000A2373 /* InstanceType.swift */; };
|
||||
D667E5E12134937B0057A976 /* StatusTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D667E5E02134937B0057A976 /* StatusTableViewCell.xib */; };
|
||||
D667E5E721349D4C0057A976 /* ProfileTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D667E5E621349D4C0057A976 /* ProfileTableViewController.swift */; };
|
||||
D667E5E921349EE50057A976 /* ProfileHeaderTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D667E5E821349EE50057A976 /* ProfileHeaderTableViewCell.xib */; };
|
||||
|
@ -143,7 +142,6 @@
|
|||
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, ); }; };
|
||||
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 */; };
|
||||
D6A3BC7923218E9200FD64D5 /* NotificationGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6A3BC7823218E9200FD64D5 /* NotificationGroup.swift */; };
|
||||
D6A3BC7C232195C600FD64D5 /* ActionNotificationGroupTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6A3BC7A232195C600FD64D5 /* ActionNotificationGroupTableViewCell.swift */; };
|
||||
|
@ -166,9 +164,6 @@
|
|||
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, ); }; };
|
||||
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, ); }; };
|
||||
D6BED174212667E900F02DA0 /* StatusTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6BED173212667E900F02DA0 /* StatusTableViewCell.swift */; };
|
||||
D6C693EF216192C2007D6A6D /* TuskerNavigationDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C693EE216192C2007D6A6D /* TuskerNavigationDelegate.swift */; };
|
||||
|
@ -353,7 +348,6 @@
|
|||
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>"; };
|
||||
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>"; };
|
||||
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>"; };
|
||||
|
@ -393,7 +387,6 @@
|
|||
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>"; };
|
||||
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>"; };
|
||||
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>"; };
|
||||
|
@ -415,9 +408,6 @@
|
|||
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; };
|
||||
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; };
|
||||
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>"; };
|
||||
|
@ -744,7 +734,6 @@
|
|||
D641C786213DD852004B4513 /* Notifications */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D6BC9DB0232C61BC002CA326 /* NotificationsPageViewController.swift */,
|
||||
D641C772213CAA25004B4513 /* NotificationsTableViewController.swift */,
|
||||
);
|
||||
path = Notifications;
|
||||
|
@ -777,7 +766,6 @@
|
|||
04586B4022B2FFB10021BD04 /* PreferencesView.swift */,
|
||||
04586B4222B301470021BD04 /* AppearancePrefsView.swift */,
|
||||
0427033722B30F5F000D31B6 /* BehaviorPrefsView.swift */,
|
||||
D6BC9DB2232D4C07002CA326 /* WellnessPrefsView.swift */,
|
||||
0427033922B31269000D31B6 /* AdvancedPrefsView.swift */,
|
||||
0427037B22B316B9000D31B6 /* SilentActionPrefs.swift */,
|
||||
);
|
||||
|
@ -840,7 +828,6 @@
|
|||
0427033522B30B3D000D31B6 /* Preference.swift */,
|
||||
D6DD353C22F28CD000A9563A /* ContentWarningCopyMode.swift */,
|
||||
D6DD353E22F502EC00A9563A /* Preferences+Notification.swift */,
|
||||
D6BC9DB4232D4CE3002CA326 /* NotificationsMode.swift */,
|
||||
);
|
||||
path = Preferences;
|
||||
sourceTree = "<group>";
|
||||
|
@ -960,7 +947,6 @@
|
|||
D6E6F26221603F8B006A8599 /* CharacterCounter.swift */,
|
||||
D6A3BC7323218C6E00FD64D5 /* TimelineSegment.swift */,
|
||||
D6A3BC7823218E9200FD64D5 /* NotificationGroup.swift */,
|
||||
D667383B23299340000A2373 /* InstanceType.swift */,
|
||||
);
|
||||
path = Utilities;
|
||||
sourceTree = "<group>";
|
||||
|
@ -1040,7 +1026,6 @@
|
|||
D6538944214D6D7500E3CEFC /* TableViewSwipeActionProvider.swift */,
|
||||
D6B8DB332182A59300424AF7 /* UIAlertController+Visibility.swift */,
|
||||
D6BC8747219738E1006163F1 /* EnhancedTableViewController.swift */,
|
||||
D68FEC4E232C5BC300C84F23 /* SegmentedPageViewController.swift */,
|
||||
);
|
||||
path = Utilities;
|
||||
sourceTree = "<group>";
|
||||
|
@ -1443,7 +1428,6 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D61099E5214561AB00432DC2 /* Application.swift in Sources */,
|
||||
D667383C23299340000A2373 /* InstanceType.swift in Sources */,
|
||||
D61099FF21456A4C00432DC2 /* Status.swift in Sources */,
|
||||
D61099E32144C38900432DC2 /* Emoji.swift in Sources */,
|
||||
D6109A0D214599E100432DC2 /* RequestRange.swift in Sources */,
|
||||
|
@ -1503,13 +1487,10 @@
|
|||
D6757A822157E8FA00721E32 /* XCBSession.swift in Sources */,
|
||||
04DACE8C212CB14B009840C4 /* MainTabBarViewController.swift in Sources */,
|
||||
D6AEBB412321642700E5038B /* SendMesasgeActivity.swift in Sources */,
|
||||
D6BC9DB1232C61BC002CA326 /* NotificationsPageViewController.swift in Sources */,
|
||||
D6C693F92162E4DB007D6A6D /* StatusContentLabel.swift in Sources */,
|
||||
D6BC9DB3232D4C07002CA326 /* WellnessPrefsView.swift in Sources */,
|
||||
D6D58DF922074B74009C8DD9 /* LinkLabel.swift in Sources */,
|
||||
0454DDAF22B462EF00B8BB8E /* GalleryExpandAnimationController.swift in Sources */,
|
||||
D6A3BC8A2321F79B00FD64D5 /* AccountTableViewCell.swift in Sources */,
|
||||
D68FEC4F232C5BC300C84F23 /* SegmentedPageViewController.swift in Sources */,
|
||||
0450531F22B0097E00100BA2 /* Timline+UI.swift in Sources */,
|
||||
D667E5F52135BCD50057A976 /* ConversationTableViewController.swift in Sources */,
|
||||
D6C7D27D22B6EBF800071952 /* AttachmentsContainerView.swift in Sources */,
|
||||
|
@ -1570,7 +1551,6 @@
|
|||
D6A3BC7C232195C600FD64D5 /* ActionNotificationGroupTableViewCell.swift in Sources */,
|
||||
D6F953EC212519E700CF0F2B /* TimelineTableViewController.swift in Sources */,
|
||||
04586B4122B2FFB10021BD04 /* PreferencesView.swift in Sources */,
|
||||
D6BC9DB5232D4CE3002CA326 /* NotificationsMode.swift in Sources */,
|
||||
D667E5EB21349EF80057A976 /* ProfileHeaderTableViewCell.swift in Sources */,
|
||||
04D14BB022B34A2800642648 /* GalleryViewController.swift in Sources */,
|
||||
D641C773213CAA25004B4513 /* NotificationsTableViewController.swift in Sources */,
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
//
|
||||
// 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,79 +35,34 @@ class Preferences: Codable, ObservableObject {
|
|||
|
||||
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>
|
||||
let objectWillChange = PassthroughSubject<Preferences, Never>()
|
||||
|
||||
// MARK: - Appearance
|
||||
@Published var showRepliesInProfiles = false
|
||||
@Published var avatarStyle = AvatarStyle.roundRect
|
||||
@Published var hideCustomEmojiInUsernames = false
|
||||
var showRepliesInProfiles = false { willSet { objectWillChange.send(self) } }
|
||||
var avatarStyle = AvatarStyle.roundRect { willSet { objectWillChange.send(self) } }
|
||||
var hideCustomEmojiInUsernames = false { willSet { objectWillChange.send(self) } }
|
||||
|
||||
// MARK: - Behavior
|
||||
@Published var defaultPostVisibility = Status.Visibility.public
|
||||
@Published var automaticallySaveDrafts = true
|
||||
@Published var contentWarningCopyMode = ContentWarningCopyMode.asIs
|
||||
@Published var openLinksInApps = true
|
||||
|
||||
// MARK: - Digital Wellness
|
||||
@Published var defaultNotificationsMode = NotificationsMode.allNotifications
|
||||
var defaultPostVisibility = Status.Visibility.public { willSet { objectWillChange.send(self) } }
|
||||
var automaticallySaveDrafts = true { willSet { objectWillChange.send(self) } }
|
||||
var contentWarningCopyMode = ContentWarningCopyMode.asIs { willSet { objectWillChange.send(self) } }
|
||||
var openLinksInApps = true { willSet { objectWillChange.send(self) } }
|
||||
|
||||
// MARK: - Advanced
|
||||
@Published var silentActions: [String: Permission] = [:]
|
||||
@Published var statusContentType: StatusContentType = .plain
|
||||
var silentActions: [String: Permission] = [:] { willSet { objectWillChange.send(self) } }
|
||||
var statusContentType: StatusContentType = .plain { willSet { objectWillChange.send(self) } }
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case showRepliesInProfiles
|
||||
case avatarStyle
|
||||
case hideCustomEmojiInUsernames
|
||||
|
||||
case defaultPostVisibility
|
||||
case automaticallySaveDrafts
|
||||
case contentWarningCopyMode
|
||||
case openLinksInApps
|
||||
|
||||
case defaultNotificationsType
|
||||
|
||||
case silentActions
|
||||
case statusContentType
|
||||
}
|
||||
|
||||
extension PassthroughSubject: Codable {
|
||||
public convenience init(from decoder: Decoder) throws {
|
||||
self.init()
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
extension Preferences {
|
||||
|
|
|
@ -283,12 +283,7 @@ class ComposeViewController: UIViewController {
|
|||
}
|
||||
|
||||
func updateAddAttachmentButton() {
|
||||
switch MastodonController.instance.instanceType {
|
||||
case .pleroma:
|
||||
addAttachmentButton.isEnabled = true
|
||||
case .mastodon:
|
||||
addAttachmentButton.isEnabled = selectedAssets.count <= 4 && selectedAssets.first(where: { $0.mediaType == .video }) == nil
|
||||
}
|
||||
addAttachmentButton.isEnabled = selectedAssets.count < 5 // 4 attachments + 1 button
|
||||
}
|
||||
|
||||
func updateAttachmentViews() {
|
||||
|
@ -316,6 +311,7 @@ class ComposeViewController: UIViewController {
|
|||
}
|
||||
|
||||
func saveDraft() {
|
||||
// TODO: save CW to draft
|
||||
var attachments = [DraftsManager.DraftAttachment]()
|
||||
for asset in selectedAssets {
|
||||
let index = attachments.count
|
||||
|
@ -563,17 +559,9 @@ extension ComposeViewController: GMImagePickerControllerDelegate {
|
|||
}
|
||||
|
||||
func assetsPickerController(_ picker: GMImagePickerController!, shouldSelect asset: PHAsset!) -> Bool {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension ComposeViewController: ComposeMediaViewDelegate {
|
||||
func didRemoveMedia(_ mediaView: ComposeMediaView) {
|
||||
|
|
|
@ -17,7 +17,7 @@ class MainTabBarViewController: UITabBarController, UITabBarControllerDelegate {
|
|||
|
||||
viewControllers = [
|
||||
embedInNavigationController(TimelineTableViewController(for: .home)),
|
||||
embedInNavigationController(NotificationsPageViewController()),
|
||||
embedInNavigationController(NotificationsTableViewController()),
|
||||
ComposeViewController(),
|
||||
embedInNavigationController(TimelineTableViewController(for: .public(local: false))),
|
||||
embedInNavigationController(MyProfileTableViewController()),
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
//
|
||||
// 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,7 +15,6 @@ class NotificationsTableViewController: EnhancedTableViewController {
|
|||
private let actionGroupCell = "actionGroupCell"
|
||||
private let followGroupCell = "followGroupCell"
|
||||
|
||||
let excludedTypes: [Pachyderm.Notification.Kind]
|
||||
let groupTypes = [Notification.Kind.favourite, .reblog, .follow]
|
||||
|
||||
var groups: [NotificationGroup] = [] {
|
||||
|
@ -29,11 +28,12 @@ class NotificationsTableViewController: EnhancedTableViewController {
|
|||
var newer: RequestRange?
|
||||
var older: RequestRange?
|
||||
|
||||
init(allowedTypes: [Pachyderm.Notification.Kind]) {
|
||||
self.excludedTypes = Array(Set(Pachyderm.Notification.Kind.allCases).subtracting(allowedTypes))
|
||||
|
||||
init() {
|
||||
super.init(style: .plain)
|
||||
|
||||
title = "Notifications"
|
||||
tabBarItem.image = UIImage(systemName: "bell.fill")
|
||||
|
||||
self.refreshControl = UIRefreshControl()
|
||||
refreshControl!.addTarget(self, action: #selector(refreshNotifications(_:)), for: .valueChanged)
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ class NotificationsTableViewController: EnhancedTableViewController {
|
|||
|
||||
tableView.prefetchDataSource = self
|
||||
|
||||
let request = MastodonController.client.getNotifications(excludeTypes: excludedTypes)
|
||||
let request = MastodonController.client.getNotifications()
|
||||
MastodonController.client.run(request) { result in
|
||||
guard case let .success(notifications, pagination) = result else { fatalError() }
|
||||
|
||||
|
@ -116,7 +116,7 @@ class NotificationsTableViewController: EnhancedTableViewController {
|
|||
if indexPath.row == groups.count - 1 {
|
||||
guard let older = older else { return }
|
||||
|
||||
let request = MastodonController.client.getNotifications(excludeTypes: excludedTypes, range: older)
|
||||
let request = MastodonController.client.getNotifications(range: older)
|
||||
MastodonController.client.run(request) { result in
|
||||
guard case let .success(newNotifications, pagination) = result else { fatalError() }
|
||||
|
||||
|
@ -148,7 +148,7 @@ class NotificationsTableViewController: EnhancedTableViewController {
|
|||
@objc func refreshNotifications(_ sender: Any) {
|
||||
guard let newer = newer else { return }
|
||||
|
||||
let request = MastodonController.client.getNotifications(excludeTypes: excludedTypes, range: newer)
|
||||
let request = MastodonController.client.getNotifications(range: newer)
|
||||
MastodonController.client.run(request) { result in
|
||||
guard case let .success(newNotifications, pagination) = result else { fatalError() }
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ struct BehaviorPrefsView : View {
|
|||
}
|
||||
|
||||
var section1: some View {
|
||||
Section(header: Text("COMPOSING")) {
|
||||
Section {
|
||||
Picker(selection: _defaultPostVisibility.binding, label: Text("Default Post Visibility")) {
|
||||
ForEach(Status.Visibility.allCases, id: \.self) { visibility in
|
||||
HStack {
|
||||
|
@ -46,7 +46,7 @@ struct BehaviorPrefsView : View {
|
|||
}
|
||||
|
||||
var section2: some View {
|
||||
Section(header: Text("READING")) {
|
||||
Section {
|
||||
Toggle(isOn: _openLinksInApps.binding) {
|
||||
Text("Open Links in Apps")
|
||||
}
|
||||
|
|
|
@ -18,9 +18,6 @@ struct PreferencesView : View {
|
|||
NavigationLink(destination: BehaviorPrefsView()) {
|
||||
Text("Behavior")
|
||||
}
|
||||
NavigationLink(destination: WellnessPrefsView()) {
|
||||
Text("Digital Wellness")
|
||||
}
|
||||
NavigationLink(destination: AdvancedPrefsView()) {
|
||||
Text("Advanced")
|
||||
}
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
//
|
||||
// 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()
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
//
|
||||
// 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