@@ -17,7 +17,10 @@ private struct AdvancedView: View {
17
17
18
18
var body : some View {
19
19
ScrollView {
20
- self . settings
20
+ settings
21
+ if #available( macOS 11 . 0 , * ) {
22
+ excludedApps
23
+ }
21
24
Spacer ( )
22
25
}
23
26
}
@@ -42,6 +45,75 @@ private struct AdvancedView: View {
42
45
}
43
46
)
44
47
}
48
+
49
+ @available ( macOS 11 . 0 , * )
50
+ private var excludedApps : some View {
51
+ SettingsSectionView ( showSeparator: false , content: {
52
+ WithViewStore ( store) { viewStore in
53
+ Text ( _L10n. View. excludeListTitle) . asWidgetTitle ( )
54
+ VStack ( alignment: . leading, spacing: 0 ) {
55
+ ScrollView {
56
+ VStack ( spacing: 4 ) {
57
+ ForEach ( viewStore. excludedApps) { app in
58
+ Button ( action: {
59
+ viewStore. send ( . selectExcludedApp( app) )
60
+ } ) {
61
+ HStack {
62
+ Text ( " \( app. appName) ( \( app. bundleIdentifier) ) " )
63
+ Spacer ( )
64
+ }
65
+ . contentShape ( Rectangle ( ) )
66
+ }
67
+ . padding ( EdgeInsets ( top: 2 , leading: 6 , bottom: 2 , trailing: 6 ) )
68
+ . roundedCornerBackground (
69
+ cornerRadius: 4 ,
70
+ fillColor: viewStore. state. selectedExcludedApp == app
71
+ ? Color ( NSColor . selectedControlColor)
72
+ : . clear,
73
+ strokeColor: . clear,
74
+ strokeWidth: 0 ,
75
+ shadow: nil
76
+ )
77
+ . padding ( EdgeInsets ( top: 0 , leading: 6 , bottom: 0 , trailing: 6 ) )
78
+ . frame ( maxWidth: . infinity)
79
+ . buttonStyle ( PlainButtonStyle ( ) )
80
+ }
81
+ }
82
+ }
83
+ . padding ( EdgeInsets ( top: 6 , leading: 0 , bottom: 6 , trailing: 0 ) )
84
+ . background ( Color . clear)
85
+ . frame ( maxWidth: 320 , minHeight: 120 , maxHeight: 120 )
86
+
87
+ HStack {
88
+ Menu ( " + " ) {
89
+ ForEach ( viewStore. availableApplications) { app in
90
+ Button ( action: {
91
+ viewStore. send ( . addExcludedApp( app) )
92
+ } ) {
93
+ Text ( " \( app. appName) ( \( app. bundleIdentifier) ) " )
94
+ }
95
+ }
96
+ }
97
+ . frame ( width: 40 )
98
+
99
+ Button ( action: {
100
+ viewStore. send ( . removeSelectedExcludedApp)
101
+ } ) {
102
+ Image ( nsImage: NSImage ( named: NSImage . touchBarDeleteTemplateName) !)
103
+ } . buttonStyle ( . plain)
104
+ }
105
+ . padding ( EdgeInsets ( top: 0 , leading: 6 , bottom: 6 , trailing: 6 ) )
106
+ }
107
+ . roundedCornerBackground (
108
+ cornerRadius: 2 ,
109
+ fillColor: Color ( NSColor . controlBackgroundColor) ,
110
+ strokeColor: Color ( NSColor . separatorColor) ,
111
+ strokeWidth: 1 ,
112
+ shadow: nil
113
+ )
114
+ }
115
+ } )
116
+ }
45
117
}
46
118
47
119
private enum _L10n {
@@ -51,7 +123,17 @@ private enum _L10n {
51
123
struct AdvancedView_Previews : PreviewProvider {
52
124
static var previews : some View {
53
125
AdvancedView ( store: . init(
54
- initialState: . init( ) ,
126
+ initialState: . init(
127
+ listenToKeyboardEvent: true ,
128
+ excludedApps: [
129
+ . init( appName: " A " , bundleIdentifier: " A " ) ,
130
+ . init( appName: " B " , bundleIdentifier: " B " ) ,
131
+ ] ,
132
+ availableApplications: [
133
+ . init( appName: " A " , bundleIdentifier: " A " ) ,
134
+ . init( appName: " B " , bundleIdentifier: " B " ) ,
135
+ ]
136
+ ) ,
55
137
reducer: AdvancedDomain . reducer,
56
138
environment: . live( environment: . init( persisted: . init( ) ) )
57
139
) )
0 commit comments