Skip to content

Commit 7513e1b

Browse files
Removed Tab Bar Style Setting and Native Editor Tab Design (CodeEditApp#1761)
1 parent 4a6b234 commit 7513e1b

16 files changed

+42
-420
lines changed

CodeEdit.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,6 @@
520520
D7E201AE27E8B3C000CB86D0 /* String+Ranges.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7E201AD27E8B3C000CB86D0 /* String+Ranges.swift */; };
521521
D7E201B227E8D50000CB86D0 /* FindNavigatorForm.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7E201B127E8D50000CB86D0 /* FindNavigatorForm.swift */; };
522522
DE513F52281B672D002260B9 /* EditorTabBarAccessory.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE513F51281B672D002260B9 /* EditorTabBarAccessory.swift */; };
523-
DE6405A62817734700881FDF /* EditorTabBarNative.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE6405A52817734700881FDF /* EditorTabBarNative.swift */; };
524523
DE6F77872813625500D00A76 /* EditorTabBarDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE6F77862813625500D00A76 /* EditorTabBarDivider.swift */; };
525524
EC0870F72A455F6400EB8692 /* ProjectNavigatorViewController+NSMenuDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC0870F62A455F6400EB8692 /* ProjectNavigatorViewController+NSMenuDelegate.swift */; };
526525
/* End PBXBuildFile section */
@@ -1093,7 +1092,6 @@
10931092
D7E201B127E8D50000CB86D0 /* FindNavigatorForm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FindNavigatorForm.swift; sourceTree = "<group>"; };
10941093
D7E201B327E9989900CB86D0 /* FindNavigatorResultList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FindNavigatorResultList.swift; sourceTree = "<group>"; };
10951094
DE513F51281B672D002260B9 /* EditorTabBarAccessory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditorTabBarAccessory.swift; sourceTree = "<group>"; };
1096-
DE6405A52817734700881FDF /* EditorTabBarNative.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditorTabBarNative.swift; sourceTree = "<group>"; };
10971095
DE6F77862813625500D00A76 /* EditorTabBarDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditorTabBarDivider.swift; sourceTree = "<group>"; };
10981096
EC0870F62A455F6400EB8692 /* ProjectNavigatorViewController+NSMenuDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProjectNavigatorViewController+NSMenuDelegate.swift"; sourceTree = "<group>"; };
10991097
/* End PBXFileReference section */
@@ -2183,7 +2181,6 @@
21832181
DE513F51281B672D002260B9 /* EditorTabBarAccessory.swift */,
21842182
6CDA84AC284C1BA000C1CC3A /* EditorTabBarContextMenu.swift */,
21852183
DE6F77862813625500D00A76 /* EditorTabBarDivider.swift */,
2186-
DE6405A52817734700881FDF /* EditorTabBarNative.swift */,
21872184
287776E827E34BC700D46668 /* EditorTabBarView.swift */,
21882185
B6AB09A22AAABFEC0003A3A6 /* EditorTabBarLeadingAccessories.swift */,
21892186
B6AB09A42AAAC00F0003A3A6 /* EditorTabBarTrailingAccessories.swift */,
@@ -3569,7 +3566,6 @@
35693566
201169E22837B3D800F92B46 /* SourceControlNavigatorChangesView.swift in Sources */,
35703567
850C631029D6B01D00E1444C /* SettingsView.swift in Sources */,
35713568
77A01E6D2BC3EA2A00F0EA38 /* NSWindow+Child.swift in Sources */,
3572-
DE6405A62817734700881FDF /* EditorTabBarNative.swift in Sources */,
35733569
581550CF29FBD30400684881 /* StandardTableViewCell.swift in Sources */,
35743570
B62AEDB82A1FE2DC009A9F52 /* UtilityAreaOutputView.swift in Sources */,
35753571
B67DB0FC2AFDF71F002DC647 /* IconToggleStyle.swift in Sources */,

