Commit f6e6de0
authored
Sean/support custom user profile rows (#382)
* Add external navigation path support to UserProfileView
Allow embedding UserProfileView in a parent NavigationStack by passing
an optional navigationPath binding. When provided, destinations push
onto the parent's path instead of an internal stack.
- Add externalPath and externalPathBaseCount to UserProfileNavigation
- Add navigate(to:) and popToRoot() methods for unified navigation
- Extract profileContent to conditionally wrap in NavigationStack
- Track isEmbedded in telemetry payload
# Conflicts:
# Sources/ClerkKitUI/Components/UserProfile/UserProfileView.swift
* Refactor UserProfileView to configure external navigation path lazily
Move external navigation path configuration from init to taskOnce
to ensure the binding is properly captured when the view appears.
This fixes an issue where the external path could be stale when
passed through initializer state wrappers.
* Add includingSelf parameter to popToRoot for account deletion
When deleting the last session in embedded mode, we need to also
pop the UserProfileView entry itself from the parent's navigation
stack, not just the views pushed by the profile flow.
* Fix bounds checking in popToRoot to prevent negative values
* Refactor UserProfileView navigation to use router pattern
Replace imperative navigation.navigate() calls with a new
UserProfileRouter struct that manages push/pop operations via
closures. This provides a cleaner API for embedded and standalone
navigation scenarios.
- Extract routing logic from UserProfileNavigation into UserProfileRouter
- Track embedded push count via @State to properly pop to root
- Inject router through environment for consistent access
* Refactor UserProfileView to use @entry macro for router
Move navigation path from UserProfileNavigation to local state
within UserProfileView, simplifying the navigation class to only
manage presentation state. Replace custom EnvironmentKey with
@entry macro for cleaner environment value declaration.
* Rename UserProfileNavigation to UserProfileSheetNavigation
* Simplify popToRoot by moving includingSelf logic inside
* Simplify popToRoot by combining removeLast operations
* Replace push count tracking with initial path count
Use initialPathCount captured at init to calculate entries to
remove during popToRoot, eliminating the need for onChange tracking
and embeddedPushCount state management.
* Add includingSelf parameter to UserProfileRouter.popToRoot
Clarifies the caller's intent when popping to root after account
deletion. The decision about whether to include the current view
in the pop is now made explicitly at the call site based on
whether the user still exists and if the account switcher will
be presented.
* Add preview for UserProfileView embedded in parent NavigationStack
* Add custom rows support to UserProfileView
Allow developers to inject custom rows into the root profile screen
with flexible placement options. Custom rows can be positioned at
section start/end or before/after specific built-in rows.
* Type user profile custom navigation routes
Replace AnyHashable-based custom row and destination routing with typed
Route generics, add UserProfileNavigator for environment-driven
navigation, and keep a built-in router for Clerk-owned child views.
* Add custom user profile rows to UserButton
Support custom profile rows and destination routing from
`UserButton` into `UserProfileView`.
Update profile row icon rendering so asset and system icons
share consistent sizing and theming.
* Remove built-in row navigation from UserProfileNavigator
The public navigator should only allow pushing custom routes.
Built-in row navigation is now handled internally through
the private navigate(to:) helper method.
* Simplify UserProfileView navigation by inlining navigator
The UserProfileNavigator instance was being created on every body
evaluation via the computed property. Inline the calls to navigate()
directly and construct the navigator only when needed for child views.
* Rename popToRoot to dismiss with explicit action enum
* Rename UserProfileCustomRow to UserProfileCustomItem
Use view modifier API for custom items and destinations
* Move initialPathCount initialization to onFirstAppear
This ensures the initial path count is captured when the view actually
appears rather than during init, providing more reliable navigation
state tracking.
* Move UserButtonPresentationContext below public struct
* Inline UserProfileView sheet content in UserButton
* Improve row ID to support duplicate routes
* Add missing environment objects to SwiftUI previews
* Refactor UserProfileView navigation and extract header
Separate built-in and custom route navigation paths to allow custom
routes to use a distinct navigation destination. Extract header view
and custom row helpers into separate files for better organization.
* Remove unused bundle parameter from UserProfileCustomRow
SwiftUI's LocalizedStringKey automatically uses the calling module's
bundle via an internal init. Explicit bundle passing was redundant
and added unnecessary API surface.
* Change internal properties from public to internal
* Add configurable width and height to asset icon type1 parent be40260 commit f6e6de0
15 files changed
Lines changed: 918 additions & 192 deletions
File tree
- Sources/ClerkKitUI
- Components
- UserButton
- UserProfile
- Extensions
Lines changed: 83 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | 58 | | |
64 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
65 | 62 | | |
66 | 63 | | |
67 | 64 | | |
| |||
80 | 77 | | |
81 | 78 | | |
82 | 79 | | |
83 | | - | |
| 80 | + | |
84 | 81 | | |
85 | 82 | | |
| 83 | + | |
| 84 | + | |
86 | 85 | | |
87 | 86 | | |
88 | 87 | | |
89 | 88 | | |
90 | 89 | | |
91 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
| 96 | + | |
| 97 | + | |
95 | 98 | | |
96 | 99 | | |
97 | 100 | | |
98 | 101 | | |
99 | | - | |
| 102 | + | |
100 | 103 | | |
101 | 104 | | |
102 | 105 | | |
103 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
104 | 109 | | |
105 | 110 | | |
| 111 | + | |
| 112 | + | |
106 | 113 | | |
107 | 114 | | |
108 | 115 | | |
| |||
142 | 149 | | |
143 | 150 | | |
144 | 151 | | |
145 | | - | |
146 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
147 | 159 | | |
148 | 160 | | |
149 | 161 | | |
| |||
163 | 175 | | |
164 | 176 | | |
165 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
166 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
167 | 196 | | |
168 | 197 | | |
169 | 198 | | |
| |||
178 | 207 | | |
179 | 208 | | |
180 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
181 | 251 | | |
182 | 252 | | |
183 | 253 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| 174 | + | |
174 | 175 | | |
175 | 176 | | |
176 | 177 | | |
| |||
Lines changed: 35 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
15 | 26 | | |
16 | 27 | | |
17 | 28 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 29 | + | |
| 30 | + | |
24 | 31 | | |
25 | 32 | | |
26 | 33 | | |
| |||
31 | 38 | | |
32 | 39 | | |
33 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
34 | 62 | | |
35 | 63 | | |
36 | 64 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
135 | 136 | | |
136 | 137 | | |
137 | 138 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
0 commit comments