Skip to content

Commit c9501ca

Browse files
committed
Finish Utility Area
1 parent a822c40 commit c9501ca

File tree

4 files changed

+91
-30
lines changed

4 files changed

+91
-30
lines changed

CodeEdit/Features/StatusBar/Views/StatusBarView.swift

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,21 @@ struct StatusBarView: View {
2222
@Environment(\.controlActiveState)
2323
private var controlActive
2424

25-
static let height = 28.0
25+
static var height: CGFloat {
26+
if #available(macOS 26, *) {
27+
37.0
28+
} else {
29+
29.0
30+
}
31+
}
32+
33+
private var trailingPadding: CGFloat {
34+
if #available(macOS 26, *) {
35+
8
36+
} else {
37+
0
38+
}
39+
}
2640

2741
@Environment(\.colorScheme)
2842
private var colorScheme
@@ -43,8 +57,9 @@ struct StatusBarView: View {
4357
StatusBarToggleUtilityAreaButton()
4458
}
4559
.padding(.horizontal, 10)
60+
.padding(.trailing, trailingPadding)
4661
.cursor(.resizeUpDown)
47-
.frame(height: Self.height)
62+
.frame(height: Self.height - 1.0)
4863
.background(.bar)
4964
.padding(.top, 1)
5065
.overlay(alignment: .top) {

CodeEdit/Features/UtilityArea/Views/PaneToolbar.swift

Lines changed: 62 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,79 @@ struct PaneToolbar<Content: View>: View {
1313
@Environment(\.paneArea)
1414
var paneArea: PaneArea?
1515

16+
private var height: CGFloat? {
17+
if #available(macOS 26, *) {
18+
36.0
19+
} else {
20+
nil
21+
}
22+
}
23+
24+
private var maxHeight: CGFloat? {
25+
if #available(macOS 26, *) {
26+
nil
27+
} else {
28+
27.0
29+
}
30+
}
31+
32+
private var padding: CGSize {
33+
if #available(macOS 26, *) {
34+
CGSize(width: 5.0, height: 0)
35+
} else {
36+
CGSize(width: 5.0, height: 8.0)
37+
}
38+
}
39+
1640
var body: some View {
17-
HStack(spacing: 5) {
18-
if model.hasLeadingSidebar
19-
&& (
20-
((paneArea == .main || paneArea == .mainLeading)
21-
&& model.leadingSidebarIsCollapsed)
22-
|| paneArea == .leading
23-
) {
41+
HStack(alignment: .center, spacing: 5) {
42+
if shouldShowLeadingSection() {
2443
PaneToolbarSection {
2544
Spacer()
2645
.frame(width: 24)
2746
}
2847
.opacity(0)
2948
}
3049
content
31-
if model.hasTrailingSidebar
32-
&& (
33-
((paneArea == .main || paneArea == .mainTrailing)
34-
&& model.trailingSidebarIsCollapsed)
35-
|| paneArea == .trailing
36-
) || !model.hasTrailingSidebar {
37-
if model.hasTrailingSidebar {
38-
PaneToolbarSection {
39-
Spacer()
40-
.frame(width: 24)
41-
}
42-
.opacity(0)
50+
if shouldShowTrailingSection() {
51+
PaneToolbarSection {
52+
Spacer()
53+
.frame(width: 24)
4354
}
55+
.opacity(0)
56+
}
57+
if #available(macOS 26, *), isTrailingItem() {
58+
Spacer().frame(width: 5)
4459
}
4560
}
4661
.buttonStyle(.icon(size: 24))
47-
.padding(.horizontal, 5)
48-
.padding(.vertical, 8)
49-
.frame(maxHeight: 27)
62+
.padding(.horizontal, padding.width)
63+
.padding(.vertical, padding.height)
64+
.frame(maxHeight: maxHeight)
65+
.frame(height: height)
66+
}
67+
68+
private func shouldShowLeadingSection() -> Bool {
69+
model.hasLeadingSidebar
70+
&& (
71+
((paneArea == .main || paneArea == .mainLeading) && model.leadingSidebarIsCollapsed)
72+
|| paneArea == .leading
73+
)
74+
}
75+
76+
private func shouldShowTrailingSection() -> Bool {
77+
model.hasTrailingSidebar
78+
&& (
79+
((paneArea == .main || paneArea == .mainTrailing) && model.trailingSidebarIsCollapsed)
80+
|| paneArea == .trailing
81+
)
82+
}
83+
84+
private func isTrailingItem() -> Bool {
85+
paneArea == .trailing
86+
|| (
87+
(paneArea == .main || paneArea == .mainTrailing)
88+
&& (model.trailingSidebarIsCollapsed || !model.hasTrailingSidebar)
89+
)
5090
}
5191
}

CodeEdit/Features/UtilityArea/Views/UtilityAreaTabView.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,22 @@ struct UtilityAreaTabView<Content: View, LeadingSidebar: View, TrailingSidebar:
118118
}
119119
.buttonStyle(.icon(isActive: !model.leadingSidebarIsCollapsed))
120120
}
121-
Divider()
121+
if #available(macOS 26, *) {
122+
Divider().frame(height: 12)
123+
} else {
124+
Divider()
125+
}
122126
}
123127
}
124128
}
125129
.overlay(alignment: .bottomTrailing) {
126130
if model.hasTrailingSidebar {
127131
PaneToolbar {
128-
Divider()
132+
if #available(macOS 26, *) {
133+
Divider().frame(height: 12)
134+
} else {
135+
Divider()
136+
}
129137
PaneToolbarSection {
130138
Button {
131139
model.trailingSidebarIsCollapsed.toggle()

CodeEdit/WorkspaceView.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ struct WorkspaceView: View {
3535
@State private var editorsHeight: CGFloat = 0
3636
@State private var drawerHeight: CGFloat = 0
3737

38-
private let statusbarHeight: CGFloat = 29
39-
4038
private var keybindings: KeybindingManager = .shared
4139

4240
var body: some View {
@@ -162,15 +160,15 @@ struct WorkspaceView: View {
162160
UtilityAreaView()
163161
.frame(height: utilityAreaViewModel.isMaximized ? nil : drawerHeight)
164162
.frame(maxHeight: utilityAreaViewModel.isMaximized ? .infinity : nil)
165-
.padding(.top, utilityAreaViewModel.isMaximized ? statusbarHeight + 1 : 0)
163+
.padding(.top, utilityAreaViewModel.isMaximized ? StatusBarView.height + 1 : 0)
166164
.offset(y: utilityAreaViewModel.isMaximized ? 0 : editorsHeight + 1)
167165
VStack(spacing: 0) {
168166
StatusBarView(proxy: proxy)
169167
if utilityAreaViewModel.isMaximized {
170168
PanelDivider()
171169
}
172170
}
173-
.offset(y: utilityAreaViewModel.isMaximized ? 0 : editorsHeight - statusbarHeight)
171+
.offset(y: utilityAreaViewModel.isMaximized ? 0 : editorsHeight - StatusBarView.height)
174172
}
175173
.accessibilityElement(children: .contain)
176174
}

0 commit comments

Comments
 (0)