Skip to content

Commit 2236d0d

Browse files
committed
Finish Navigator Filter Bar & Tab Bar Work
1 parent c9501ca commit 2236d0d

File tree

8 files changed

+80
-23
lines changed

8 files changed

+80
-23
lines changed

CodeEdit/Features/CodeEditUI/Views/WorkspacePanel/WorkspacePanelTabBar+IconButton.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,21 @@ extension WorkspacePanelTabBar {
1717

1818
@Binding var selection: Tab?
1919

20+
var symbolVariant: SymbolVariants {
21+
if #unavailable(macOS 26), selection == tab {
22+
.fill
23+
} else {
24+
.none
25+
}
26+
}
27+
2028
var body: some View {
2129
Button {
2230
selection = tab
2331
} label: {
2432
getSafeImage(named: tab.systemImage, accessibilityDescription: tab.title)
2533
.font(.system(size: 13))
26-
.symbolVariant(tab == selection ? .fill : .none)
34+
.symbolVariant(symbolVariant)
2735
.help(tab.title)
2836
.frame(maxWidth: .infinity)
2937
}

CodeEdit/Features/CodeEditUI/Views/WorkspacePanel/WorkspacePanelTabBar.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,12 @@ struct WorkspacePanelTabBar<Tab: WorkspacePanelTab>: View {
146146
}
147147
}
148148
}
149+
}
150+
151+
// MARK: - Drag Gesture
149152

