@@ -12,20 +12,22 @@ public struct StatusBarView: View {
12
12
13
13
@ObservedObject private var model : StatusBarModel
14
14
15
+ private var toolbarFont : Font = . system( size: 11 )
16
+
15
17
public init ( ) {
16
18
self . model = . init( )
17
19
}
18
20
19
- public var body : some View {
21
+ public var body : some View {
20
22
VStack ( spacing: 0 ) {
21
23
bar
22
- if model. isExpanded {
24
+ // if model.isExpanded {
23
25
terminal
24
- }
26
+ // }
25
27
}
26
- // removes weird light gray bar above when in light mode
28
+ // removes weird light gray bar above when in light mode
27
29
. padding ( . top, - 8 ) // (comment out to make it look normal in preview)
28
- }
30
+ }
29
31
30
32
private var dragGesture : some Gesture {
31
33
DragGesture ( )
@@ -42,8 +44,8 @@ public struct StatusBarView: View {
42
44
ZStack {
43
45
Rectangle ( )
44
46
. foregroundStyle ( . bar)
45
- HStack ( spacing: 14 ) {
46
- HStack ( spacing: 8 ) {
47
+ HStack ( spacing: 15 ) {
48
+ HStack ( spacing: 5 ) {
47
49
labelButton ( model. errorCount. formatted ( ) , image: " xmark.octagon " )
48
50
labelButton ( model. warningCount. formatted ( ) , image: " exclamationmark.triangle " )
49
51
}
@@ -77,17 +79,18 @@ public struct StatusBarView: View {
77
79
private var terminal : some View {
78
80
Rectangle ( )
79
81
. foregroundColor ( Color ( red: 0.163 , green: 0.163 , blue: 0.188 , opacity: 1.000 ) )
80
- . frame ( minHeight: 0 , idealHeight: height, maxHeight: height)
82
+ . frame ( minHeight: 0 , idealHeight: model . isExpanded ? height : 0 , maxHeight: model . isExpanded ? height : 0 )
81
83
}
82
84
83
85
private func labelButton( _ text: String , image: String ) -> some View {
84
86
Button {
85
87
// show errors/warnings
86
88
} label: {
87
- HStack ( spacing: 4 ) {
89
+ HStack ( spacing: 2 ) {
88
90
Image ( systemName: image)
89
- . font ( . headline )
91
+ . font ( . callout . bold ( ) )
90
92
Text ( text)
93
+ . font ( toolbarFont)
91
94
}
92
95
}
93
96
. buttonStyle ( . borderless)
@@ -102,13 +105,16 @@ public struct StatusBarView: View {
102
105
}
103
106
104
107
private var branchPicker : some View {
105
- Menu ( model . branches [ model . selectedBranch ] ) {
108
+ Menu {
106
109
ForEach ( model. branches. indices, id: \. self) { branch in
107
110
Button { model. selectedBranch = branch } label: {
108
111
Text ( model. branches [ branch] )
109
112
// checkout branch
110
113
}
111
114
}
115
+ } label: {
116
+ Text ( model. branches [ model. selectedBranch] )
117
+ . font ( toolbarFont)
112
118
}
113
119
. menuStyle ( . borderlessButton)
114
120
. fixedSize ( )
@@ -132,14 +138,14 @@ public struct StatusBarView: View {
132
138
}
133
139
} label: {
134
140
Image ( systemName: " arrow.triangle.2.circlepath " )
135
- . imageScale ( . large )
141
+ . imageScale ( . medium )
136
142
. rotationEffect ( . degrees( model. isReloading ? 360 : 0 ) )
137
143
. animation ( animation, value: model. isReloading)
138
144
. opacity ( model. isReloading ? 1 : 0 )
139
145
// A bit of a hacky solution to prevent spinning counterclockwise once `reloading` changes to `false`
140
146
. overlay {
141
147
Image ( systemName: " arrow.triangle.2.circlepath " )
142
- . imageScale ( . large )
148
+ . imageScale ( . medium )
143
149
. opacity ( model. isReloading ? 0 : 1 )
144
150
}
145
151
@@ -163,6 +169,7 @@ public struct StatusBarView: View {
163
169
164
170
private var cursorLocationLabel : some View {
165
171
Text ( " Ln \( model. currentLine) , Col \( model. currentCol) " )
172
+ . font ( toolbarFont)
166
173
. foregroundStyle ( . primary)
167
174
. onHover { hovering in
168
175
if hovering {
@@ -174,8 +181,11 @@ public struct StatusBarView: View {
174
181
}
175
182
176
183
private var indentSelector : some View {
177
- Menu ( " 2 Spaces " ) {
184
+ Menu {
178
185
// 2 spaces, 4 spaces, ...
186
+ } label: {
187
+ Text ( " 2 Spaces " )
188
+ . font ( toolbarFont)
179
189
}
180
190
. menuStyle ( . borderlessButton)
181
191
. fixedSize ( )
@@ -189,45 +199,53 @@ public struct StatusBarView: View {
189
199
}
190
200
191
201
private var encodingSelector : some View {
192
- Menu ( " UTF 8 " ) {
202
+ Menu {
193
203
// UTF 8, ASCII, ...
204
+ } label: {
205
+ Text ( " UTF 8 " )
206
+ . font ( toolbarFont)
194
207
}
195
- . menuStyle ( . borderlessButton)
196
- . fixedSize ( )
197
- . onHover { hovering in
198
- if hovering {
199
- NSCursor . pointingHand. push ( )
200
- } else {
201
- NSCursor . pop ( )
202
- }
208
+ . menuStyle ( . borderlessButton)
209
+ . fixedSize ( )
210
+ . onHover { hovering in
211
+ if hovering {
212
+ NSCursor . pointingHand. push ( )
213
+ } else {
214
+ NSCursor . pop ( )
203
215
}
216
+ }
204
217
}
205
218
206
219
private var lineEndSelector : some View {
207
- Menu ( " LF " ) {
220
+ Menu {
208
221
// LF, CRLF
222
+ } label: {
223
+ Text ( " LF " )
224
+ . font ( toolbarFont)
209
225
}
210
- . menuStyle ( . borderlessButton)
211
- . fixedSize ( )
212
- . onHover { hovering in
213
- if hovering {
214
- NSCursor . pointingHand. push ( )
215
- } else {
216
- NSCursor . pop ( )
217
- }
226
+ . menuStyle ( . borderlessButton)
227
+ . fixedSize ( )
228
+ . onHover { hovering in
229
+ if hovering {
230
+ NSCursor . pointingHand. push ( )
231
+ } else {
232
+ NSCursor . pop ( )
218
233
}
234
+ }
219
235
}
220
236
221
237
private var expandButton : some View {
222
238
Button {
223
- model. isExpanded. toggle ( )
224
- if model. isExpanded && height < 1 {
225
- height = 300
239
+ withAnimation {
240
+ model. isExpanded. toggle ( )
241
+ if model. isExpanded && height < 1 {
242
+ height = 300
243
+ }
226
244
}
227
245
// Show/hide terminal window
228
246
} label: {
229
247
Image ( systemName: " rectangle.bottomthird.inset.filled " )
230
- . imageScale ( . large )
248
+ . imageScale ( . medium )
231
249
}
232
250
. tint ( model. isExpanded ? . accentColor : . primary)
233
251
. buttonStyle ( . borderless)
@@ -243,12 +261,12 @@ public struct StatusBarView: View {
243
261
244
262
@available ( macOS 12 , * )
245
263
struct SwiftUIView_Previews : PreviewProvider {
246
- static var previews : some View {
264
+ static var previews : some View {
247
265
ZStack ( alignment: . bottom) {
248
266
Color . white
249
267
StatusBarView ( )
250
268
. previewLayout ( . fixed( width: 1.336 , height: 500.0 ) )
251
269
. preferredColorScheme ( . light)
252
270
}
253
- }
271
+ }
254
272
}
0 commit comments