Skip to content

Commit 4575ead

Browse files
committed
improve branch selector UI to match icon picker style
1 parent 51fb165 commit 4575ead

1 file changed

Lines changed: 61 additions & 48 deletions

File tree

aizen/Views/Worktree/Components/BranchSelectorView.swift

Lines changed: 61 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,45 @@ struct BranchSelectorView: View {
2222

2323
var body: some View {
2424
VStack(spacing: 0) {
25-
// Search field
26-
HStack(spacing: 8) {
27-
Image(systemName: "magnifyingglass")
28-
.font(.system(size: 12))
29-
.foregroundStyle(.secondary)
25+
// Header with search and close
26+
HStack(spacing: 12) {
27+
HStack(spacing: 8) {
28+
Image(systemName: "magnifyingglass")
29+
.foregroundStyle(.secondary)
3030

31-
TextField(allowCreation ? "Search or create new one" : "Search branches", text: $searchText)
32-
.textFieldStyle(.plain)
33-
.font(.system(size: 12))
34-
.onSubmit {
35-
if allowCreation && !searchText.isEmpty && filteredBranches.isEmpty {
36-
createBranch()
31+
TextField(allowCreation ? "Search or create new one" : "Search branches", text: $searchText)
32+
.textFieldStyle(.plain)
33+
.onSubmit {
34+
if allowCreation && !searchText.isEmpty && filteredBranches.isEmpty {
35+
createBranch()
36+
}
3737
}
38-
}
3938

40-
if !searchText.isEmpty {
41-
Button {
42-
searchText = ""
43-
} label: {
44-
Image(systemName: "xmark.circle.fill")
45-
.font(.system(size: 12))
46-
.foregroundStyle(.secondary)
39+
if !searchText.isEmpty {
40+
Button {
41+
searchText = ""
42+
} label: {
43+
Image(systemName: "xmark.circle.fill")
44+
.foregroundStyle(.secondary)
45+
}
46+
.buttonStyle(.plain)
4747
}
48-
.buttonStyle(.plain)
4948
}
49+
.padding(8)
50+
.background(Color(nsColor: .controlBackgroundColor))
51+
.cornerRadius(8)
52+
53+
Button {
54+
dismiss()
55+
} label: {
56+
Image(systemName: "xmark.circle.fill")
57+
.font(.system(size: 20))
58+
.symbolRenderingMode(.hierarchical)
59+
.foregroundStyle(.secondary)
60+
}
61+
.buttonStyle(.borderless)
5062
}
5163
.padding(12)
52-
.background(Color(nsColor: .textBackgroundColor))
53-
.cornerRadius(6)
54-
.padding()
5564

5665
Divider()
5766

@@ -90,6 +99,17 @@ struct BranchSelectorView: View {
9099
} else {
91100
ScrollView {
92101
LazyVStack(alignment: .leading, spacing: 0) {
102+
// Count label
103+
HStack {
104+
Text("\(filteredBranches.count) branches")
105+
.font(.caption)
106+
.foregroundStyle(.secondary)
107+
Spacer()
108+
}
109+
.padding(.horizontal, 12)
110+
.padding(.top, 8)
111+
.padding(.bottom, 4)
112+
93113
ForEach(Array(filteredBranches.prefix(displayedCount)), id: \.id) { branch in
94114
branchRow(branch)
95115
}
@@ -102,15 +122,15 @@ struct BranchSelectorView: View {
102122
HStack {
103123
Image(systemName: "plus.circle")
104124
.font(.system(size: 12))
105-
.foregroundStyle(.blue)
125+
.foregroundStyle(Color.accentColor)
106126

107127
Text("Create branch: \(searchText)")
108128
.font(.system(size: 12))
109129
.foregroundStyle(.primary)
110130

111131
Spacer()
112132
}
113-
.padding(.horizontal, 16)
133+
.padding(.horizontal, 12)
114134
.padding(.vertical, 12)
115135
}
116136
.buttonStyle(.plain)
@@ -123,31 +143,22 @@ struct BranchSelectorView: View {
123143
displayedCount = min(displayedCount + pageSize, filteredBranches.count)
124144
}
125145
} label: {
126-
HStack {
127-
Image(systemName: "arrow.down.circle")
128-
.font(.system(size: 11))
129-
.foregroundStyle(.blue)
130-
131-
Text("Load \(min(pageSize, filteredBranches.count - displayedCount)) more...")
132-
.font(.system(size: 11))
133-
.foregroundStyle(.blue)
134-
135-
Spacer()
136-
137-
Text("\(displayedCount) of \(filteredBranches.count)")
138-
.font(.system(size: 10, design: .monospaced))
139-
.foregroundStyle(.secondary)
140-
}
141-
.padding(.horizontal, 16)
142-
.padding(.vertical, 12)
146+
Text("Load more (\(filteredBranches.count - displayedCount) remaining)")
147+
.font(.caption)
148+
.foregroundStyle(Color.accentColor)
149+
.padding(.vertical, 12)
143150
}
144151
.buttonStyle(.plain)
152+
.frame(maxWidth: .infinity)
145153
}
146154
}
155+
.padding(.bottom, 12)
147156
}
157+
.background(Color(nsColor: .controlBackgroundColor))
148158
}
149159
}
150160
.frame(width: 350, height: 400)
161+
.background(Color(nsColor: .windowBackgroundColor))
151162
.onAppear {
152163
loadBranches()
153164
}
@@ -163,10 +174,10 @@ struct BranchSelectorView: View {
163174
dismiss()
164175
}
165176
} label: {
166-
HStack {
177+
HStack(spacing: 8) {
167178
Image(systemName: "arrow.triangle.branch")
168-
.font(.system(size: 10))
169-
.foregroundStyle(.secondary)
179+
.font(.system(size: 11))
180+
.foregroundStyle(branch.id == selectedBranch?.id ? Color.accentColor : Color.secondary)
170181

171182
Text(branch.name)
172183
.font(.system(size: 12, design: .monospaced))
@@ -176,13 +187,15 @@ struct BranchSelectorView: View {
176187

177188
if branch.id == selectedBranch?.id {
178189
Image(systemName: "checkmark")
179-
.font(.system(size: 10))
180-
.foregroundStyle(.blue)
190+
.font(.system(size: 11, weight: .medium))
191+
.foregroundStyle(Color.accentColor)
181192
}
182193
}
183-
.padding(.horizontal, 16)
194+
.padding(.horizontal, 12)
184195
.padding(.vertical, 8)
185196
.background(branch.id == selectedBranch?.id ? Color.accentColor.opacity(0.1) : Color.clear)
197+
.cornerRadius(6)
198+
.padding(.horizontal, 4)
186199
}
187200
.buttonStyle(.plain)
188201
}

0 commit comments

Comments
 (0)