Remove dead code found by Periphery on all platforms

Delete declarations that Periphery reports unused on every platform that
compiles them (iOS, macOS, tvOS), including nine views used only by their
own previews. Platform-gated code still used on another platform, device-
only MPV render paths, migration models, CloudKit record names, App
Intents metadata and unused parameters are kept.
This commit is contained in:
Arkadiusz Fal
2026-10-08 23:57:56 +02:00
parent 45e19e6536
commit 4770bbe3b9
141 changed files with 14 additions and 4191 deletions

View File

@@ -16,7 +16,6 @@ final class PlayerControlsSettingsViewModel {
// MARK: - Dependencies
private let layoutService: PlayerControlsLayoutService
let settingsManager: SettingsManager
/// Observer for preset changes from CloudKit sync.
@ObservationIgnored private var presetsChangedObserver: NSObjectProtocol?
@@ -54,12 +53,6 @@ final class PlayerControlsSettingsViewModel {
activePreset?.id
}
/// Whether the active preset can be deleted (not built-in and not active).
var canDeleteActivePreset: Bool {
guard let activePreset else { return false }
return !activePreset.isBuiltIn
}
/// Whether the active preset can be edited (not built-in).
var canEditActivePreset: Bool {
guard let activePreset else { return false }
@@ -76,16 +69,6 @@ final class PlayerControlsSettingsViewModel {
activePreset?.layout.centerSettings ?? .default
}
/// Seek backward seconds - exposed for direct observation.
var seekBackwardSeconds: Int {
activePreset?.layout.centerSettings.seekBackwardSeconds ?? 10
}
/// Seek forward seconds - exposed for direct observation.
var seekForwardSeconds: Int {
activePreset?.layout.centerSettings.seekForwardSeconds ?? 10
}
/// Current progress bar settings.
var progressBarSettings: ProgressBarSettings {
activePreset?.layout.progressBarSettings ?? .default
@@ -101,15 +84,6 @@ final class PlayerControlsSettingsViewModel {
presets.filter { !$0.isBuiltIn }.sorted { $0.name < $1.name }
}
/// Button types that are new since last seen.
var newButtonTypes: [ControlButtonType] {
Task.detached { [layoutService] in
await layoutService.newButtonTypes()
}
// Return empty for now; actual implementation will load async
return []
}
// MARK: - Initialization
init(
@@ -117,7 +91,6 @@ final class PlayerControlsSettingsViewModel {
settingsManager: SettingsManager
) {
self.layoutService = layoutService
self.settingsManager = settingsManager
// Observe preset changes from CloudKit sync
presetsChangedObserver = NotificationCenter.default.addObserver(
@@ -204,13 +177,6 @@ final class PlayerControlsSettingsViewModel {
LoggingService.shared.info("Selected preset: \(preset.name)")
}
/// Selects a preset by ID.
/// - Parameter id: The ID of the preset to activate.
func selectPreset(id: UUID) {
guard let preset = presets.first(where: { $0.id == id }) else { return }
selectPreset(preset)
}
// MARK: - Preset Management
/// Creates a new custom preset with the given name.
@@ -290,30 +256,6 @@ final class PlayerControlsSettingsViewModel {
// MARK: - Layout Editing
/// Updates the top section of the current layout.
/// - Parameter section: The new top section configuration.
func updateTopSection(_ section: LayoutSection) async {
await updateLayout { layout in
layout.topSection = section
}
}
/// Updates the bottom section of the current layout.
/// - Parameter section: The new bottom section configuration.
func updateBottomSection(_ section: LayoutSection) async {
await updateLayout { layout in
layout.bottomSection = section
}
}
/// Updates the center settings of the current layout.
/// - Parameter settings: The new center section settings.
func updateCenterSettings(_ settings: CenterSectionSettings) async {
await updateLayout { layout in
layout.centerSettings = settings
}
}
/// Synchronously updates center settings with immediate UI feedback.
/// Saves are debounced to avoid rapid disk writes.
/// - Parameter mutation: A closure that mutates the center settings.
@@ -338,14 +280,6 @@ final class PlayerControlsSettingsViewModel {
queueDebouncedSave(preset: preset)
}
/// Updates the global settings of the current layout.
/// - Parameter settings: The new global settings.
func updateGlobalSettings(_ settings: GlobalLayoutSettings) async {
await updateLayout { layout in
layout.globalSettings = settings
}
}
/// Synchronously updates global settings with immediate UI feedback.
/// Saves are debounced to avoid rapid disk writes.
/// - Parameter mutation: A closure that mutates the global settings.
@@ -382,21 +316,6 @@ final class PlayerControlsSettingsViewModel {
queueDebouncedSave(preset: preset)
}
/// Updates a button configuration in the specified section.
/// - Parameters:
/// - config: The updated button configuration.
/// - section: The section containing the button.
func updateButtonConfiguration(_ config: ControlButtonConfiguration, in section: LayoutSectionType) async {
await updateLayout { layout in
switch section {
case .top:
layout.topSection.update(button: config)
case .bottom:
layout.bottomSection.update(button: config)
}
}
}
/// Synchronously updates a button configuration with immediate UI feedback.
/// Saves are debounced to avoid rapid disk writes.
/// - Parameters:
@@ -422,22 +341,6 @@ final class PlayerControlsSettingsViewModel {
queueDebouncedSave(preset: preset)
}
/// Adds a button to the specified section.
/// - Parameters:
/// - buttonType: The type of button to add.
/// - section: The section to add the button to.
func addButton(_ buttonType: ControlButtonType, to section: LayoutSectionType) async {
await updateLayout { layout in
let config = ControlButtonConfiguration.defaultConfiguration(for: buttonType)
switch section {
case .top:
layout.topSection.add(button: config)
case .bottom:
layout.bottomSection.add(button: config)
}
}
}
/// Synchronously adds a button with immediate UI feedback.
/// - Parameters:
/// - buttonType: The type of button to add.
@@ -462,21 +365,6 @@ final class PlayerControlsSettingsViewModel {
queueDebouncedSave(preset: preset)
}
/// Removes a button from the specified section.
/// - Parameters:
/// - buttonID: The ID of the button to remove.
/// - section: The section containing the button.
func removeButton(_ buttonID: UUID, from section: LayoutSectionType) async {
await updateLayout { layout in
switch section {
case .top:
layout.topSection.remove(id: buttonID)
case .bottom:
layout.bottomSection.remove(id: buttonID)
}
}
}
/// Synchronously removes a button with immediate UI feedback.
/// - Parameters:
/// - buttonID: The ID of the button to remove.
@@ -500,22 +388,6 @@ final class PlayerControlsSettingsViewModel {
queueDebouncedSave(preset: preset)
}
/// Moves a button within a section.
/// - Parameters:
/// - source: Source indices.
/// - destination: Destination index.
/// - section: The section containing the buttons.
func moveButton(fromOffsets source: IndexSet, toOffset destination: Int, in section: LayoutSectionType) async {
await updateLayout { layout in
switch section {
case .top:
layout.topSection.move(fromOffsets: source, toOffset: destination)
case .bottom:
layout.bottomSection.move(fromOffsets: source, toOffset: destination)
}
}
}
/// Synchronously moves a button with immediate UI feedback.
/// - Parameters:
/// - source: Source indices.
@@ -850,13 +722,6 @@ final class PlayerControlsSettingsViewModel {
}
}
/// Moves pages within the panel page order.
func movePanelPages(fromOffsets source: IndexSet, toOffset destination: Int) {
updatePanelSettingsSync { settings in
settings.movePages(fromOffsets: source, toOffset: destination)
}
}
/// Reorders the pages a settings list displays; offsets are relative to
/// `visible` (see `PanelSettings.moveVisiblePages`).
func movePanelPages(visible: [PanelPageType], fromOffsets source: IndexSet, toOffset destination: Int) {
@@ -981,32 +846,6 @@ final class PlayerControlsSettingsViewModel {
// MARK: - Private Helpers
/// Updates the layout and saves to storage.
/// - Parameter mutation: A closure that mutates the layout.
private func updateLayout(_ mutation: (inout PlayerControlsLayout) -> Void) async {
guard let activePreset, !activePreset.isBuiltIn else {
error = "Cannot edit built-in presets. Duplicate it first."
return
}
var layout = activePreset.layout
mutation(&layout)
// Update local state immediately for responsive UI
self.activePreset = activePreset.withUpdatedLayout(layout)
// Save to storage
isSaving = true
do {
try await layoutService.updatePresetLayout(activePreset.id, layout: layout)
await refreshPresets()
} catch {
self.error = error.localizedDescription
LoggingService.shared.error("Failed to save layout: \(error.localizedDescription)")
}
isSaving = false
}
/// Queues a debounced save operation.
/// Cancels any pending save and waits before persisting to avoid rapid disk writes.
/// - Parameter preset: The preset to save.
@@ -1029,21 +868,6 @@ final class PlayerControlsSettingsViewModel {
}
}
// MARK: - NEW Badge Support
/// Marks all button types as seen, hiding NEW badges.
func markAllButtonsAsSeen() async {
await layoutService.markAllButtonsAsSeen()
}
/// Returns whether a button type should show the NEW badge.
/// - Parameter type: The button type to check.
/// - Returns: True if the button was added after the last seen version.
func isNewButton(_ type: ControlButtonType) async -> Bool {
let newTypes = await layoutService.newButtonTypes()
return newTypes.contains(type)
}
// MARK: - Error Handling
/// Clears the current error.