@@ -23,9 +23,6 @@ struct EditorTabView: View {
23
23
24
24
@EnvironmentObject private var editorManager : EditorManager
25
25
26
- @AppSettings ( \. general. tabBarStyle)
27
- var tabBarStyle
28
-
29
26
@AppSettings ( \. general. fileIconStyle)
30
27
var fileIconStyle
31
28
@@ -46,9 +43,6 @@ struct EditorTabView: View {
46
43
/// By default, this value is `false`. When the root view is appeared, it turns `true`.
47
44
@State private var isAppeared : Bool = false
48
45
49
- /// The expected tab width in native tab bar style.
50
- private var expectedWidth : CGFloat
51
-
52
46
/// The id associating with the tab that is currently being dragged.
53
47
///
54
48
/// When `nil`, then there is no tab being dragged.
@@ -108,14 +102,12 @@ struct EditorTabView: View {
108
102
}
109
103
110
104
init (
111
- expectedWidth: CGFloat ,
112
105
item: CEWorkspaceFile ,
113
106
index: Int ,
114
107
draggingTabId: CEWorkspaceFile . ID ? ,
115
108
onDragTabId: CEWorkspaceFile . ID ? ,
116
109
closeButtonGestureActive: Binding < Bool >
117
110
) {
118
- self . expectedWidth = expectedWidth
119
111
self . item = item
120
112
self . index = index
121
113
self . draggingTabId = draggingTabId
@@ -127,10 +119,8 @@ struct EditorTabView: View {
127
119
HStack ( spacing: 0.0 ) {
128
120
EditorTabDivider ( )
129
121
. opacity (
130
- ( isActive || inHoldingState)
131
- && tabBarStyle == . xcode ? 0.0 : 1.0
122
+ ( isActive || inHoldingState) ? 0.0 : 1.0
132
123
)
133
- . padding ( . top, isActive && tabBarStyle == . native ? 1.22 : 0 )
134
124
// Tab content (icon and text).
135
125
HStack ( alignment: . center, spacing: 3 ) {
136
126
Image ( nsImage: item. nsIcon)
@@ -150,12 +140,10 @@ struct EditorTabView: View {
150
140
. lineLimit ( 1 )
151
141
}
152
142
. frame (
153
- // To horizontally max-out the given width area ONLY in native tab bar style.
154
- maxWidth: tabBarStyle == . native ? . infinity : nil ,
155
143
// To max-out the parent (tab bar) area.
156
144
maxHeight: . infinity
157
145
)
158
- . padding ( . horizontal, tabBarStyle == . native ? 28 : 20 )
146
+ . padding ( . horizontal, 20 )
159
147
. overlay {
160
148
ZStack {
161
149
// Close Button with is file changed indicator
@@ -174,36 +162,21 @@ struct EditorTabView: View {
174
162
// Inactive states for tab bar item content.
175
163
activeState != . inactive
176
164
? 1.0
177
- : (
178
- isActive
179
- ? ( tabBarStyle == . xcode ? 0.6 : 0.35 )
180
- : ( tabBarStyle == . xcode ? 0.4 : 0.55 )
181
- )
165
+ : isActive ? 0.6 : 0.4
182
166
)
183
167
EditorTabDivider ( )
184
168
. opacity (
185
- ( isActive || inHoldingState)
186
- && tabBarStyle == . xcode ? 0.0 : 1.0
169
+ ( isActive || inHoldingState) ? 0.0 : 1.0
187
170
)
188
- . padding ( . top, isActive && tabBarStyle == . native ? 1.22 : 0 )
189
- }
190
- . overlay ( alignment: . top) {
191
- // Only show NativeTabShadow when `tabBarStyle` is native and this tab is not active.
192
- EditorTabBarTopDivider ( )
193
- . opacity ( tabBarStyle == . native && !isActive ? 1 : 0 )
194
171
}
195
172
. foregroundColor (
196
173
isActive && isActiveEditor
197
174
? (
198
- tabBarStyle == . xcode && colorScheme != . dark
175
+ colorScheme != . dark
199
176
? Color ( nsColor: . controlAccentColor)
200
177
: . primary
201
178
)
202
- : (
203
- tabBarStyle == . xcode
204
- ? . primary
205
- : . secondary
206
- )
179
+ : . primary
207
180
)
208
181
. frame ( maxHeight: . infinity) // To vertically max-out the parent (tab bar) area.
209
182
. contentShape ( Rectangle ( ) ) // Make entire area clickable.
@@ -225,26 +198,8 @@ struct EditorTabView: View {
225
198
content
226
199
}
227
200
. background {
228
- if tabBarStyle == . xcode {
229
- EditorTabBackground ( isActive: isActive, isPressing: isPressing, isDragging: isDragging)
230
- . animation ( . easeInOut( duration: 0.08 ) , value: isHovering)
231
- } else {
232
- if isFullscreen && isActive {
233
- EditorTabBarNativeActiveMaterial ( )
234
- } else {
235
- EditorTabBarNativeMaterial ( )
236
- }
237
- ZStack {
238
- // Native inactive tab background dim.
239
- EditorTabBarNativeInactiveBgColor ( )
240
- // Native inactive tab hover state.
241
- Color ( nsColor: colorScheme == . dark ? . white : . black)
242
- . opacity ( isHovering ? ( colorScheme == . dark ? 0.08 : 0.05 ) : 0.0 )
243
- . animation ( . easeInOut( duration: 0.10 ) , value: isHovering)
244
- }
245
- . padding ( . horizontal, 1 )
246
- . opacity ( isActive ? 0 : 1 )
247
- }
201
+ EditorTabBackground ( isActive: isActive, isPressing: isPressing, isDragging: isDragging)
202
+ . animation ( . easeInOut( duration: 0.08 ) , value: isHovering)
248
203
}
249
204
// TODO: Enable the following code snippet when dragging-out behavior should be allowed.
250
205
// Since we didn't handle the drop-outside event, dragging-out is disabled for now.
@@ -262,32 +217,20 @@ struct EditorTabView: View {
262
217
}
263
218
}
264
219
)
265
- . padding (
266
- // This padding is to avoid background color overlapping with top divider.
267
- . top, tabBarStyle == . xcode ? 1 : 0
268
- )
220
+ // This padding is to avoid background color overlapping with top divider.
221
+ . padding ( . top, 1 )
269
222
// .offset(
270
- // x: isAppeared || tabBarStyle == .native ? 0 : -14,
223
+ // x: isAppeared ? 0 : -14,
271
224
// y: 0
272
225
// )
273
226
// .opacity(isAppeared && onDragTabId != item.id ? 1.0 : 0.0)
274
227
. zIndex (
275
228
isActive
276
- ? ( tabBarStyle == . native ? - 1 : 2 )
229
+ ? 2
277
230
: ( isDragging ? 3 : ( isPressing ? 1 : 0 ) )
278
231
)
279
- . frame (
280
- width: (
281
- // Constrain the width of tab bar item for native tab style only.
282
- tabBarStyle == . native
283
- ? max ( expectedWidth. isFinite ? expectedWidth : 0 , 0 )
284
- : nil
285
- )
286
- )
287
232
. onAppear {
288
- withAnimation (
289
- . easeOut( duration: tabBarStyle == . native ? 0.15 : 0.20 )
290
- ) {
233
+ withAnimation ( . easeOut( duration: 0.20 ) ) {
291
234
// isAppeared = true
292
235
}
293
236
}
0 commit comments