Repository: Automattic/pocket-casts-ios
File: podcasts/New Detail/Episode Add/ManualPlaylistsChooserViewController.swift (Swift)

Code before:
        newSelectedPlaylists = initialSelectedPlaylists
    }

    private func addCloseButton() {
        let closeButton = createStandardCloseButton(imageName: "cancel")
        closeButton.addTarget(self, action: #selector(closeTapped(_:)), for: .touchUpInside)

        let backButtonItem = UIBarButtonItem(customView: closeButton)
        navigationItem.leftBarButtonItem = backButtonItem
    }

    @objc private func closeTapped(_ sender: Any) {
        dismiss(animated: true, completion: nil)
    }

    @objc private func doneTapped() {
        let added = newSelectedPlaylists.subtracting(initialSelectedPlaylists)
        let removed = initialSelectedPlaylists.subtracting(newSelectedPlaylists)

        FileLog.shared.console("Added \(added), removed \(removed)")

        manualPlaylists.forEach { playlist in
            if added.contains(playlist.uuid) {
                let didAdd = dataManager.add(episodes: [episode], to: playlist)
                guard didAdd else {
                    Toast.show(L10n.playlistManualAddEpisodeFullPlaylistToast)
                    return
                }
            }
            if removed.contains(playlist.uuid) {
                dataManager.deleteEpisodes([episode.uuid], from: playlist)
            }
        }

        dismiss(animated: true, completion: nil)
    }
}

extension ManualPlaylistsChooserViewController: UITableViewDelegate, UITableViewDataSource {
    func numberOfSections(in tableView: UITableView) -> Int {
        return TableSection.allCases.count
    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        switch section {
        case TableSection.addNewPlaylist.rawValue:
            return 1
        default:
            return manualPlaylists.count
        }
    }

Review comment (suggestion):
We should use a `ToastTheme` to inject and set the left icon
<img width="523" height="105" alt="Screenshot 2025-10-30 at 09 40 46" src="https://github.com/user-attachments/assets/807fb39e-8bc2-42af-9d88-37fae549e4e9" />


Code after:
        newSelectedPlaylists = initialSelectedPlaylists
    }

    private func addCloseButton() {
        let closeButton = createStandardCloseButton(imageName: "cancel")
        closeButton.addTarget(self, action: #selector(closeTapped(_:)), for: .touchUpInside)

        let backButtonItem = UIBarButtonItem(customView: closeButton)
        navigationItem.leftBarButtonItem = backButtonItem
    }

    @objc private func closeTapped(_ sender: Any) {
        dismiss(animated: true, completion: nil)
    }

    @objc private func doneTapped() {
        let added = newSelectedPlaylists.subtracting(initialSelectedPlaylists)
        let removed = initialSelectedPlaylists.subtracting(newSelectedPlaylists)

        FileLog.shared.console("Added \(added), removed \(removed)")

        manualPlaylists.forEach { playlist in
            if added.contains(playlist.uuid) {
                let didAdd = dataManager.add(episodes: [episode], to: playlist)
                guard didAdd else {
                    let theme: any ToastTheme = ToastIconTheme(iconName: "option-alert", iconColor: Theme.sharedTheme.primaryIcon01)
                    Toast.show(L10n.playlistManualAddEpisodeFullPlaylistToast, theme: theme)
                    return
                }
            }
            if removed.contains(playlist.uuid) {
                dataManager.deleteEpisodes([episode.uuid], from: playlist)
            }
        }

        dismiss(animated: true, completion: nil)
    }
}

extension ManualPlaylistsChooserViewController: UITableViewDelegate, UITableViewDataSource {
    func numberOfSections(in tableView: UITableView) -> Int {
        return TableSection.allCases.count
    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        switch section {
        case TableSection.addNewPlaylist.rawValue:
            return 1
        default:
            return manualPlaylists.count
        }