1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-25 06:06:21 +03:00

GH-436 Refactor slightly

This commit is contained in:
Tae Won Ha 2017-06-28 19:55:43 +02:00
parent f6662620be
commit 77cc5cdb53
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
2 changed files with 18 additions and 24 deletions

View File

@ -70,18 +70,8 @@ class FileOutlineView: NSOutlineView,
themePrefChanged: state.appearance.usesTheme != self.usesTheme,
themeChanged: state.appearance.theme.mark != self.lastThemeMark,
usesTheme: state.appearance.usesTheme,
forTheme: {
self.theme = state.appearance.theme.payload
self.enclosingScrollView?.backgroundColor = self.theme.background
self.backgroundColor = self.theme.background
self.lastThemeMark = state.appearance.theme.mark
},
forDefaultTheme: {
self.theme = Theme.default
self.enclosingScrollView?.backgroundColor = self.theme.background
self.backgroundColor = self.theme.background
self.lastThemeMark = state.appearance.theme.mark
})
forTheme: { self.updateTheme(state.appearance.theme) },
forDefaultTheme: { self.updateTheme(Marked(Theme.default)) })
self.usesTheme = state.appearance.usesTheme
@ -137,6 +127,13 @@ class FileOutlineView: NSOutlineView,
fatalError("init(coder:) has not been implemented")
}
fileprivate func updateTheme(_ theme: Marked<Theme>) {
self.theme = theme.payload
self.enclosingScrollView?.backgroundColor = self.theme.background
self.backgroundColor = self.theme.background
self.lastThemeMark = theme.mark
}
fileprivate func shouldReloadData(for state: StateType, themeChanged: Bool = false) -> Bool {
if self.isShowHidden != state.fileBrowserShowHidden {
return true

View File

@ -48,18 +48,8 @@ class OpenedFileList: NSView,
themePrefChanged: state.appearance.usesTheme != self.usesTheme,
themeChanged: state.appearance.theme.mark != self.lastThemeMark,
usesTheme: state.appearance.usesTheme,
forTheme: {
self.theme = state.appearance.theme.payload
self.bufferList.enclosingScrollView?.backgroundColor = self.theme.background
self.bufferList.backgroundColor = self.theme.background
self.lastThemeMark = state.appearance.theme.mark
},
forDefaultTheme: {
self.theme = Theme.default
self.bufferList.enclosingScrollView?.backgroundColor = self.theme.background
self.bufferList.backgroundColor = self.theme.background
self.lastThemeMark = state.appearance.theme.mark
})
forTheme: { self.updateTheme(state.appearance.theme) },
forDefaultTheme: { self.updateTheme(Marked(Theme.default)) })
self.usesTheme = state.appearance.usesTheme
@ -91,6 +81,13 @@ class OpenedFileList: NSView,
fatalError("init(coder:) has not been implemented")
}
fileprivate func updateTheme(_ theme: Marked<Theme>) {
self.theme = theme.payload
self.bufferList.enclosingScrollView?.backgroundColor = self.theme.background
self.bufferList.backgroundColor = self.theme.background
self.lastThemeMark = theme.mark
}
fileprivate func addViews() {
let scrollView = NSScrollView.standardScrollView()
scrollView.borderType = .noBorder