CutBox.app

Coverage Report

Created: 2024-03-12 03:40

.../Source/App/Preferences/PreferencesThemeSelectionView+HidePreview.swift
Line
Count
Source (jump to first uncovered line)
1
//
2
//  PreferencesThemeSelectionView+HidePreview.swift
3
//  CutBox
4
//
5
//  Created by Carlos Enumo on 22/09/22.
6
//  Copyright © 2023 ocodo. All rights reserved.
7
//
8
9
import RxCocoa
10
import RxSwift
11
12
extension PreferencesThemeSelectionView {
13
14
49
    func setupHidePreviewControl() {
15
49
        self.hidePreviewCheckbox.title = "preferences_hide_preview".l7n
16
49
        self.hidePreviewCheckbox.toolTip = "preferences_hide_preview_tooltip".l7n
17
49
18
49
        self.hidePreviewCheckbox.state = self.prefs.hidePreview ? .on : .off
19
49
20
49
        self.hidePreviewCheckbox
21
49
            .rx
22
49
            .state
23
49
            .map { $0 == .on }
24
49
            .subscribe(onNext: { self.prefs.hidePreview = $0 })
25
49
            .disposed(by: disposeBag)
26
49
27
49
        self.prefs
28
49
            .events
29
5.88k
            .subscribe(onNext: {
30
5.88k
                if case .hidePreviewSettingChanged(let isOn) = $0 {
31
1.17k
                    self.hidePreviewCheckbox.state = isOn ? .on : .off
32
5.88k
                }
33
5.88k
            })
34
49
            .disposed(by: disposeBag)
35
49
    }
36
}