1
1
mirror of https://github.com/bitgapp/eqMac.git synced 2024-12-14 09:54:32 +03:00
eqMac/native/app/Source/Audio/Volume/VolumeState.swift
2020-04-04 19:15:38 +01:00

40 lines
866 B
Swift

//
// VolumeState.swift
// eqMac
//
// Created by Roman Kisil on 29/06/2018.
// Copyright © 2018 Roman Kisil. All rights reserved.
//
import Foundation
import ReSwift
import SwiftyUserDefaults
struct VolumeState: State {
var gain: Double = 0.5
var balance: Double = 0
var transition: Bool = false
}
enum VolumeAction: Action {
case setGain(Double, Bool)
case setBalance(Double, Bool)
}
func VolumeStateReducer(action: Action, state: VolumeState?) -> VolumeState {
var state = state ?? VolumeState()
switch action as? VolumeAction {
case .setGain(let gain, let transition)?:
state.gain = gain
state.transition = transition
case .setBalance(let balance, let transition)?:
state.balance = balance
state.transition = transition
case .none:
break
}
return state
}