File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ //
2+ // AndroidNavigationLink.swift
3+ // AndroidSwiftUI
4+ //
5+ // Created by Alsey Coleman Miller on 7/16/26.
6+ //
7+
8+ import AndroidKit
9+
10+ extension NavigationLink : AndroidPrimitive {
11+
12+ var renderedBody : AnyView {
13+ AnyView ( AndroidNavigationLinkContainer ( proxy: _NavigationLinkProxy ( self ) ) )
14+ }
15+ }
16+
17+ /// Native container for `NavigationLink`. Hosts the link's label as a mounted child inside a
18+ /// clickable container that pushes the destination onto the enclosing `NavigationView`'s stack.
19+ struct AndroidNavigationLinkContainer < Label: View , Destination: View > {
20+
21+ let proxy : _NavigationLinkProxy < Label , Destination >
22+ }
23+
24+ extension AndroidNavigationLinkContainer : ParentView {
25+
26+ var children : [ AnyView ] {
27+ [ AnyView ( proxy. label) ]
28+ }
29+ }
30+
31+ extension AndroidNavigationLinkContainer : AndroidViewRepresentable {
32+
33+ typealias Coordinator = Void
34+
35+ func makeAndroidView( context: Self . Context ) -> AndroidWidget . LinearLayout {
36+ let view = AndroidWidget . LinearLayout ( context. androidContext)
37+ let listener = ViewOnClickListener ( action: { proxy. activate ( ) } )
38+ view. setClickable ( true )
39+ view. setOnClickListener ( listener. as ( AndroidView . View. OnClickListener. self) )
40+ return view
41+ }
42+
43+ func updateAndroidView( _ view: AndroidWidget . LinearLayout , context: Self . Context ) {
44+
45+ }
46+ }
You can’t perform that action at this time.
0 commit comments