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

Commitf0465a3

Browse files
committed
add back the focus code
1 parent5133c65 commitf0465a3

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

‎Coder Desktop/Coder Desktop/Coder_DesktopApp.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ struct DesktopApp: App {
1111
EmptyView()
1212
}
1313
Window("Sign In", id:Windows.login.rawValue){
14-
LoginForm<PreviewSession>()
15-
}.environmentObject(appDelegate.session)
14+
LoginForm<PreviewSession>().environmentObject(appDelegate.session)
15+
}
1616
.windowResizability(.contentSize)
1717
}
1818
}

‎Coder Desktop/Coder Desktop/Views/LoginForm.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ struct LoginForm<S: Session>: View {
1010
@StateprivatevarloginError:LoginError?
1111
@StateprivatevarcurrentPage:LoginPage=.serverURL
1212
@Stateprivatevarloading:Bool=false
13+
@FocusStateprivatevarfocusedField:LoginField?
1314

1415
letinspection=Inspection<Self>()
1516

@@ -19,9 +20,19 @@ struct LoginForm<S: Session>: View {
1920
case.serverURL:
2021
serverURLPage
2122
.transition(.move(edge:.leading))
23+
.onAppear{
24+
DispatchQueue.main.async{
25+
focusedField=.baseAccessURL
26+
}
27+
}
2228
case.sessionToken:
2329
sessionTokenPage
2430
.transition(.move(edge:.trailing))
31+
.onAppear{
32+
DispatchQueue.main.async{
33+
focusedField=.sessionToken
34+
}
35+
}
2536
}
2637
}
2738
.animation(.easeInOut, value: currentPage)
@@ -79,6 +90,7 @@ struct LoginForm<S: Session>: View {
7990
text: $baseAccessURL,
8091
prompt:Text("https://coder.example.com")
8192
).autocorrectionDisabled()
93+
.focused($focusedField, equals:.baseAccessURL)
8294
}
8395
}.formStyle(.grouped).scrollDisabled(true).padding(.horizontal)
8496
Divider()
@@ -110,6 +122,7 @@ struct LoginForm<S: Session>: View {
110122
SecureField("Session Token", text: $sessionToken, prompt:Text("●●●●●●●●"))
111123
.autocorrectionDisabled()
112124
.privacySensitive()
125+
.focused($focusedField, equals:.sessionToken)
113126
HStack(spacing:0){
114127
Text("Generate a session token at")
115128
.font(.subheadline)
@@ -144,12 +157,14 @@ struct LoginForm<S: Session>: View {
144157
}
145158
withAnimation{
146159
currentPage=.sessionToken
160+
focusedField=.sessionToken
147161
}
148162
}
149163

150164
privatefunc back(){
151165
withAnimation{
152166
currentPage=.serverURL
167+
focusedField=.baseAccessURL
153168
}
154169
}
155170
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp