forked from shadowfacts/Tusker
83 lines
3.6 KiB
Swift
83 lines
3.6 KiB
Swift
//
|
|
// PreferenceStore.swift
|
|
// TuskerPreferences
|
|
//
|
|
// Created by Shadowfacts on 4/12/24.
|
|
//
|
|
|
|
import Foundation
|
|
import UIKit
|
|
import Pachyderm
|
|
|
|
public final class PreferenceStore: ObservableObject, Codable {
|
|
// MARK: Appearance
|
|
@Preference<ThemeKey> public var theme
|
|
@Preference<TrueKey> public var pureBlackDarkMode
|
|
@Preference<AccentColorKey> public var accentColor
|
|
@Preference<AvatarStyleKey> public var avatarStyle
|
|
@Preference<FalseKey> public var hideCustomEmojiInUsernames
|
|
@Preference<FalseKey> public var showIsStatusReplyIcon
|
|
@Preference<FalseKey> public var alwaysShowStatusVisibilityIcon
|
|
@Preference<FalseKey> public var hideActionsInTimeline
|
|
@Preference<TrueKey> public var showLinkPreviews
|
|
@Preference<LeadingSwipeActionsKey> public var leadingStatusSwipeActions
|
|
@Preference<TrailingSwipeActionsKey> public var trailingStatusSwipeActions
|
|
@Preference<WidescreenNavigationModeKey> public var widescreenNavigationMode
|
|
@Preference<FalseKey> public var underlineTextLinks
|
|
@Preference<TrueKey> public var showAttachmentsInTimeline
|
|
@Preference<AttachmentBlurModeKey> public var attachmentBlurMode
|
|
@Preference<TrueKey> public var blurMediaBehindContentWarning
|
|
@Preference<TrueKey> public var automaticallyPlayGifs
|
|
@Preference<TrueKey> public var showUncroppedMediaInline
|
|
@Preference<TrueKey> public var showAttachmentBadges
|
|
@Preference<FalseKey> public var attachmentAltBadgeInverted
|
|
|
|
// MARK: Composing
|
|
@Preference<PostVisibilityKey> public var defaultPostVisibility
|
|
@Preference<ReplyVisibilityKey> public var defaultReplyVisibility
|
|
@Preference<FalseKey> public var requireAttachmentDescriptions
|
|
@Preference<ContentWarningCopyModeKey> public var contentWarningCopyMode
|
|
@Preference<FalseKey> public var mentionReblogger
|
|
@Preference<FalseKey> public var useTwitterKeyboard
|
|
|
|
// MARK: Behavior
|
|
@Preference<TrueKey> public var openLinksInApps
|
|
@Preference<InAppSafariKey> public var useInAppSafari
|
|
@Preference<FalseKey> public var inAppSafariAutomaticReaderMode
|
|
@Preference<FalseKey> public var expandAllContentWarnings
|
|
@Preference<TrueKey> public var collapseLongPosts
|
|
@Preference<OppositeCollapseKeywordsKey> public var oppositeCollapseKeywords
|
|
@Preference<ConfirmReblogKey> public var confirmBeforeReblog
|
|
@Preference<TrueKey> public var timelineStateRestoration
|
|
@Preference<TimelineSyncModeKey> public var timelineSyncMode
|
|
@Preference<FalseKey> public var hideReblogsInTimelines
|
|
@Preference<FalseKey> public var hideRepliesInTimelines
|
|
|
|
// MARK: Digital Wellness
|
|
@Preference<TrueKey> public var showFavoriteAndReblogCounts
|
|
@Preference<NotificationsModeKey> public var defaultNotificationsMode
|
|
@Preference<FalseKey> public var grayscaleImages
|
|
@Preference<FalseKey> public var disableInfiniteScrolling
|
|
@Preference<FalseKey> public var hideTrends
|
|
|
|
// MARK: Advanced
|
|
@Preference<StatusContentTypeKey> public var statusContentType
|
|
@Preference<TrueKey> public var reportErrorsAutomatically
|
|
@Preference<FeatureFlagsKey> public var enabledFeatureFlags
|
|
|
|
// MARK: Internal
|
|
@Preference<FalseKey> public var hasShownLocalTimelineDescription
|
|
@Preference<FalseKey> public var hasShownFederatedTimelineDescription
|
|
}
|
|
|
|
extension PreferenceStore {
|
|
public func hasFeatureFlag(_ flag: FeatureFlag) -> Bool {
|
|
enabledFeatureFlags.contains(flag)
|
|
}
|
|
|
|
|
|
public func getValue<Key: PreferenceKey>(preferenceKeyPath: KeyPath<PreferenceStore, PreferencePublisher<Key>>) -> Key.Value {
|
|
self[keyPath: preferenceKeyPath].preference.wrappedValue
|
|
}
|
|
}
|