Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd5bc158

Browse files
feat: make workspaces list scrollable on overflow (#197)
Closes#188.If the workspaces view exceeds 400px in height, it'll become scrollable. The diff without whitespace changes is like 4 lines.https://github.com/user-attachments/assets/5bdd0369-c882-4085-9513-7594bd100475I think the `View more`/`View less` very much still makes sense, so I'm keeping it.
1 parent5da2698 commitd5bc158

File tree

2 files changed

+40
-35
lines changed

2 files changed

+40
-35
lines changed

‎Coder-Desktop/Coder-Desktop/Views/VPN/Agents.swift‎

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,32 @@ struct Agents<VPN: VPNService>: View {
1616
if vpn.state==.connected{
1717
letitems= vpn.menuState.sorted
1818
letvisibleItems= viewAll?items[...]: items.prefix(defaultVisibleRows)
19-
ForEach(visibleItems, id: \.id){ agentin
20-
MenuItemView(
21-
item: agent,
22-
baseAccessURL: state.baseAccessURL!,
23-
expandedItem: $expandedItem,
24-
userInteracted: $hasToggledExpansion
25-
)
26-
.padding(.horizontal,Theme.Size.trayMargin)
27-
}.onChange(of: visibleItems){
28-
// If no workspaces are online, we should expand the first one to come online
29-
if visibleItems.filter({ $0.status!=.off}).isEmpty{
30-
hasToggledExpansion=false
31-
return
19+
ScrollView(showsIndicators:false){
20+
ForEach(visibleItems, id: \.id){ agentin
21+
MenuItemView(
22+
item: agent,
23+
baseAccessURL: state.baseAccessURL!,
24+
expandedItem: $expandedItem,
25+
userInteracted: $hasToggledExpansion
26+
)
27+
.padding(.horizontal,Theme.Size.trayMargin)
28+
}.onChange(of: visibleItems){
29+
// If no workspaces are online, we should expand the first one to come online
30+
if visibleItems.filter({ $0.status!=.off}).isEmpty{
31+
hasToggledExpansion=false
32+
return
33+
}
34+
if hasToggledExpansion{
35+
return
36+
}
37+
withAnimation(.snappy(duration:Theme.Animation.collapsibleDuration)){
38+
expandedItem= visibleItems.first?.id
39+
}
40+
hasToggledExpansion=true
3241
}
33-
if hasToggledExpansion{
34-
return
35-
}
36-
withAnimation(.snappy(duration:Theme.Animation.collapsibleDuration)){
37-
expandedItem= visibleItems.first?.id
38-
}
39-
hasToggledExpansion=true
4042
}
43+
.scrollBounceBehavior(.basedOnSize)
44+
.frame(maxHeight:400)
4145
if items.count==0{
4246
Text("No workspaces!")
4347
.font(.body)

‎Coder-Desktop/Coder-Desktop/Views/VPN/VPNMenuItem.swift‎

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -138,24 +138,25 @@ struct MenuItemView: View {
138138
MenuItemIcons(item: item, wsURL: wsURL)
139139
}
140140
if isExpanded{
141-
switch(loadingApps, hasApps){
142-
case(true, _):
143-
CircularProgressView(value:nil, strokeWidth:3, diameter:15)
144-
.padding(.top,5)
145-
case(false,true):
146-
MenuItemCollapsibleView(apps: apps)
147-
case(false,false):
148-
HStack{
149-
Text(item.status==.off?"Workspace is offline.":"No apps available.")
150-
.font(.body)
151-
.foregroundColor(.secondary)
152-
.padding(.horizontal,Theme.Size.trayInset)
153-
.padding(.top,7)
141+
Group{
142+
switch(loadingApps, hasApps){
143+
case(true, _):
144+
CircularProgressView(value:nil, strokeWidth:3, diameter:15)
145+
.padding(.top,5)
146+
case(false,true):
147+
MenuItemCollapsibleView(apps: apps)
148+
case(false,false):
149+
HStack{
150+
Text(item.status==.off?"Workspace is offline.":"No apps available.")
151+
.font(.body)
152+
.foregroundColor(.secondary)
153+
.padding(.horizontal,Theme.Size.trayInset)
154+
.padding(.top,7)
155+
}
154156
}
155-
}
157+
}.task{awaitloadApps()}
156158
}
157159
}
158-
.task{awaitloadApps()}
159160
}
160161

161162
func loadApps()async{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp