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