.../Source/App/Preferences/PreferencesGeneralView+ProtectFavorites.swift
Line | Count | Source (jump to first uncovered line) |
1 | | // |
2 | | // PreferencesGeneralView+ProtectFavorites.swift |
3 | | // CutBox |
4 | | // |
5 | | // Created by Jason Milkins on 17/5/18. |
6 | | // Copyright © 2018-2023 ocodo. All rights reserved. |
7 | | // |
8 | | |
9 | | import Foundation |
10 | | |
11 | | extension PreferencesGeneralView { |
12 | | |
13 | 49 | func setupProtectFavoritesCheckbox() { |
14 | 49 | self.protectFavoritesCheckbox.toolTip = "preferences_protect_favorites_tooltip".l7n |
15 | 49 | self.protectFavoritesCheckbox.title = "preferences_protect_favorites".l7n |
16 | 49 | |
17 | 49 | self.protectFavoritesCheckbox.state = self.prefs.protectFavorites ? .on : .off |
18 | 49 | |
19 | 49 | self.protectFavoritesCheckbox |
20 | 49 | .rx |
21 | 49 | .state |
22 | 49 | .map { $0 == .on } |
23 | 49 | .subscribe(onNext: { |
24 | 49 | self.prefs.protectFavorites = $0 |
25 | 49 | }) |
26 | 49 | .disposed(by: disposeBag) |
27 | 49 | |
28 | 49 | self.prefs |
29 | 49 | .events |
30 | 6.07k | .subscribe(onNext: { |
31 | 6.07k | if case .protectFavoritesChanged(let isOn) = $0 { |
32 | 1.17k | self.protectFavoritesCheckbox.state = isOn ? .on : .off |
33 | 6.07k | } |
34 | 6.07k | }) |
35 | 49 | .disposed(by: disposeBag) |
36 | 49 | } |
37 | | } |