1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-28 19:47:41 +03:00
vimr/VimR/AppearancePrefReducer.swift

45 lines
1.0 KiB
Swift
Raw Normal View History

2017-02-28 11:53:27 +03:00
/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Foundation
2017-04-30 10:25:15 +03:00
class AppearancePrefReducer {
2017-02-28 11:53:27 +03:00
typealias Pair = StateActionPair<AppState, AppearancePref.Action>
2017-04-30 10:25:15 +03:00
func reduce(_ pair: Pair) -> Pair {
var state = pair.state
var appearance = state.mainWindowTemplate.appearance
2017-02-28 11:53:27 +03:00
2017-04-30 10:25:15 +03:00
switch pair.action {
2017-02-28 11:53:27 +03:00
case let .setUsesColorscheme(value):
appearance.usesTheme = value
case let .setShowsFileIcon(value):
appearance.showsFileIcon = value
case let .setUsesLigatures(value):
appearance.usesLigatures = value
2017-04-30 10:25:15 +03:00
case let .setFont(font):
appearance.font = font
2017-02-28 11:53:27 +03:00
2017-04-30 10:25:15 +03:00
case let .setLinespacing(linespacing):
appearance.linespacing = linespacing
2017-02-28 11:53:27 +03:00
2017-04-30 10:25:15 +03:00
}
2017-02-28 11:53:27 +03:00
2017-04-30 10:25:15 +03:00
self.modify(state: &state, with: appearance)
2017-02-28 11:53:27 +03:00
2017-04-30 10:25:15 +03:00
return StateActionPair(state: state, action: pair.action)
2017-02-28 11:53:27 +03:00
}
fileprivate func modify(state: inout AppState, with appearance: AppearanceState) {
state.mainWindowTemplate.appearance = appearance
state.mainWindows.keys.forEach { state.mainWindows[$0]?.appearance = appearance }
}
}