mirror of
https://github.com/mastodon/mastodon-ios.git
synced 2025-01-23 22:11:22 +01:00
Clean up settings (a bit, IOS-14)
This commit is contained in:
parent
9ec380cccd
commit
24724b9943
@ -3,7 +3,7 @@
|
||||
import UIKit
|
||||
import MastodonAsset
|
||||
|
||||
protocol GeneralSettingToggleCellDelegate: AnyObject {
|
||||
protocol GeneralSettingToggleTableViewCellDelegate: AnyObject {
|
||||
func toggle(_ cell: GeneralSettingToggleTableViewCell, setting: GeneralSetting, isOn: Bool)
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ class GeneralSettingToggleTableViewCell: ToggleTableViewCell {
|
||||
return "GeneralSettingToggleCell"
|
||||
}
|
||||
|
||||
weak var delegate: GeneralSettingToggleCellDelegate?
|
||||
weak var delegate: GeneralSettingToggleTableViewCellDelegate?
|
||||
var setting: GeneralSetting?
|
||||
|
||||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||
|
@ -15,7 +15,6 @@ enum GeneralSettingsSectionType: Hashable {
|
||||
|
||||
var sectionTitle: String {
|
||||
switch self {
|
||||
//TODO: @zeitschlag Localization
|
||||
case .appearance:
|
||||
return L10n.Scene.Settings.General.Appearance.sectionTitle
|
||||
case .design:
|
||||
|
@ -144,7 +144,7 @@ extension GeneralSettingsViewController: UITableViewDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
extension GeneralSettingsViewController: GeneralSettingToggleCellDelegate {
|
||||
extension GeneralSettingsViewController: GeneralSettingToggleTableViewCellDelegate {
|
||||
func toggle(_ cell: GeneralSettingToggleTableViewCell, setting: GeneralSetting, isOn: Bool) {
|
||||
switch setting {
|
||||
case .appearance(_), .openLinksIn(_):
|
||||
|
@ -55,17 +55,10 @@ extension Setting {
|
||||
property: Property
|
||||
) -> Setting {
|
||||
let setting: Setting = context.insertObject()
|
||||
// setting.appearanceRaw = property.appearanceRaw
|
||||
setting.domain = property.domain
|
||||
setting.userID = property.userID
|
||||
return setting
|
||||
}
|
||||
|
||||
// public func update(appearanceRaw: String) {
|
||||
// guard appearanceRaw != self.appearanceRaw else { return }
|
||||
// self.appearanceRaw = appearanceRaw
|
||||
// didUpdate(at: Date())
|
||||
// }
|
||||
|
||||
public func update(preferredStaticAvatar: Bool) {
|
||||
guard preferredStaticAvatar != self.preferredStaticAvatar else { return }
|
||||
@ -95,16 +88,13 @@ extension Setting {
|
||||
public struct Property {
|
||||
public let domain: String
|
||||
public let userID: String
|
||||
// public let appearanceRaw: String
|
||||
|
||||
public init(
|
||||
domain: String,
|
||||
userID: String
|
||||
// appearanceRaw: String
|
||||
) {
|
||||
self.domain = domain
|
||||
self.userID = userID
|
||||
// self.appearanceRaw = appearanceRaw
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -122,5 +112,13 @@ extension Setting {
|
||||
#keyPath(Setting.userID), userID
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
extension Setting {
|
||||
public var activeSubscription: Subscription? {
|
||||
return (subscriptions ?? Set())
|
||||
.sorted(by: { $0.activedAt > $1.activedAt })
|
||||
.first
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +0,0 @@
|
||||
//
|
||||
// Setting.swift
|
||||
// Mastodon
|
||||
//
|
||||
// Created by MainasuK Cirno on 2021-4-25.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreDataStack
|
||||
import MastodonSDK
|
||||
|
||||
extension Setting {
|
||||
|
||||
// var appearance: SettingsItem.AppearanceMode {
|
||||
// return SettingsItem.AppearanceMode(rawValue: appearanceRaw) ?? .automatic
|
||||
// }
|
||||
|
||||
public var activeSubscription: Subscription? {
|
||||
return (subscriptions ?? Set())
|
||||
.sorted(by: { $0.activedAt > $1.activedAt })
|
||||
.first
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user