CutBox.app

Coverage Report

Created: 2024-03-12 03:40

.../Source/App/Preferences/ColorTheme/CutBoxColorTheme.swift
Line
Count
Source
1
//
2
//  CutBoxColorTheme.swift
3
//  CutBox
4
//
5
//  Created by Jason Milkins on 12/4/18.
6
//  Copyright © 2018-2023 ocodo. All rights reserved.
7
//
8
9
import Cocoa
10
11
struct SearchTextTheme: Equatable {
12
    var cursorColor: NSColor
13
    var textColor: NSColor
14
    var backgroundColor: NSColor
15
    var placeholderTextColor: NSColor
16
}
17
18
struct ClipTheme: Equatable {
19
    var backgroundColor: NSColor
20
    var textColor: NSColor
21
    var highlightColor: NSColor
22
    var highlightTextColor: NSColor
23
}
24
25
struct PreviewTheme: Equatable {
26
    var textColor: NSColor
27
    var backgroundColor: NSColor
28
    var selectedTextBackgroundColor: NSColor
29
    var selectedTextColor: NSColor
30
}
31
32
class CutBoxColorTheme: Equatable, CustomStringConvertible {
33
3
    static func == (lhs: CutBoxColorTheme, rhs: CutBoxColorTheme) -> Bool {
34
3
        lhs.description == rhs.description
35
3
    }
36
37
    let name: String
38
    var spacing: CGFloat
39
    let popupBackgroundColor: NSColor
40
    let searchText: SearchTextTheme
41
    let clip: ClipTheme
42
    let preview: PreviewTheme
43
44
    init(name: String,
45
         popupBackgroundColor: NSColor,
46
         searchText: SearchTextTheme,
47
         clip: ClipTheme,
48
         preview: PreviewTheme,
49
1.85k
         spacing: CGFloat = 5) {
50
1.85k
51
1.85k
        self.name = name
52
1.85k
        self.spacing = spacing
53
1.85k
        self.popupBackgroundColor = popupBackgroundColor
54
1.85k
        self.searchText = searchText
55
1.85k
        self.clip = clip
56
1.85k
        self.preview = preview
57
1.85k
    }
58
59
12
    var description: String {
60
12
        """
61
12
        {
62
12
            "name": "\(name)",
63
12
            "popupBackgroundColor": "\(popupBackgroundColor)",
64
12
            "searchText": {
65
12
            "cursorColor": "\(searchText.cursorColor)",
66
12
                    "textColor": "\(searchText.textColor)",
67
12
                    "backgroundColor": "\(searchText.backgroundColor)",
68
12
                    "placeholderTextColor": "\(searchText.placeholderTextColor)"
69
12
                },
70
12
                "clip": {
71
12
                    "backgroundColor": "\(clip.backgroundColor)",
72
12
                    "textColor": "\(clip.textColor)",
73
12
                    "highlightColor": "\(clip.highlightColor)",
74
12
                    "highlightTextColor": "\(clip.highlightTextColor)"
75
12
                },
76
12
                "preview": {
77
12
                    "textColor": "\(preview.textColor)",
78
12
                    "backgroundColor": "\(preview.backgroundColor)",
79
12
                    "selectedTextBackgroundColor": "\(preview.selectedTextBackgroundColor)",
80
12
                    "selectedTextColor": "\(preview.selectedTextColor)"
81
12
                },
82
12
            "spacing": \(spacing),
83
12
        }
84
12
        """
85
12
    }
86
}