CodeEdit/Features/Documents/Controllers/CodeEditWindowController+Toolbar.swift

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,7 @@ extension CodeEditWindowController {
1616
toolbar.showsBaselineSeparator = false
1717
self.window?.titleVisibility = toolbarCollapsed ? .visible : .hidden
1818
self.window?.toolbarStyle = .unifiedCompact
19-
if Settings[\.general].tabBarStyle == .native {
20-
// Set titlebar background as transparent by default in order to
21-
// style the toolbar background in native tab bar style.
22-
self.window?.titlebarSeparatorStyle = .none
23-
} else {
24-
// In Xcode tab bar style, we use default toolbar background with
25-
// line separator.
26-
self.window?.titlebarSeparatorStyle = .automatic
27-
}
19+
self.window?.titlebarSeparatorStyle = .automatic
2820
self.window?.toolbar = toolbar
2921
}
3022

CodeEdit/Features/Editor/TabBar/Tabs/Tab/EditorTabCloseButton.swift

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,50 +18,39 @@ struct EditorTabCloseButton: View {
1818
@Environment(\.colorScheme)
1919
var colorScheme
2020

21-
@AppSettings(\.general.tabBarStyle)
22-
var tabBarStyle
23-
2421
@State private var isPressingClose: Bool = false
2522
@State private var isHoveringClose: Bool = false
2623

2724
let buttonSize: CGFloat = 16
2825

2926
var body: some View {
3027
HStack(alignment: .center) {
31-
if tabBarStyle == .xcode {
32-
Image(systemName: isDocumentEdited && !isHoveringTab ? "circlebadge.fill" : "xmark")
33-
.font(
34-
.system(
35-
size: isDocumentEdited && !isHoveringTab ? 9.5 : 11.5,
36-
weight: .regular,
37-
design: .rounded
38-
)
39-
)
40-
.foregroundColor(
41-
isActive
42-
? colorScheme == .dark ? .primary : Color(.controlAccentColor)
43-
: .secondary
28+
Image(systemName: isDocumentEdited && !isHoveringTab ? "circlebadge.fill" : "xmark")
29+
.font(
30+
.system(
31+
size: isDocumentEdited && !isHoveringTab ? 9.5 : 11.5,
32+
weight: .regular,
33+
design: .rounded
4434
)
45-
} else {
46-
Image(systemName: isDocumentEdited && !isHoveringTab ? "circlebadge.fill" : "xmark")
47-
.font(.system(size: 9.5, weight: .medium, design: .rounded))
48-
}
35+
)
36+
.foregroundColor(
37+
isActive
38+
? colorScheme == .dark ? .primary : Color(.controlAccentColor)
39+
: .secondary
40+
)
4941
}
5042
.frame(width: buttonSize, height: buttonSize)
5143
.background(
5244
colorScheme == .dark
5345
? Color(nsColor: .white)
5446
.opacity(isPressingClose ? 0.10 : isHoveringClose ? 0.05 : 0)
5547
: (
56-
tabBarStyle == .xcode
57-
? Color(nsColor: isActive ? .controlAccentColor : .black)
48+
Color(nsColor: isActive ? .controlAccentColor : .black)
5849
.opacity(
5950
isPressingClose
6051
? 0.25
6152
: (isHoveringClose ? (isActive ? 0.10 : 0.06) : 0)
6253
)
63-
: Color(nsColor: .black)
64-
.opacity(isPressingClose ? 0.29 : (isHoveringClose ? 0.11 : 0))
6554
)
6655
)
6756
.foregroundColor(isPressingClose ? .primary : .secondary)

CodeEdit/Features/Editor/TabBar/Tabs/Tab/EditorTabView.swift

Lines changed: 13 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ struct EditorTabView: View {
2323

2424
@EnvironmentObject private var editorManager: EditorManager
2525

26-
@AppSettings(\.general.tabBarStyle)
27-
var tabBarStyle
28-
2926
@AppSettings(\.general.fileIconStyle)
3027
var fileIconStyle
3128

@@ -46,9 +43,6 @@ struct EditorTabView: View {
4643
/// By default, this value is `false`. When the root view is appeared, it turns `true`.
4744
@State private var isAppeared: Bool = false
4845

49-
/// The expected tab width in native tab bar style.
50-
private var expectedWidth: CGFloat
51-
5246
/// The id associating with the tab that is currently being dragged.
5347
///
5448
/// When `nil`, then there is no tab being dragged.
@@ -108,14 +102,12 @@ struct EditorTabView: View {
108102
}
109103

110104
init(
111-
expectedWidth: CGFloat,
112105
item: CEWorkspaceFile,
113106
index: Int,
114107
draggingTabId: CEWorkspaceFile.ID?,
115108
onDragTabId: CEWorkspaceFile.ID?,
116109
closeButtonGestureActive: Binding<Bool>
117110
) {
118-
self.expectedWidth = expectedWidth
119111
self.item = item
120112
self.index = index
121113
self.draggingTabId = draggingTabId
@@ -127,10 +119,8 @@ struct EditorTabView: View {
127119
HStack(spacing: 0.0) {
128120
EditorTabDivider()
129121
.opacity(
130-
(isActive || inHoldingState)
131-
&& tabBarStyle == .xcode ? 0.0 : 1.0
122+
(isActive || inHoldingState) ? 0.0 : 1.0
132123
)
133-
.padding(.top, isActive && tabBarStyle == .native ? 1.22 : 0)
134124
// Tab content (icon and text).
135125
HStack(alignment: .center, spacing: 3) {
136126
Image(nsImage: item.nsIcon)
@@ -150,12 +140,10 @@ struct EditorTabView: View {
150140
.lineLimit(1)
151141
}
152142
.frame(
153-
// To horizontally max-out the given width area ONLY in native tab bar style.
154-
maxWidth: tabBarStyle == .native ? .infinity : nil,
155143
// To max-out the parent (tab bar) area.
156144
maxHeight: .infinity
157145
)
158-
.padding(.horizontal, tabBarStyle == .native ? 28 : 20)
146+
.padding(.horizontal, 20)
159147
.overlay {
160148
ZStack {
161149
// Close Button with is file changed indicator
@@ -174,36 +162,21 @@ struct EditorTabView: View {
174162
// Inactive states for tab bar item content.
175163
activeState != .inactive
176164
? 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
182166
)
183167
EditorTabDivider()
184168
.opacity(
185-
(isActive || inHoldingState)
186-
&& tabBarStyle == .xcode ? 0.0 : 1.0
169+
(isActive || inHoldingState) ? 0.0 : 1.0
187170
)
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)
194171
}
195172
.foregroundColor(
196173
isActive && isActiveEditor
197174
? (
198-
tabBarStyle == .xcode && colorScheme != .dark
175+
colorScheme != .dark
199176
? Color(nsColor: .controlAccentColor)
200177
: .primary
201178
)
202-
: (
203-
tabBarStyle == .xcode
204-
? .primary
205-
: .secondary
206-
)
179+
: .primary
207180
)
208181
.frame(maxHeight: .infinity) // To vertically max-out the parent (tab bar) area.
209182
.contentShape(Rectangle()) // Make entire area clickable.
@@ -225,26 +198,8 @@ struct EditorTabView: View {
225198
content
226199
}
227200
.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)
248203
}
249204
// TODO: Enable the following code snippet when dragging-out behavior should be allowed.
250205
// Since we didn't handle the drop-outside event, dragging-out is disabled for now.
@@ -262,32 +217,20 @@ struct EditorTabView: View {
262217
}
263218
}
264219
)
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)
269222
// .offset(
270-
// x: isAppeared || tabBarStyle == .native ? 0 : -14,
223+
// x: isAppeared ? 0 : -14,
271224
// y: 0
272225
// )
273226
// .opacity(isAppeared && onDragTabId != item.id ? 1.0 : 0.0)
274227
.zIndex(
275228
isActive
276-
? (tabBarStyle == .native ? -1 : 2)
229+
? 2
277230
: (isDragging ? 3 : (isPressing ? 1 : 0))
278231
)
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-
)
287232
.onAppear {
288-
withAnimation(
289-
.easeOut(duration: tabBarStyle == .native ? 0.15 : 0.20)
290-
) {
233+
withAnimation(.easeOut(duration: 0.20)) {
291234
// isAppeared = true
292235
}
293236
}

0 commit comments

Comments
 (0)