2018-08-28 19:16:17 -04:00
|
|
|
//
|
|
|
|
// Preferences.swift
|
2023-04-18 19:47:49 -04:00
|
|
|
// TuskerPreferences
|
2018-08-28 19:16:17 -04:00
|
|
|
//
|
|
|
|
// Created by Shadowfacts on 8/28/18.
|
|
|
|
// Copyright © 2018 Shadowfacts. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2022-04-02 19:28:10 -04:00
|
|
|
import UIKit
|
2018-09-11 10:52:21 -04:00
|
|
|
import Pachyderm
|
2019-06-13 17:53:17 -07:00
|
|
|
import Combine
|
2018-08-28 19:16:17 -04:00
|
|
|
|
2023-04-18 19:47:49 -04:00
|
|
|
public class Preferences: Codable, ObservableObject {
|
2019-07-18 18:44:35 -04:00
|
|
|
|
2023-04-18 19:47:49 -04:00
|
|
|
public static var shared: Preferences = load()
|
2018-08-28 19:16:17 -04:00
|
|
|
|
|
|
|
private static var documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
|
2023-04-18 19:47:49 -04:00
|
|
|
private static var appGroupDirectory = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.space.vaccor.Tusker")!
|
|
|
|
private static var archiveURL = appGroupDirectory.appendingPathComponent("preferences").appendingPathExtension("plist")
|
2018-08-28 19:16:17 -04:00
|
|
|
|
2023-04-18 19:47:49 -04:00
|
|
|
public static func save() {
|
2018-08-28 19:16:17 -04:00
|
|
|
let encoder = PropertyListEncoder()
|
|
|
|
let data = try? encoder.encode(shared)
|
2018-10-22 22:09:11 -04:00
|
|
|
try? data?.write(to: archiveURL, options: .noFileProtection)
|
2018-08-28 19:16:17 -04:00
|
|
|
}
|
|
|
|
|
2023-04-18 19:47:49 -04:00
|
|
|
public static func load() -> Preferences {
|
2018-08-28 19:16:17 -04:00
|
|
|
let decoder = PropertyListDecoder()
|
2018-10-22 22:09:11 -04:00
|
|
|
if let data = try? Data(contentsOf: archiveURL),
|
2018-08-28 19:16:17 -04:00
|
|
|
let preferences = try? decoder.decode(Preferences.self, from: data) {
|
|
|
|
return preferences
|
|
|
|
}
|
|
|
|
return Preferences()
|
|
|
|
}
|
|
|
|
|
2023-04-18 19:47:49 -04:00
|
|
|
public static func migrate(from url: URL) -> Result<Void, any Error> {
|
|
|
|
do {
|
|
|
|
try? FileManager.default.removeItem(at: archiveURL)
|
|
|
|
try FileManager.default.moveItem(at: url, to: archiveURL)
|
|
|
|
} catch {
|
|
|
|
return .failure(error)
|
|
|
|
}
|
|
|
|
shared = load()
|
|
|
|
return .success(())
|
|
|
|
}
|
|
|
|
|
2018-10-06 10:38:36 -04:00
|
|
|
private init() {}
|
2018-08-28 19:16:17 -04:00
|
|
|
|
2023-04-18 19:47:49 -04:00
|
|
|
public required init(from decoder: Decoder) throws {
|
2019-09-14 12:15:40 -04:00
|
|
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
|
|
|
|
2019-12-31 00:12:18 -05:00
|
|
|
self.theme = try container.decode(UIUserInterfaceStyle.self, forKey: .theme)
|
2023-02-02 23:02:11 -05:00
|
|
|
self.pureBlackDarkMode = try container.decodeIfPresent(Bool.self, forKey: .pureBlackDarkMode) ?? true
|
2023-01-14 11:27:41 -05:00
|
|
|
self.accentColor = try container.decodeIfPresent(AccentColor.self, forKey: .accentColor) ?? .default
|
2019-09-14 12:15:40 -04:00
|
|
|
self.avatarStyle = try container.decode(AvatarStyle.self, forKey: .avatarStyle)
|
|
|
|
self.hideCustomEmojiInUsernames = try container.decode(Bool.self, forKey: .hideCustomEmojiInUsernames)
|
2020-06-17 17:45:34 -04:00
|
|
|
self.showIsStatusReplyIcon = try container.decode(Bool.self, forKey: .showIsStatusReplyIcon)
|
2020-06-17 18:00:13 -04:00
|
|
|
self.alwaysShowStatusVisibilityIcon = try container.decode(Bool.self, forKey: .alwaysShowStatusVisibilityIcon)
|
2022-04-08 18:42:15 -04:00
|
|
|
self.hideActionsInTimeline = try container.decodeIfPresent(Bool.self, forKey: .hideActionsInTimeline) ?? false
|
2023-01-26 17:18:27 -05:00
|
|
|
self.showLinkPreviews = try container.decodeIfPresent(Bool.self, forKey: .showLinkPreviews) ?? true
|
2022-12-12 23:09:04 -05:00
|
|
|
self.leadingStatusSwipeActions = try container.decodeIfPresent([StatusSwipeAction].self, forKey: .leadingStatusSwipeActions) ?? leadingStatusSwipeActions
|
|
|
|
self.trailingStatusSwipeActions = try container.decodeIfPresent([StatusSwipeAction].self, forKey: .trailingStatusSwipeActions) ?? trailingStatusSwipeActions
|
2019-09-14 12:15:40 -04:00
|
|
|
|
2023-03-07 10:14:35 -05:00
|
|
|
self.defaultPostVisibility = try container.decode(Visibility.self, forKey: .defaultPostVisibility)
|
2022-11-05 12:20:30 -04:00
|
|
|
self.defaultReplyVisibility = try container.decodeIfPresent(ReplyVisibility.self, forKey: .defaultReplyVisibility) ?? .sameAsPost
|
2020-01-17 21:55:21 -05:00
|
|
|
self.requireAttachmentDescriptions = try container.decode(Bool.self, forKey: .requireAttachmentDescriptions)
|
2020-01-19 23:23:00 -05:00
|
|
|
self.contentWarningCopyMode = try container.decode(ContentWarningCopyMode.self, forKey: .contentWarningCopyMode)
|
2020-01-19 23:48:36 -05:00
|
|
|
self.mentionReblogger = try container.decode(Bool.self, forKey: .mentionReblogger)
|
2022-11-22 11:06:21 -05:00
|
|
|
self.useTwitterKeyboard = try container.decodeIfPresent(Bool.self, forKey: .useTwitterKeyboard) ?? false
|
2020-06-17 17:38:00 -04:00
|
|
|
|
2022-12-06 21:12:58 -05:00
|
|
|
if let blurAllMedia = try? container.decodeIfPresent(Bool.self, forKey: .blurAllMedia) {
|
|
|
|
self.attachmentBlurMode = blurAllMedia ? .always : .useStatusSetting
|
|
|
|
} else {
|
|
|
|
self.attachmentBlurMode = try container.decode(AttachmentBlurMode.self, forKey: .attachmentBlurMode)
|
|
|
|
}
|
2022-11-05 13:20:55 -04:00
|
|
|
self.blurMediaBehindContentWarning = try container.decodeIfPresent(Bool.self, forKey: .blurMediaBehindContentWarning) ?? true
|
2020-02-22 13:12:28 -05:00
|
|
|
self.automaticallyPlayGifs = try container.decode(Bool.self, forKey: .automaticallyPlayGifs)
|
2022-12-25 14:13:59 -05:00
|
|
|
self.showUncroppedMediaInline = try container.decodeIfPresent(Bool.self, forKey: .showUncroppedMediaInline) ?? true
|
2023-02-13 20:40:17 -05:00
|
|
|
self.showAttachmentBadges = try container.decodeIfPresent(Bool.self, forKey: .showAttachmentBadges) ?? true
|
2020-06-17 17:38:00 -04:00
|
|
|
|
2019-09-14 12:15:40 -04:00
|
|
|
self.openLinksInApps = try container.decode(Bool.self, forKey: .openLinksInApps)
|
2019-11-14 19:53:27 -05:00
|
|
|
self.useInAppSafari = try container.decode(Bool.self, forKey: .useInAppSafari)
|
|
|
|
self.inAppSafariAutomaticReaderMode = try container.decode(Bool.self, forKey: .inAppSafariAutomaticReaderMode)
|
2020-11-03 15:39:02 -05:00
|
|
|
self.expandAllContentWarnings = try container.decodeIfPresent(Bool.self, forKey: .expandAllContentWarnings) ?? false
|
|
|
|
self.collapseLongPosts = try container.decodeIfPresent(Bool.self, forKey: .collapseLongPosts) ?? true
|
|
|
|
self.oppositeCollapseKeywords = try container.decodeIfPresent([String].self, forKey: .oppositeCollapseKeywords) ?? []
|
2021-04-05 17:48:03 -04:00
|
|
|
self.confirmBeforeReblog = try container.decodeIfPresent(Bool.self, forKey: .confirmBeforeReblog) ?? false
|
2022-12-05 17:24:01 -05:00
|
|
|
self.timelineStateRestoration = try container.decodeIfPresent(Bool.self, forKey: .timelineStateRestoration) ?? true
|
2023-02-14 21:37:43 -05:00
|
|
|
self.timelineSyncMode = try container.decodeIfPresent(TimelineSyncMode.self, forKey: .timelineSyncMode) ?? .icloud
|
2022-12-17 13:40:15 -05:00
|
|
|
self.hideReblogsInTimelines = try container.decodeIfPresent(Bool.self, forKey: .hideReblogsInTimelines) ?? false
|
|
|
|
self.hideRepliesInTimelines = try container.decodeIfPresent(Bool.self, forKey: .hideRepliesInTimelines) ?? false
|
2019-09-14 12:15:40 -04:00
|
|
|
|
2019-09-14 14:55:30 -04:00
|
|
|
self.showFavoriteAndReblogCounts = try container.decode(Bool.self, forKey: .showFavoriteAndReblogCounts)
|
2019-09-14 13:02:33 -04:00
|
|
|
self.defaultNotificationsMode = try container.decode(NotificationsMode.self, forKey: .defaultNotificationsType)
|
2020-11-03 15:39:02 -05:00
|
|
|
self.grayscaleImages = try container.decodeIfPresent(Bool.self, forKey: .grayscaleImages) ?? false
|
2021-06-25 23:28:14 -04:00
|
|
|
self.disableInfiniteScrolling = try container.decodeIfPresent(Bool.self, forKey: .disableInfiniteScrolling) ?? false
|
2023-02-05 14:43:04 -05:00
|
|
|
self.hideTrends = try container.decodeIfPresent(Bool.self, forKey: .hideTrends) ?? false
|
2019-09-14 13:02:33 -04:00
|
|
|
|
2019-09-14 12:15:40 -04:00
|
|
|
self.statusContentType = try container.decode(StatusContentType.self, forKey: .statusContentType)
|
2023-09-04 23:35:40 -04:00
|
|
|
self.reportErrorsAutomatically = try container.decodeIfPresent(Bool.self, forKey: .reportErrorsAutomatically) ?? true
|
|
|
|
let featureFlagNames = (try? container.decodeIfPresent([String].self, forKey: .enabledFeatureFlags)) ?? []
|
|
|
|
self.enabledFeatureFlags = Set(featureFlagNames.compactMap(FeatureFlag.init))
|
2021-08-07 14:39:01 -04:00
|
|
|
|
|
|
|
self.hasShownLocalTimelineDescription = try container.decodeIfPresent(Bool.self, forKey: .hasShownLocalTimelineDescription) ?? false
|
|
|
|
self.hasShownFederatedTimelineDescription = try container.decodeIfPresent(Bool.self, forKey: .hasShownFederatedTimelineDescription) ?? false
|
2019-09-14 12:15:40 -04:00
|
|
|
}
|
|
|
|
|
2023-04-18 19:47:49 -04:00
|
|
|
public func encode(to encoder: Encoder) throws {
|
2019-09-14 12:15:40 -04:00
|
|
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
|
|
|
2019-12-31 00:12:18 -05:00
|
|
|
try container.encode(theme, forKey: .theme)
|
2023-02-02 23:02:11 -05:00
|
|
|
try container.encode(pureBlackDarkMode, forKey: .pureBlackDarkMode)
|
2023-01-14 11:27:41 -05:00
|
|
|
try container.encode(accentColor, forKey: .accentColor)
|
2019-09-14 12:15:40 -04:00
|
|
|
try container.encode(avatarStyle, forKey: .avatarStyle)
|
|
|
|
try container.encode(hideCustomEmojiInUsernames, forKey: .hideCustomEmojiInUsernames)
|
2020-06-17 17:45:34 -04:00
|
|
|
try container.encode(showIsStatusReplyIcon, forKey: .showIsStatusReplyIcon)
|
2020-06-17 18:00:13 -04:00
|
|
|
try container.encode(alwaysShowStatusVisibilityIcon, forKey: .alwaysShowStatusVisibilityIcon)
|
2022-04-08 18:42:15 -04:00
|
|
|
try container.encode(hideActionsInTimeline, forKey: .hideActionsInTimeline)
|
2023-01-26 17:18:27 -05:00
|
|
|
try container.encode(showLinkPreviews, forKey: .showLinkPreviews)
|
2022-12-12 23:09:04 -05:00
|
|
|
try container.encode(leadingStatusSwipeActions, forKey: .leadingStatusSwipeActions)
|
|
|
|
try container.encode(trailingStatusSwipeActions, forKey: .trailingStatusSwipeActions)
|
2019-09-14 12:15:40 -04:00
|
|
|
|
|
|
|
try container.encode(defaultPostVisibility, forKey: .defaultPostVisibility)
|
2022-11-05 12:20:30 -04:00
|
|
|
try container.encode(defaultReplyVisibility, forKey: .defaultReplyVisibility)
|
2020-01-17 21:55:21 -05:00
|
|
|
try container.encode(requireAttachmentDescriptions, forKey: .requireAttachmentDescriptions)
|
2020-01-19 23:23:00 -05:00
|
|
|
try container.encode(contentWarningCopyMode, forKey: .contentWarningCopyMode)
|
2020-01-19 23:48:36 -05:00
|
|
|
try container.encode(mentionReblogger, forKey: .mentionReblogger)
|
2022-11-22 11:06:21 -05:00
|
|
|
try container.encode(useTwitterKeyboard, forKey: .useTwitterKeyboard)
|
2020-06-17 17:38:00 -04:00
|
|
|
|
2022-12-06 21:12:58 -05:00
|
|
|
try container.encode(attachmentBlurMode, forKey: .attachmentBlurMode)
|
2022-11-05 13:20:55 -04:00
|
|
|
try container.encode(blurMediaBehindContentWarning, forKey: .blurMediaBehindContentWarning)
|
2020-02-22 13:12:28 -05:00
|
|
|
try container.encode(automaticallyPlayGifs, forKey: .automaticallyPlayGifs)
|
2022-12-25 14:13:59 -05:00
|
|
|
try container.encode(showUncroppedMediaInline, forKey: .showUncroppedMediaInline)
|
2023-02-13 20:40:17 -05:00
|
|
|
try container.encode(showAttachmentBadges, forKey: .showAttachmentBadges)
|
2020-06-17 17:38:00 -04:00
|
|
|
|
2019-09-14 12:15:40 -04:00
|
|
|
try container.encode(openLinksInApps, forKey: .openLinksInApps)
|
2019-11-14 19:53:27 -05:00
|
|
|
try container.encode(useInAppSafari, forKey: .useInAppSafari)
|
|
|
|
try container.encode(inAppSafariAutomaticReaderMode, forKey: .inAppSafariAutomaticReaderMode)
|
2020-09-15 21:37:08 -04:00
|
|
|
try container.encode(expandAllContentWarnings, forKey: .expandAllContentWarnings)
|
|
|
|
try container.encode(collapseLongPosts, forKey: .collapseLongPosts)
|
2020-11-03 15:39:02 -05:00
|
|
|
try container.encode(oppositeCollapseKeywords, forKey: .oppositeCollapseKeywords)
|
2021-04-05 17:48:03 -04:00
|
|
|
try container.encode(confirmBeforeReblog, forKey: .confirmBeforeReblog)
|
2022-12-05 17:24:01 -05:00
|
|
|
try container.encode(timelineStateRestoration, forKey: .timelineStateRestoration)
|
2023-02-14 21:37:43 -05:00
|
|
|
try container.encode(timelineSyncMode, forKey: .timelineSyncMode)
|
2022-12-17 13:40:15 -05:00
|
|
|
try container.encode(hideReblogsInTimelines, forKey: .hideReblogsInTimelines)
|
|
|
|
try container.encode(hideRepliesInTimelines, forKey: .hideRepliesInTimelines)
|
2019-09-14 12:15:40 -04:00
|
|
|
|
2019-09-14 14:55:30 -04:00
|
|
|
try container.encode(showFavoriteAndReblogCounts, forKey: .showFavoriteAndReblogCounts)
|
2019-09-14 13:02:33 -04:00
|
|
|
try container.encode(defaultNotificationsMode, forKey: .defaultNotificationsType)
|
2020-11-01 13:59:58 -05:00
|
|
|
try container.encode(grayscaleImages, forKey: .grayscaleImages)
|
2021-06-25 23:28:14 -04:00
|
|
|
try container.encode(disableInfiniteScrolling, forKey: .disableInfiniteScrolling)
|
2023-02-05 14:43:04 -05:00
|
|
|
try container.encode(hideTrends, forKey: .hideTrends)
|
2019-09-14 13:02:33 -04:00
|
|
|
|
2019-09-14 12:15:40 -04:00
|
|
|
try container.encode(statusContentType, forKey: .statusContentType)
|
2023-09-04 23:35:40 -04:00
|
|
|
try container.encode(reportErrorsAutomatically, forKey: .reportErrorsAutomatically)
|
|
|
|
try container.encode(enabledFeatureFlags, forKey: .enabledFeatureFlags)
|
2021-08-07 14:39:01 -04:00
|
|
|
|
|
|
|
try container.encode(hasShownLocalTimelineDescription, forKey: .hasShownLocalTimelineDescription)
|
|
|
|
try container.encode(hasShownFederatedTimelineDescription, forKey: .hasShownFederatedTimelineDescription)
|
2019-09-14 12:15:40 -04:00
|
|
|
}
|
|
|
|
|
2020-06-17 17:38:00 -04:00
|
|
|
// MARK: Appearance
|
2023-04-18 19:47:49 -04:00
|
|
|
@Published public var theme = UIUserInterfaceStyle.unspecified
|
|
|
|
@Published public var pureBlackDarkMode = true
|
|
|
|
@Published public var accentColor = AccentColor.default
|
|
|
|
@Published public var avatarStyle = AvatarStyle.roundRect
|
|
|
|
@Published public var hideCustomEmojiInUsernames = false
|
|
|
|
@Published public var showIsStatusReplyIcon = false
|
|
|
|
@Published public var alwaysShowStatusVisibilityIcon = false
|
|
|
|
@Published public var hideActionsInTimeline = false
|
|
|
|
@Published public var showLinkPreviews = true
|
|
|
|
@Published public var leadingStatusSwipeActions: [StatusSwipeAction] = [.favorite, .reblog]
|
|
|
|
@Published public var trailingStatusSwipeActions: [StatusSwipeAction] = [.reply, .share]
|
2023-09-03 17:39:58 -04:00
|
|
|
@Published public var widescreenNavigationMode = WidescreenNavigationMode.multiColumn
|
2018-08-28 21:18:58 -04:00
|
|
|
|
2020-06-17 17:38:00 -04:00
|
|
|
// MARK: Composing
|
2023-04-18 19:47:49 -04:00
|
|
|
@Published public var defaultPostVisibility = Visibility.public
|
|
|
|
@Published public var defaultReplyVisibility = ReplyVisibility.sameAsPost
|
|
|
|
@Published public var requireAttachmentDescriptions = false
|
|
|
|
@Published public var contentWarningCopyMode = ContentWarningCopyMode.asIs
|
|
|
|
@Published public var mentionReblogger = false
|
|
|
|
@Published public var useTwitterKeyboard = false
|
2020-06-17 17:38:00 -04:00
|
|
|
|
|
|
|
// MARK: Media
|
2023-04-18 19:47:49 -04:00
|
|
|
@Published public var attachmentBlurMode = AttachmentBlurMode.useStatusSetting {
|
2022-11-05 13:20:55 -04:00
|
|
|
didSet {
|
2022-12-06 21:12:58 -05:00
|
|
|
if attachmentBlurMode == .always {
|
2022-11-05 13:20:55 -04:00
|
|
|
blurMediaBehindContentWarning = true
|
2022-12-06 21:12:58 -05:00
|
|
|
} else if attachmentBlurMode == .never {
|
|
|
|
blurMediaBehindContentWarning = false
|
2022-11-05 13:20:55 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-04-18 19:47:49 -04:00
|
|
|
@Published public var blurMediaBehindContentWarning = true
|
|
|
|
@Published public var automaticallyPlayGifs = true
|
|
|
|
@Published public var showUncroppedMediaInline = true
|
|
|
|
@Published public var showAttachmentBadges = true
|
2020-06-17 17:38:00 -04:00
|
|
|
|
|
|
|
// MARK: Behavior
|
2023-04-18 19:47:49 -04:00
|
|
|
@Published public var openLinksInApps = true
|
|
|
|
@Published public var useInAppSafari = true
|
|
|
|
@Published public var inAppSafariAutomaticReaderMode = false
|
|
|
|
@Published public var expandAllContentWarnings = false
|
|
|
|
@Published public var collapseLongPosts = true
|
|
|
|
@Published public var oppositeCollapseKeywords: [String] = []
|
|
|
|
@Published public var confirmBeforeReblog = false
|
|
|
|
@Published public var timelineStateRestoration = true
|
|
|
|
@Published public var timelineSyncMode = TimelineSyncMode.icloud
|
|
|
|
@Published public var hideReblogsInTimelines = false
|
|
|
|
@Published public var hideRepliesInTimelines = false
|
2018-10-22 22:09:11 -04:00
|
|
|
|
2020-06-17 17:38:00 -04:00
|
|
|
// MARK: Digital Wellness
|
2023-04-18 19:47:49 -04:00
|
|
|
@Published public var showFavoriteAndReblogCounts = true
|
|
|
|
@Published public var defaultNotificationsMode = NotificationsMode.allNotifications
|
|
|
|
@Published public var grayscaleImages = false
|
|
|
|
@Published public var disableInfiniteScrolling = false
|
|
|
|
@Published public var hideTrends = false
|
2019-09-14 13:02:33 -04:00
|
|
|
|
2020-06-17 17:38:00 -04:00
|
|
|
// MARK: Advanced
|
2023-04-18 19:47:49 -04:00
|
|
|
@Published public var statusContentType: StatusContentType = .plain
|
|
|
|
@Published public var reportErrorsAutomatically = true
|
2023-09-04 23:35:40 -04:00
|
|
|
@Published public var enabledFeatureFlags: Set<FeatureFlag> = []
|
2021-08-07 14:39:01 -04:00
|
|
|
|
|
|
|
// MARK:
|
2023-04-18 19:47:49 -04:00
|
|
|
@Published public var hasShownLocalTimelineDescription = false
|
|
|
|
@Published public var hasShownFederatedTimelineDescription = false
|
2021-08-07 14:39:01 -04:00
|
|
|
|
2023-09-03 17:39:58 -04:00
|
|
|
public func hasFeatureFlag(_ flag: FeatureFlag) -> Bool {
|
|
|
|
enabledFeatureFlags.contains(flag)
|
|
|
|
}
|
|
|
|
|
2020-11-01 13:59:58 -05:00
|
|
|
private enum CodingKeys: String, CodingKey {
|
2019-12-31 00:12:18 -05:00
|
|
|
case theme
|
2023-02-02 23:02:11 -05:00
|
|
|
case pureBlackDarkMode
|
2023-01-14 11:27:41 -05:00
|
|
|
case accentColor
|
2019-09-14 12:15:40 -04:00
|
|
|
case avatarStyle
|
|
|
|
case hideCustomEmojiInUsernames
|
2020-06-17 17:45:34 -04:00
|
|
|
case showIsStatusReplyIcon
|
2020-06-17 18:00:13 -04:00
|
|
|
case alwaysShowStatusVisibilityIcon
|
2022-04-08 18:42:15 -04:00
|
|
|
case hideActionsInTimeline
|
2023-01-26 17:18:27 -05:00
|
|
|
case showLinkPreviews
|
2022-12-12 23:09:04 -05:00
|
|
|
case leadingStatusSwipeActions
|
|
|
|
case trailingStatusSwipeActions
|
2019-06-13 17:53:17 -07:00
|
|
|
|
2019-09-14 12:15:40 -04:00
|
|
|
case defaultPostVisibility
|
2022-11-05 12:20:30 -04:00
|
|
|
case defaultReplyVisibility
|
2020-01-17 21:55:21 -05:00
|
|
|
case requireAttachmentDescriptions
|
2020-01-19 23:23:00 -05:00
|
|
|
case contentWarningCopyMode
|
2020-01-19 23:48:36 -05:00
|
|
|
case mentionReblogger
|
2022-11-22 11:06:21 -05:00
|
|
|
case useTwitterKeyboard
|
2020-06-17 17:38:00 -04:00
|
|
|
|
2022-12-06 21:12:58 -05:00
|
|
|
case blurAllMedia // only used for migration
|
|
|
|
case attachmentBlurMode
|
2022-11-05 13:20:55 -04:00
|
|
|
case blurMediaBehindContentWarning
|
2020-02-22 13:12:28 -05:00
|
|
|
case automaticallyPlayGifs
|
2022-12-25 14:13:59 -05:00
|
|
|
case showUncroppedMediaInline
|
2023-02-13 20:40:17 -05:00
|
|
|
case showAttachmentBadges
|
2020-06-17 17:38:00 -04:00
|
|
|
|
2019-09-14 12:15:40 -04:00
|
|
|
case openLinksInApps
|
2019-11-14 19:53:27 -05:00
|
|
|
case useInAppSafari
|
|
|
|
case inAppSafariAutomaticReaderMode
|
2020-09-15 21:37:08 -04:00
|
|
|
case expandAllContentWarnings
|
|
|
|
case collapseLongPosts
|
2020-11-03 15:39:02 -05:00
|
|
|
case oppositeCollapseKeywords
|
2021-04-05 17:48:03 -04:00
|
|
|
case confirmBeforeReblog
|
2022-12-05 17:24:01 -05:00
|
|
|
case timelineStateRestoration
|
2023-02-14 21:37:43 -05:00
|
|
|
case timelineSyncMode
|
2022-12-17 13:40:15 -05:00
|
|
|
case hideReblogsInTimelines
|
|
|
|
case hideRepliesInTimelines
|
2019-09-14 12:15:40 -04:00
|
|
|
|
2019-09-14 14:55:30 -04:00
|
|
|
case showFavoriteAndReblogCounts
|
2019-09-14 13:02:33 -04:00
|
|
|
case defaultNotificationsType
|
2020-11-01 13:59:58 -05:00
|
|
|
case grayscaleImages
|
2021-06-25 23:28:14 -04:00
|
|
|
case disableInfiniteScrolling
|
2023-02-05 14:43:04 -05:00
|
|
|
case hideTrends = "hideDiscover"
|
2019-09-14 13:02:33 -04:00
|
|
|
|
2019-09-14 12:15:40 -04:00
|
|
|
case statusContentType
|
2023-09-04 23:35:40 -04:00
|
|
|
case reportErrorsAutomatically
|
|
|
|
case enabledFeatureFlags
|
2021-08-07 14:39:01 -04:00
|
|
|
|
|
|
|
case hasShownLocalTimelineDescription
|
|
|
|
case hasShownFederatedTimelineDescription
|
2019-06-13 17:53:17 -07:00
|
|
|
}
|
2019-09-14 12:15:40 -04:00
|
|
|
|
2018-09-23 19:04:39 -04:00
|
|
|
}
|
|
|
|
|
2022-11-05 12:20:30 -04:00
|
|
|
extension Preferences {
|
2023-04-18 19:47:49 -04:00
|
|
|
public enum ReplyVisibility: Codable, Hashable, CaseIterable {
|
2022-11-05 12:20:30 -04:00
|
|
|
case sameAsPost
|
2023-03-07 10:14:35 -05:00
|
|
|
case visibility(Visibility)
|
2022-11-05 12:20:30 -04:00
|
|
|
|
2023-04-18 19:47:49 -04:00
|
|
|
public static var allCases: [Preferences.ReplyVisibility] = [.sameAsPost] + Visibility.allCases.map { .visibility($0) }
|
2022-11-05 12:20:30 -04:00
|
|
|
|
2023-04-18 19:47:49 -04:00
|
|
|
public var resolved: Visibility {
|
2022-11-05 12:20:30 -04:00
|
|
|
switch self {
|
|
|
|
case .sameAsPost:
|
|
|
|
return Preferences.shared.defaultPostVisibility
|
|
|
|
case .visibility(let vis):
|
|
|
|
return vis
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-18 19:47:49 -04:00
|
|
|
public var displayName: String {
|
2022-11-05 12:20:30 -04:00
|
|
|
switch self {
|
|
|
|
case .sameAsPost:
|
|
|
|
return "Same as Default"
|
|
|
|
case .visibility(let vis):
|
|
|
|
return vis.displayName
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-18 19:47:49 -04:00
|
|
|
public var imageName: String? {
|
2022-11-05 12:20:30 -04:00
|
|
|
switch self {
|
|
|
|
case .sameAsPost:
|
|
|
|
return nil
|
|
|
|
case .visibility(let vis):
|
|
|
|
return vis.imageName
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-06 21:12:58 -05:00
|
|
|
extension Preferences {
|
2023-04-18 19:47:49 -04:00
|
|
|
public enum AttachmentBlurMode: Codable, Hashable, CaseIterable {
|
2022-12-06 21:12:58 -05:00
|
|
|
case useStatusSetting
|
|
|
|
case always
|
|
|
|
case never
|
|
|
|
|
2023-04-18 19:47:49 -04:00
|
|
|
public var displayName: String {
|
2022-12-06 21:12:58 -05:00
|
|
|
switch self {
|
|
|
|
case .useStatusSetting:
|
|
|
|
return "Default"
|
|
|
|
case .always:
|
|
|
|
return "Always"
|
|
|
|
case .never:
|
|
|
|
return "Never"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-31 00:12:18 -05:00
|
|
|
extension UIUserInterfaceStyle: Codable {}
|
2023-01-14 11:27:41 -05:00
|
|
|
|
|
|
|
extension Preferences {
|
2023-04-18 19:47:49 -04:00
|
|
|
public enum AccentColor: String, Codable, CaseIterable {
|
2023-01-14 11:27:41 -05:00
|
|
|
case `default`
|
|
|
|
case purple
|
|
|
|
case indigo
|
|
|
|
case blue
|
|
|
|
case cyan
|
|
|
|
case teal
|
|
|
|
case mint
|
|
|
|
case green
|
|
|
|
// case yellow
|
|
|
|
case orange
|
|
|
|
case red
|
|
|
|
case pink
|
|
|
|
// case brown
|
|
|
|
|
2023-04-18 19:47:49 -04:00
|
|
|
public var color: UIColor? {
|
2023-01-14 11:27:41 -05:00
|
|
|
switch self {
|
|
|
|
case .default:
|
|
|
|
return nil
|
|
|
|
case .blue:
|
|
|
|
return .systemBlue
|
|
|
|
// case .brown:
|
|
|
|
// return .systemBrown
|
|
|
|
case .cyan:
|
|
|
|
return .systemCyan
|
|
|
|
case .green:
|
|
|
|
return .systemGreen
|
|
|
|
case .indigo:
|
|
|
|
return .systemIndigo
|
|
|
|
case .mint:
|
|
|
|
return .systemMint
|
|
|
|
case .orange:
|
|
|
|
return .systemOrange
|
|
|
|
case .pink:
|
|
|
|
return .systemPink
|
|
|
|
case .purple:
|
|
|
|
return .systemPurple
|
|
|
|
case .red:
|
|
|
|
return .systemRed
|
|
|
|
case .teal:
|
|
|
|
return .systemTeal
|
|
|
|
// case .yellow:
|
|
|
|
// return .systemYellow
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-18 19:47:49 -04:00
|
|
|
public var name: String {
|
2023-01-14 11:27:41 -05:00
|
|
|
switch self {
|
|
|
|
case .default:
|
|
|
|
return "Default"
|
|
|
|
case .blue:
|
|
|
|
return "Blue"
|
|
|
|
// case .brown:
|
|
|
|
// return "Brown"
|
|
|
|
case .cyan:
|
|
|
|
return "Cyan"
|
|
|
|
case .green:
|
|
|
|
return "Green"
|
|
|
|
case .indigo:
|
|
|
|
return "Indigo"
|
|
|
|
case .mint:
|
|
|
|
return "Mint"
|
|
|
|
case .orange:
|
|
|
|
return "Orange"
|
|
|
|
case .pink:
|
|
|
|
return "Pink"
|
|
|
|
case .purple:
|
|
|
|
return "Purple"
|
|
|
|
case .red:
|
|
|
|
return "Red"
|
|
|
|
case .teal:
|
|
|
|
return "Teal"
|
|
|
|
// case .yellow:
|
|
|
|
// return "Yellow"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-02-14 21:37:43 -05:00
|
|
|
|
|
|
|
extension Preferences {
|
2023-04-18 19:47:49 -04:00
|
|
|
public enum TimelineSyncMode: String, Codable {
|
2023-02-14 21:37:43 -05:00
|
|
|
case mastodon
|
|
|
|
case icloud
|
|
|
|
}
|
|
|
|
}
|
2023-09-04 23:35:40 -04:00
|
|
|
|
|
|
|
extension Preferences {
|
|
|
|
public enum FeatureFlag: String, Codable {
|
2023-09-03 17:39:58 -04:00
|
|
|
case iPadMultiColumn = "ipad-multi-column"
|
2023-09-06 13:27:42 -04:00
|
|
|
case iPadBrowserNavigation = "ipad-browser-navigation"
|
2023-09-03 17:39:58 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension Preferences {
|
|
|
|
public enum WidescreenNavigationMode: String, Codable {
|
|
|
|
case stack
|
|
|
|
case splitScreen
|
|
|
|
case multiColumn
|
2023-09-04 23:35:40 -04:00
|
|
|
}
|
|
|
|
}
|