# CutBox.app

## Coverage Report

#### Created: 2024-03-12 03:40

    .../Source/App/Preferences/PreferencesAdvancedView+MultipleItemWrapping.swift

    Line

    Count

    Source (jump to first uncovered line)

    1

    //

    2

    //  PreferencesAdvancedView+MultipleItemWrapping.swift

    3

    //  CutBox

    4

    //

    5

    //  Created by Jason Milkins on 11/4/18.

    6

    //  Copyright © 2018-2023 ocodo. All rights reserved.

    7

    //

    8

    9

    import RxSwift

    10

    import RxCocoa

    11

    12

    extension PreferencesAdvancedView {

    13

    14

    50

        func setupWrappingStringTextFields() {

    15

    50

            self.shouldWrapMultipleSelection.title = "preferences_multi_clip_wrapped_checkbox_label".l7n

    16

    50

            self.wrapStartTextField.placeholderString = "preferences_multi_clip_wrapped_start_placeholder".l7n

    17

    50

            self.wrapEndTextField.placeholderString = "preferences_multi_clip_wrapped_end_placeholder".l7n

    18

    50

    19

    50

            let (start, end) = prefs.wrappingStrings

    20

    50

            self.wrapStartTextField.stringValue = start ?? ""

    21

    50

            self.wrapEndTextField.stringValue = end ?? ""

    22

    50

    23

    50

            let shouldWrapSaved = prefs.useWrappingStrings

    24

    50

            self.shouldWrapMultipleSelection.state = shouldWrapSaved ? .on : .off

    25

    50

            updateWrappingMultipleSelection(shouldWrapSaved)

    26

    50

    27

    50

            Observable

    28

    50

                .combineLatest(self.wrapStartTextField.rx.text,

    29

    50

                               self.wrapEndTextField.rx.text) { ($0, $1) }

    30

    50

                .skip(1)

    31

    50

                .subscribe(onNext: { self.prefs.wrappingStrings = $0 })

    32

    50

                .disposed(by: disposeBag)

    33

    50

    34

    50

            self.shouldWrapMultipleSelection.rx.state

    35

    50

                .skip(1)

    36

    50

                .map { $0 == .on }

    37

    50

                .subscribe(onNext: { self.updateWrappingMultipleSelection($0) })

    38

    50

                .disposed(by: disposeBag)

    39

    50

        }

    40

    41

    50

        func updateWrappingMultipleSelection(_ bool: Bool) {

    42

    50

            prefs.useWrappingStrings = bool

    43

    50

            [self.wrapStartTextField,

    44

    50

             self.wrapEndTextField]

    45

    100

                .forEach {

    46

    100

                    $0?.isHidden = !bool

    47

    100

                    $0?.isEnabled = bool

    48

    100

            }

    49

    50

        }

    50

    }