150-
private func makeAreaTabDragGesture(tab: Tab) -> some Gesture {
153+
private extension WorkspacePanelTabBar {
154+
func makeAreaTabDragGesture(tab: Tab) -> some Gesture {
151155
DragGesture(minimumDistance: 2, coordinateSpace: .global)
152156
.onChanged({ value in
153157
if draggingTab != tab {
@@ -203,7 +207,7 @@ struct WorkspacePanelTabBar<Tab: WorkspacePanelTab>: View {
203207
})
204208
}
205209

206-
private func initializeDragGesture(value: DragGesture.Value, for tab: Tab) {
210+
func initializeDragGesture(value: DragGesture.Value, for tab: Tab) {
207211
draggingTab = tab
208212
let initialLocation = position == .top ? value.startLocation.x : value.startLocation.y
209213
draggingStartLocation = initialLocation
@@ -216,7 +220,7 @@ struct WorkspacePanelTabBar<Tab: WorkspacePanelTab>: View {
216220
}
217221

218222
// swiftlint:disable:next function_parameter_count
219-
private func swapTab(
223+
func swapTab(
220224
tab: Tab,
221225
currentIndex: Int,
222226
currentLocation: CGFloat,
@@ -267,7 +271,7 @@ struct WorkspacePanelTabBar<Tab: WorkspacePanelTab>: View {
267271
}
268272
}
269273

270-
private func isWithinPrevTopBounds(
274+
func isWithinPrevTopBounds(
271275
_ curLocation: CGFloat, _ swapLocation: CGRect, _ swapWidth: CGFloat
272276
) -> Bool {
273277
return curLocation < max(
@@ -276,7 +280,7 @@ struct WorkspacePanelTabBar<Tab: WorkspacePanelTab>: View {
276280
)
277281
}
278282

279-
private func isWithinNextTopBounds(
283+
func isWithinNextTopBounds(
280284
_ curLocation: CGFloat, _ swapLocation: CGRect, _ swapWidth: CGFloat, _ curWidth: CGFloat
281285
) -> Bool {
282286
return curLocation > min(
@@ -285,7 +289,7 @@ struct WorkspacePanelTabBar<Tab: WorkspacePanelTab>: View {
285289
)
286290
}
287291

288-
private func isWithinPrevBottomBounds(
292+
func isWithinPrevBottomBounds(
289293
_ curLocation: CGFloat, _ swapLocation: CGRect, _ swapWidth: CGFloat
290294
) -> Bool {
291295
return curLocation < max(
@@ -294,7 +298,7 @@ struct WorkspacePanelTabBar<Tab: WorkspacePanelTab>: View {
294298
)
295299
}
296300

297-
private func isWithinNextBottomBounds(
301+
func isWithinNextBottomBounds(
298302
_ curLocation: CGFloat, _ swapLocation: CGRect, _ swapWidth: CGFloat, _ curWidth: CGFloat
299303
) -> Bool {
300304
return curLocation > min(
@@ -303,7 +307,7 @@ struct WorkspacePanelTabBar<Tab: WorkspacePanelTab>: View {
303307
)
304308
}
305309

306-
private func makeTabItemGeometryReader(tab: Tab) -> some View {
310+
func makeTabItemGeometryReader(tab: Tab) -> some View {
307311
GeometryReader { geometry in
308312
Rectangle()
309313
.foregroundColor(.clear)

CodeEdit/Features/CodeEditUI/Views/WorkspacePanel/WorkspacePanelView.swift

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import SwiftUI
99

10-
struct WorkspacePanelView<Tab: WorkspacePanelTab, ViewModel: ObservableObject>: View {
10+
struct WorkspacePanelView<Tab: WorkspacePanelTab, ViewModel: ObservableObject, BottomAccessory: View>: View {
1111
@ObservedObject var viewModel: ViewModel
1212
@Binding var selectedTab: Tab?
1313
@Binding var tabItems: [Tab]
@@ -19,6 +19,7 @@ struct WorkspacePanelView<Tab: WorkspacePanelTab, ViewModel: ObservableObject>:
1919
var darkDivider: Bool
2020
let padSideItemVertically: Bool
2121
let sideOnTrailing: Bool
22+
let bottomAccessory: BottomAccessory
2223

2324
init(
2425
viewModel: ViewModel,
@@ -27,7 +28,8 @@ struct WorkspacePanelView<Tab: WorkspacePanelTab, ViewModel: ObservableObject>:
2728
sidebarPosition: SettingsData.SidebarTabBarPosition,
2829
darkDivider: Bool = false,
2930
padSideItemVertically: Bool = false,
30-
sideOnTrailing: Bool = false
31+
sideOnTrailing: Bool = false,
32+
@ViewBuilder bottomAccessory: () -> BottomAccessory
3133
) {
3234
self.viewModel = viewModel
3335
self._selectedTab = selectedTab
@@ -40,12 +42,41 @@ struct WorkspacePanelView<Tab: WorkspacePanelTab, ViewModel: ObservableObject>:
4042
} else {
4143
self.sideOnTrailing = false
4244
}
45+
self.bottomAccessory = bottomAccessory()
46+
}
47+
48+
init(
49+
viewModel: ViewModel,
50+
selectedTab: Binding<Tab?>,
51+
tabItems: Binding<[Tab]>,
52+
sidebarPosition: SettingsData.SidebarTabBarPosition,
53+
darkDivider: Bool = false,
54+
padSideItemVertically: Bool = false,
55+
sideOnTrailing: Bool = false,
56+
) where BottomAccessory == EmptyView {
57+
self.viewModel = viewModel
58+
self._selectedTab = selectedTab
59+
self._tabItems = tabItems
60+
self.sidebarPosition = sidebarPosition
61+
self.darkDivider = darkDivider
62+
self.padSideItemVertically = padSideItemVertically
63+
if #available(macOS 26, *) {
64+
self.sideOnTrailing = sideOnTrailing
65+
} else {
66+
self.sideOnTrailing = false
67+
}
68+
self.bottomAccessory = EmptyView()
4369
}
4470

4571
var body: some View {
4672
VStack(spacing: 0) {
4773
if let selection = selectedTab {
4874
selection
75+
.safeAreaInset(edge: .bottom, spacing: 0) {
76+
if #unavailable(macOS 26) {
77+
bottomAccessory
78+
}
79+
}
4980
} else {
5081
CEContentUnavailableView("No Selection")
5182
}
@@ -77,6 +108,11 @@ struct WorkspacePanelView<Tab: WorkspacePanelTab, ViewModel: ObservableObject>:
77108
Divider()
78109
}
79110
}
111+
.safeAreaInset(edge: .bottom, spacing: 0) {
112+
if #available(macOS 26, *) {
113+
bottomAccessory
114+
}
115+
}
80116
}
81117

82118
@ViewBuilder private var sideTabBar: some View {

CodeEdit/Features/NavigatorArea/FindNavigator/FindNavigatorView.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ struct FindNavigatorView: View {
8686
)
8787
}
8888
}
89-
.safeAreaInset(edge: .bottom, spacing: 0) {
90-
FindNavigatorToolbarBottom()
91-
}
9289
.onReceive(state.$searchResult, perform: { value in
9390
self.foundFilesCount = value.count
9491
})

CodeEdit/Features/NavigatorArea/Models/NavigatorTab.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,20 @@ enum NavigatorTab: WorkspacePanelTab {
6060
ExtensionSceneView(with: endpoint, sceneID: data.sceneID)
6161
}
6262
}
63+
64+
@ViewBuilder func bottomView(workspace: WorkspaceDocument) -> some View {
65+
switch self {
66+
case .project:
67+
ProjectNavigatorToolbarBottom()
68+
case .sourceControl:
69+
if let sourceControlManager = workspace.sourceControlManager {
70+
SourceControlNavigatorToolbarBottom()
71+
.environmentObject(sourceControlManager)
72+
}
73+
case .search:
74+
FindNavigatorToolbarBottom()
75+
case .uiExtension:
76+
EmptyView()
77+
}
78+
}
6379
}

CodeEdit/Features/NavigatorArea/ProjectNavigator/ProjectNavigatorView.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,5 @@ import SwiftUI
1717
struct ProjectNavigatorView: View {
1818
var body: some View {
1919
ProjectNavigatorOutlineView()
20-
.safeAreaInset(edge: .bottom, spacing: 0) {
21-
ProjectNavigatorToolbarBottom()
22-
}
2320
}
2421
}

CodeEdit/Features/NavigatorArea/SourceControlNavigator/Views/SourceControlNavigatorView.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct SourceControlNavigatorView: View {
1414
var fetchRefreshServerStatus
1515

1616
var body: some View {
17-
if let sourceControlManager = workspace.workspaceFileManager?.sourceControlManager {
17+
if let sourceControlManager = workspace.sourceControlManager {
1818
VStack(spacing: 0) {
1919
SourceControlNavigatorTabs()
2020
.environmentObject(sourceControlManager)
@@ -31,10 +31,6 @@ struct SourceControlNavigatorView: View {
3131
}
3232
}
3333
}
34-
.safeAreaInset(edge: .bottom, spacing: 0) {
35-
SourceControlNavigatorToolbarBottom()
36-
.environmentObject(sourceControlManager)
37-
}
3834
}
3935
}
4036
}

CodeEdit/Features/NavigatorArea/Views/NavigatorAreaView.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ struct NavigatorAreaView: View {
3838
viewModel: viewModel,
3939
selectedTab: $viewModel.selectedTab,
4040
tabItems: $viewModel.tabItems,
41-
sidebarPosition: sidebarPosition
41+
sidebarPosition: sidebarPosition,
42+
bottomAccessory: {
43+
viewModel.selectedTab?.bottomView(workspace: workspace)
44+
}
4245
)
4346
.environmentObject(workspace)
4447
.accessibilityElement(children: .contain)

0 commit comments

Comments
 (0)