Skip to content
Snippets Groups Projects

Move black theme setting to settings screen itself

Open Craig Reyenga requested to merge craig_r/vlc-ios:craig_r/black-theme into master
1 unresolved thread

Merge request reports

Members who can merge are allowed to add commits.

Merge request pipeline #575871 passed

Merge request pipeline passed for 8d47fde8

Approval is optional
The target branch master does not exist. Please restore it or use a different target branch.

Merge details

  • The source branch is 11 commits behind the target branch.
  • 1 commit will be added to master.
  • Source branch will be deleted.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
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 {
  • Author Contributor

    This may be a bit controversial, but I believe it is the way to go. Updates to defaults that trigger other changes should dispatch through a single, persistently-running place in the app.

  • and why not send a NSNotification?

  • Author Contributor

    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.

  • Please register or sign in to reply
  • Craig Reyenga mentioned in issue #1828

    mentioned in issue #1828

  • Please register or sign in to reply
    Loading