//
//  © 2019-2020 Qualcomm Technologies, Inc. and/or its subsidiaries. All rights reserved.
//

import Foundation

enum AudioSettingsRowType {
    case simple
    case submenu
    case toggle(value: Bool)
    case slider(value: Double)
    case option(value: String)
    case checkableOption(checked: Bool)
}

struct AudioSettingsRow {
    let identifier: String
    let type: AudioSettingsRowType
    let title: String
    let accessibilityTitle: String
}

protocol AudioSettingsViewController: class {
    var viewModel: AudioSettingsViewModel? { get set }

    func reloadAll()
    func present(viewController: AudioSettingsViewController)
}

protocol AudioSettingsViewModel: class {
    var viewController: AudioSettingsViewController? { get set }
    var playerID: String? { get set }

    var preferences: Preferences? { get set }
    var playerController: PlayerControllerProtocol? { get set }

    var title: String { get }
    func rows()->[AudioSettingsRow]
    func toggleChanged(_ row: AudioSettingsRow, value: Bool)
    func sliderMoved(_ row: AudioSettingsRow, value: Double)
    func optionRowTapped(_ row: AudioSettingsRow)
    func submenuTapped(_ row: AudioSettingsRow)
    func checkableOptionChecked(_ row: AudioSettingsRow)
}

extension AudioSettingsViewModel {
    func presentViewController(viewModel: AudioSettingsViewModel) {
        let vc = AudioSettingsTableViewController.instantiateFromStoryboard(name: "AudioSettings")
        vc.viewModel = viewModel
        viewModel.viewController = vc
        viewModel.playerID = playerID
        viewModel.preferences = preferences
        viewModel.playerController = playerController
        viewController?.present(viewController: vc)
    }
}





