Move black theme setting to settings screen itself
Context: !1441 (comment 478128)
Merge request reports
Activity
cc @ePirat
added 1 commit
- 40a2608b - Move disableGrouping into DefaultsChangeListener.
added 1 commit
- 8d47fde8 - Move hideMediaLibrary and excludeFromDeviceBackup into DefaultsChangeListener.
- Sources/App/iOS/DefaultsChangeListener.swift 0 → 100644
1 /***************************************************************************** 2 * DefaultsChangeListener.swift 3 * VLC for iOS 4 ***************************************************************************** 5 * Copyright (c) 2025 VideoLAN. All rights reserved. 6 * $Id$ 7 * 8 * Authors: Craig Reyenga <craig.reyenga # gmail.com> 9 * 10 * Refer to the COPYING file of the official project for license. 11 *****************************************************************************/ 12 13 /// Emits notifications or performs other actions based on updates to user defaults. 14 @objc(VLCDefaultsChangeListener) 15 final class DefaultsChangeListener: NSObject { Here is what I am thinking:
- Some settings require side effects (such as emitting a notification), some do not.
- user defaults are where the truth of a given setting lives.
- Apple's UserDefaults class, or a wrapper made by us shouldn't be responsible for managing specific dependencies such as notifying that the theme has changed
- it should be possible (and easy) to place a setting UI element anywhere in the app, such as the player perhaps, and trust that any side effects will be performed, just as if it was being done in the settings screen. It is best not to rely on the settings view controller being awake at all times, listening for notifications to then perform side effects. This is probably the biggest reason I did this.
- my hope is that settings can get everything it needs from PLIST info, and the SettingsViewController, ActionSheet, etc. can just display them and change them without needing to know any details (i.e.
if (someSetting) { do something special }
). - I believe this new class puts the dependencies in plain sight.
Before making this class, I first tried to have PresentationTheme listen for notifications itself, but since there are multiple instances of it, it was firing many times. Then, I looked for a high place in the app hierarchy where I could put something that can listen for changes and react appropriately. Then, it occurred to me that other dependencies could be placed here.
We have the
kVLCThemeDidChangeNotification
notification since the invention of theming in VLC-iOS. I don't understand why you want to complexify this code path. Since any object can always ask for the current theme, there was never a problem with the UI not being updated or showing a mixed state. This does not rely on the settings screen being in memory or not. I don't understand why you want the PresentationTheme class to listen for notifications. This is the obligation of the view controller.
mentioned in issue #1828