File tree Expand file tree Collapse file tree 2 files changed +40
-3
lines changed
Coder Desktop/Coder Desktop/Views Expand file tree Collapse file tree 2 files changed +40
-3
lines changed Original file line number Diff line number Diff line change @@ -128,9 +128,7 @@ struct LoginForm<S: Session>: View {
128128 Text ( " Generate a session token at " )
129129 . font ( . subheadline)
130130 . foregroundColor ( . secondary)
131- Link ( cliAuthURL. absoluteString, destination: cliAuthURL)
132- . font ( . subheadline)
133- . foregroundColor ( . blue)
131+ ResponsiveLink ( title: cliAuthURL. absoluteString, destination: cliAuthURL)
134132 }
135133 }
136134 } . 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