chore: change setting items position
This commit is contained in:
parent
2b19307e57
commit
7318d9da3d
|
@ -10,9 +10,9 @@ import CoreData
|
||||||
|
|
||||||
enum SettingsItem: Hashable {
|
enum SettingsItem: Hashable {
|
||||||
case appearance(settingObjectID: NSManagedObjectID)
|
case appearance(settingObjectID: NSManagedObjectID)
|
||||||
case appearanceDarkMode(settingObjectID: NSManagedObjectID)
|
|
||||||
case appearanceDisableAvatarAnimation(settingObjectID: NSManagedObjectID)
|
|
||||||
case notification(settingObjectID: NSManagedObjectID, switchMode: NotificationSwitchMode)
|
case notification(settingObjectID: NSManagedObjectID, switchMode: NotificationSwitchMode)
|
||||||
|
case preferenceDarkMode(settingObjectID: NSManagedObjectID)
|
||||||
|
case preferenceDisableAvatarAnimation(settingObjectID: NSManagedObjectID)
|
||||||
case preferenceUsingDefaultBrowser(settingObjectID: NSManagedObjectID)
|
case preferenceUsingDefaultBrowser(settingObjectID: NSManagedObjectID)
|
||||||
case boringZone(item: Link)
|
case boringZone(item: Link)
|
||||||
case spicyZone(item: Link)
|
case spicyZone(item: Link)
|
||||||
|
@ -51,7 +51,7 @@ extension SettingsItem {
|
||||||
|
|
||||||
var title: String {
|
var title: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .accountSettings: return "Account settings"
|
case .accountSettings: return L10n.Scene.Settings.Section.Boringzone.accountSettings
|
||||||
case .termsOfService: return L10n.Scene.Settings.Section.Boringzone.terms
|
case .termsOfService: return L10n.Scene.Settings.Section.Boringzone.terms
|
||||||
case .privacyPolicy: return L10n.Scene.Settings.Section.Boringzone.privacy
|
case .privacyPolicy: return L10n.Scene.Settings.Section.Boringzone.privacy
|
||||||
case .clearMediaCache: return L10n.Scene.Settings.Section.Spicyzone.clear
|
case .clearMediaCache: return L10n.Scene.Settings.Section.Spicyzone.clear
|
||||||
|
|
|
@ -9,7 +9,6 @@ import Foundation
|
||||||
|
|
||||||
enum SettingsSection: Hashable {
|
enum SettingsSection: Hashable {
|
||||||
case appearance
|
case appearance
|
||||||
case appearanceSettings
|
|
||||||
case notifications
|
case notifications
|
||||||
case preference
|
case preference
|
||||||
case boringZone
|
case boringZone
|
||||||
|
@ -18,7 +17,6 @@ enum SettingsSection: Hashable {
|
||||||
var title: String {
|
var title: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .appearance: return L10n.Scene.Settings.Section.Appearance.title
|
case .appearance: return L10n.Scene.Settings.Section.Appearance.title
|
||||||
case .appearanceSettings: return ""
|
|
||||||
case .notifications: return L10n.Scene.Settings.Section.Notifications.title
|
case .notifications: return L10n.Scene.Settings.Section.Notifications.title
|
||||||
case .preference: return L10n.Scene.Settings.Section.Preference.title
|
case .preference: return L10n.Scene.Settings.Section.Preference.title
|
||||||
case .boringZone: return L10n.Scene.Settings.Section.Boringzone.title
|
case .boringZone: return L10n.Scene.Settings.Section.Boringzone.title
|
||||||
|
|
|
@ -224,8 +224,8 @@ extension SearchDetailViewController {
|
||||||
override func viewWillDisappear(_ animated: Bool) {
|
override func viewWillDisappear(_ animated: Bool) {
|
||||||
super.viewWillDisappear(animated)
|
super.viewWillDisappear(animated)
|
||||||
|
|
||||||
if navigationController?.viewControllers.count != 1 {
|
if !isModal {
|
||||||
// set bar hidden but not when self is root
|
// prevent bar restore conflict with modal style issue
|
||||||
navigationController?.setNavigationBarHidden(false, animated: animated)
|
navigationController?.setNavigationBarHidden(false, animated: animated)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -358,7 +358,7 @@ extension SettingsViewController: UITableViewDelegate {
|
||||||
case .appearance:
|
case .appearance:
|
||||||
// do nothing
|
// do nothing
|
||||||
break
|
break
|
||||||
case .appearanceDarkMode, .appearanceDisableAvatarAnimation:
|
case .preferenceDarkMode, .preferenceDisableAvatarAnimation:
|
||||||
// do nothing
|
// do nothing
|
||||||
break
|
break
|
||||||
case .notification:
|
case .notification:
|
||||||
|
@ -457,38 +457,6 @@ extension SettingsViewController: SettingsToggleCellDelegate {
|
||||||
let item = dataSource.itemIdentifier(for: indexPath)
|
let item = dataSource.itemIdentifier(for: indexPath)
|
||||||
|
|
||||||
switch item {
|
switch item {
|
||||||
case .appearanceDarkMode(let settingObjectID):
|
|
||||||
let managedObjectContext = context.backgroundManagedObjectContext
|
|
||||||
managedObjectContext.performChanges {
|
|
||||||
let setting = managedObjectContext.object(with: settingObjectID) as! Setting
|
|
||||||
setting.update(preferredTrueBlackDarkMode: isOn)
|
|
||||||
}
|
|
||||||
.sink { result in
|
|
||||||
switch result {
|
|
||||||
case .success:
|
|
||||||
ThemeService.shared.set(themeName: isOn ? .system : .mastodon)
|
|
||||||
case .failure(let error):
|
|
||||||
assertionFailure(error.localizedDescription)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.store(in: &disposeBag)
|
|
||||||
case .appearanceDisableAvatarAnimation(let settingObjectID):
|
|
||||||
let managedObjectContext = context.backgroundManagedObjectContext
|
|
||||||
managedObjectContext.performChanges {
|
|
||||||
let setting = managedObjectContext.object(with: settingObjectID) as! Setting
|
|
||||||
setting.update(preferredStaticAvatar: isOn)
|
|
||||||
}
|
|
||||||
.sink { result in
|
|
||||||
switch result {
|
|
||||||
case .success:
|
|
||||||
UserDefaults.shared.preferredStaticAvatar = isOn
|
|
||||||
case .failure(let error):
|
|
||||||
assertionFailure(error.localizedDescription)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.store(in: &disposeBag)
|
|
||||||
case .notification(let settingObjectID, let switchMode):
|
case .notification(let settingObjectID, let switchMode):
|
||||||
let managedObjectContext = context.backgroundManagedObjectContext
|
let managedObjectContext = context.backgroundManagedObjectContext
|
||||||
managedObjectContext.performChanges {
|
managedObjectContext.performChanges {
|
||||||
|
@ -508,6 +476,38 @@ extension SettingsViewController: SettingsToggleCellDelegate {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
|
case .preferenceDarkMode(let settingObjectID):
|
||||||
|
let managedObjectContext = context.backgroundManagedObjectContext
|
||||||
|
managedObjectContext.performChanges {
|
||||||
|
let setting = managedObjectContext.object(with: settingObjectID) as! Setting
|
||||||
|
setting.update(preferredTrueBlackDarkMode: isOn)
|
||||||
|
}
|
||||||
|
.sink { result in
|
||||||
|
switch result {
|
||||||
|
case .success:
|
||||||
|
ThemeService.shared.set(themeName: isOn ? .system : .mastodon)
|
||||||
|
case .failure(let error):
|
||||||
|
assertionFailure(error.localizedDescription)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.store(in: &disposeBag)
|
||||||
|
case .preferenceDisableAvatarAnimation(let settingObjectID):
|
||||||
|
let managedObjectContext = context.backgroundManagedObjectContext
|
||||||
|
managedObjectContext.performChanges {
|
||||||
|
let setting = managedObjectContext.object(with: settingObjectID) as! Setting
|
||||||
|
setting.update(preferredStaticAvatar: isOn)
|
||||||
|
}
|
||||||
|
.sink { result in
|
||||||
|
switch result {
|
||||||
|
case .success:
|
||||||
|
UserDefaults.shared.preferredStaticAvatar = isOn
|
||||||
|
case .failure(let error):
|
||||||
|
assertionFailure(error.localizedDescription)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.store(in: &disposeBag)
|
||||||
case .preferenceUsingDefaultBrowser(let settingObjectID):
|
case .preferenceUsingDefaultBrowser(let settingObjectID):
|
||||||
let managedObjectContext = context.backgroundManagedObjectContext
|
let managedObjectContext = context.backgroundManagedObjectContext
|
||||||
managedObjectContext.performChanges {
|
managedObjectContext.performChanges {
|
||||||
|
|
|
@ -112,13 +112,6 @@ extension SettingsViewModel {
|
||||||
snapshot.appendSections([.appearance])
|
snapshot.appendSections([.appearance])
|
||||||
snapshot.appendItems(appearanceItems, toSection: .appearance)
|
snapshot.appendItems(appearanceItems, toSection: .appearance)
|
||||||
|
|
||||||
let appearanceSettingItems = [
|
|
||||||
SettingsItem.appearanceDarkMode(settingObjectID: setting.objectID),
|
|
||||||
SettingsItem.appearanceDisableAvatarAnimation(settingObjectID: setting.objectID)
|
|
||||||
]
|
|
||||||
snapshot.appendSections([.appearanceSettings])
|
|
||||||
snapshot.appendItems(appearanceSettingItems, toSection: .appearanceSettings)
|
|
||||||
|
|
||||||
// notification
|
// notification
|
||||||
let notificationItems = SettingsItem.NotificationSwitchMode.allCases.map { mode in
|
let notificationItems = SettingsItem.NotificationSwitchMode.allCases.map { mode in
|
||||||
SettingsItem.notification(settingObjectID: setting.objectID, switchMode: mode)
|
SettingsItem.notification(settingObjectID: setting.objectID, switchMode: mode)
|
||||||
|
@ -128,7 +121,12 @@ extension SettingsViewModel {
|
||||||
|
|
||||||
// preference
|
// preference
|
||||||
snapshot.appendSections([.preference])
|
snapshot.appendSections([.preference])
|
||||||
snapshot.appendItems([.preferenceUsingDefaultBrowser(settingObjectID: setting.objectID)], toSection: .preference)
|
let preferenceItems: [SettingsItem] = [
|
||||||
|
.preferenceDarkMode(settingObjectID: setting.objectID),
|
||||||
|
.preferenceDisableAvatarAnimation(settingObjectID: setting.objectID),
|
||||||
|
.preferenceUsingDefaultBrowser(settingObjectID: setting.objectID),
|
||||||
|
]
|
||||||
|
snapshot.appendItems(preferenceItems,toSection: .preference)
|
||||||
|
|
||||||
// boring zone
|
// boring zone
|
||||||
let boringZoneSettingsItems: [SettingsItem] = {
|
let boringZoneSettingsItems: [SettingsItem] = {
|
||||||
|
@ -191,8 +189,8 @@ extension SettingsViewModel {
|
||||||
}
|
}
|
||||||
cell.delegate = settingsAppearanceTableViewCellDelegate
|
cell.delegate = settingsAppearanceTableViewCellDelegate
|
||||||
return cell
|
return cell
|
||||||
case .appearanceDarkMode(let objectID),
|
case .preferenceDarkMode(let objectID),
|
||||||
.appearanceDisableAvatarAnimation(let objectID),
|
.preferenceDisableAvatarAnimation(let objectID),
|
||||||
.preferenceUsingDefaultBrowser(let objectID):
|
.preferenceUsingDefaultBrowser(let objectID):
|
||||||
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: SettingsToggleTableViewCell.self), for: indexPath) as! SettingsToggleTableViewCell
|
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: SettingsToggleTableViewCell.self), for: indexPath) as! SettingsToggleTableViewCell
|
||||||
cell.delegate = settingsToggleCellDelegate
|
cell.delegate = settingsToggleCellDelegate
|
||||||
|
@ -253,10 +251,10 @@ extension SettingsViewModel {
|
||||||
setting: Setting
|
setting: Setting
|
||||||
) {
|
) {
|
||||||
switch item {
|
switch item {
|
||||||
case .appearanceDarkMode:
|
case .preferenceDarkMode:
|
||||||
cell.textLabel?.text = L10n.Scene.Settings.Section.AppearanceSettings.trueBlackDarkMode
|
cell.textLabel?.text = L10n.Scene.Settings.Section.AppearanceSettings.trueBlackDarkMode
|
||||||
cell.switchButton.isOn = setting.preferredTrueBlackDarkMode
|
cell.switchButton.isOn = setting.preferredTrueBlackDarkMode
|
||||||
case .appearanceDisableAvatarAnimation:
|
case .preferenceDisableAvatarAnimation:
|
||||||
cell.textLabel?.text = L10n.Scene.Settings.Section.AppearanceSettings.disableAvatarAnimation
|
cell.textLabel?.text = L10n.Scene.Settings.Section.AppearanceSettings.disableAvatarAnimation
|
||||||
cell.switchButton.isOn = setting.preferredStaticAvatar
|
cell.switchButton.isOn = setting.preferredStaticAvatar
|
||||||
case .preferenceUsingDefaultBrowser:
|
case .preferenceUsingDefaultBrowser:
|
||||||
|
|
Loading…
Reference in New Issue