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

Commitd4fe07e

Browse files
committed
expand first
1 parentcd5877a commitd4fe07e

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ struct Agents<VPN: VPNService>: View {
55
@EnvironmentObjectvarstate:AppState
66
@StateprivatevarviewAll=false
77
@StateprivatevarexpandedItem:VPNMenuItem.ID?
8+
@StateprivatevarhasToggledExpansion:Bool=false
89
privateletdefaultVisibleRows=5
910

1011
letinspection=Inspection<Self>()
@@ -16,8 +17,24 @@ struct Agents<VPN: VPNService>: View {
1617
letitems= vpn.menuState.sorted
1718
letvisibleItems= viewAll?items[...]: items.prefix(defaultVisibleRows)
1819
ForEach(visibleItems, id: \.id){ agentin
19-
MenuItemView(item: agent, baseAccessURL: state.baseAccessURL!, expandedItem: $expandedItem)
20-
.padding(.horizontal,Theme.Size.trayMargin)
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
32+
}
33+
if hasToggledExpansion{
34+
return
35+
}
36+
expandedItem= visibleItems.first?.id
37+
hasToggledExpansion=true
2138
}
2239
if items.count==0{
2340
Text("No workspaces!")

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ struct MenuItemView: View {
6666
letitem:VPNMenuItem
6767
letbaseAccessURL:URL
6868
@BindingvarexpandedItem:VPNMenuItem.ID?
69+
@BindingvaruserInteracted:Bool
6970

7071
@StateprivatevarnameIsSelected:Bool=false
7172

@@ -95,6 +96,7 @@ struct MenuItemView: View {
9596
}
9697

9798
privatefunc toggleExpanded(){
99+
userInteracted=true
98100
if isExpanded{
99101
withAnimation(.snappy(duration:Theme.Animation.collapsibleDuration)){
100102
expandedItem=nil
@@ -254,6 +256,5 @@ struct AnimatedChevron: View {
254256
.font(.system(size:12, weight:.semibold))
255257
.foregroundColor(color)
256258
.rotationEffect(.degrees(isExpanded?90:0))
257-
.animation(.easeInOut(duration:Theme.Animation.collapsibleDuration), value: isExpanded)
258259
}
259260
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp