Kurdtvs-Live-Kurdish-TV-Kur.../Mastodon/Diffiable/Item/SettingsItem.swift

115 lines
4.1 KiB
Swift
Raw Normal View History

//
// SettingsItem.swift
// Mastodon
//
// Created by MainasuK Cirno on 2021-4-25.
//
import UIKit
import CoreData
2021-07-22 07:47:56 +02:00
enum SettingsItem {
2021-06-22 14:52:30 +02:00
case appearance(settingObjectID: NSManagedObjectID)
case notification(settingObjectID: NSManagedObjectID, switchMode: NotificationSwitchMode)
2021-07-22 07:47:56 +02:00
case preference(settingObjectID: NSManagedObjectID, preferenceType: PreferenceType)
case boringZone(item: Link)
case spicyZone(item: Link)
}
extension SettingsItem {
enum AppearanceMode: String {
case automatic
case light
case dark
}
2021-07-22 07:47:56 +02:00
enum NotificationSwitchMode: CaseIterable, Hashable {
case favorite
case follow
case reblog
case mention
var title: String {
switch self {
case .favorite: return L10n.Scene.Settings.Section.Notifications.favorites
case .follow: return L10n.Scene.Settings.Section.Notifications.follows
case .reblog: return L10n.Scene.Settings.Section.Notifications.boosts
case .mention: return L10n.Scene.Settings.Section.Notifications.mentions
}
}
}
2021-07-22 07:47:56 +02:00
enum PreferenceType: CaseIterable {
case darkMode
case disableAvatarAnimation
2021-07-23 13:33:05 +02:00
case disableEmojiAnimation
2021-07-22 07:47:56 +02:00
case useDefaultBrowser
var title: String {
switch self {
2021-07-23 13:33:05 +02:00
case .darkMode: return L10n.Scene.Settings.Section.Preference.trueBlackDarkMode
case .disableAvatarAnimation: return L10n.Scene.Settings.Section.Preference.disableAvatarAnimation
case .disableEmojiAnimation: return L10n.Scene.Settings.Section.Preference.disableEmojiAnimation
2021-07-22 07:47:56 +02:00
case .useDefaultBrowser: return L10n.Scene.Settings.Section.Preference.usingDefaultBrowser
}
}
}
2021-07-22 07:47:56 +02:00
enum Link: CaseIterable, Hashable {
case accountSettings
case github
case termsOfService
case privacyPolicy
case clearMediaCache
case signOut
var title: String {
switch self {
2021-07-15 15:04:31 +02:00
case .accountSettings: return L10n.Scene.Settings.Section.BoringZone.accountSettings
case .github: return "GitHub"
2021-07-15 15:04:31 +02:00
case .termsOfService: return L10n.Scene.Settings.Section.BoringZone.terms
case .privacyPolicy: return L10n.Scene.Settings.Section.BoringZone.privacy
case .clearMediaCache: return L10n.Scene.Settings.Section.SpicyZone.clear
case .signOut: return L10n.Scene.Settings.Section.SpicyZone.signout
}
}
var textColor: UIColor {
switch self {
case .accountSettings: return Asset.Colors.brandBlue.color
case .github: return Asset.Colors.brandBlue.color
2021-06-22 14:52:30 +02:00
case .termsOfService: return Asset.Colors.brandBlue.color
case .privacyPolicy: return Asset.Colors.brandBlue.color
case .clearMediaCache: return .systemRed
case .signOut: return .systemRed
}
}
}
}
2021-07-22 07:47:56 +02:00
extension SettingsItem: Hashable {
func hash(into hasher: inout Hasher) {
switch self {
case .appearance(let settingObjectID):
hasher.combine(String(describing: SettingsItem.AppearanceMode.self))
hasher.combine(settingObjectID)
case .notification(let settingObjectID, let switchMode):
hasher.combine(String(describing: SettingsItem.notification.self))
hasher.combine(settingObjectID)
hasher.combine(switchMode)
case .preference(let settingObjectID, let preferenceType):
hasher.combine(String(describing: SettingsItem.preference.self))
hasher.combine(settingObjectID)
hasher.combine(preferenceType)
case .boringZone(let link):
hasher.combine(String(describing: SettingsItem.boringZone.self))
hasher.combine(link)
case .spicyZone(let link):
hasher.combine(String(describing: SettingsItem.spicyZone.self))
hasher.combine(link)
}
}
}