File tree 2 files changed +40
-3
lines changed
Coder Desktop/Coder Desktop/Views
2 files changed +40
-3
lines changed Original file line number Diff line number Diff line change @@ -131,9 +131,7 @@ struct LoginForm<S: Session>: View {
131
131
Text ( " Generate a session token at " )
132
132
. font ( . subheadline)
133
133
. foregroundColor ( . secondary)
134
- Link ( cliAuthURL. absoluteString, destination: cliAuthURL)
135
- . font ( . subheadline)
136
- . foregroundColor ( . blue)
134
+ ResponsiveLink ( title: cliAuthURL. absoluteString, destination: cliAuthURL)
137
135
}
138
136
}
139
137
} . formStyle ( . grouped) . scrollDisabled ( true ) . padding ( . horizontal)
Original file line number Diff line number Diff line change
1
+ import SwiftUI
2
+
3
+ struct ResponsiveLink : View {
4
+ let title : String
5
+ let destination : URL
6
+
7
+ @State private var isHovered = false
8
+ @State private var isPressed = false
9
+ @Environment ( \. openURL) private var openURL
10
+
11
+ var body : some View {
12
+ Text ( title)
13
+ . font ( . subheadline)
14
+ . foregroundColor ( isPressed ? . red : . blue)
15
+ . underline ( isHovered, color: isPressed ? . red : . blue)
16
+ . onHover { hovering in
17
+ isHovered = hovering
18
+ if hovering {
19
+ NSCursor . pointingHand. push ( )
20
+ } else {
21
+ NSCursor . pop ( )
22
+ }
23
+ }
24
+ . simultaneousGesture (
25
+ DragGesture ( minimumDistance: 0 )
26
+ . onChanged { _ in
27
+ withAnimation ( . easeInOut( duration: 0.1 ) ) {
28
+ isPressed = true
29
+ }
30
+ }
31
+ . onEnded { _ in
32
+ withAnimation ( . easeInOut( duration: 0.1 ) ) {
33
+ isPressed = false
34
+ }
35
+ openURL ( destination)
36
+ }
37
+ )
38
+ }
39
+ }
You can’t perform that action at this time.
0 commit comments