Commit 5344191
authored
Autoclose android (#394)
* Add autoclose domain types for perpetual TP/SL modify
* Add autoclose UI model and factory
* Add coordinator support for perpetual modify
* Add shared autoclose UI components
* Add autoclose modify viewmodel and scene
* Wire perpetual position autoclose entry point and route
Also fixes pull-to-refresh indicator showing on first open by
splitting fetch() (initial load, no refresh state) from refresh()
(user gesture, sets refresh state).
* Add open-time autoclose support
* Add modify autoclose summary to confirm screen
* Extract NavEntryViewModelStoreOwner to shared :ui utility
* Suppress autoclose PnL when trigger price is directionally invalid
* Keep GemTextField caret at end on external value updates
* Add asset header and polish AmountAutocloseSheet open flow
* Restructure autoclose modify flow as nested nav graph
* Match autoclose sheet height to modal-sheet convention
* Replace core submodule with main's vendored core (pre-merge, local)
* Fix AppIcons
* Parse Auto Close TP/SL prices locale-aware
Add NumericFormatter.double(from:) and route every take-profit/stop-loss parse through it (modify view model, open-position provider, and sheet), matching iOS which parses numeric input with a locale formatter. The open-position flow previously used toDoubleOrNull(), which dropped the trigger in comma-decimal locales. The typed USD amount now parses via the canonical parseNumber() so the preview matches the built order.
* Consolidate Auto Close scene to single onAction
Replace the per-callback parameters with a sealed AutocloseAction dispatched through onAction, matching PerpetualPositionScene. Use the shared CenterAlignedTopAppBar header so the input title matches the confirm screen.
* Fix Auto Close chevron spacing
The Auto Close rows hand-rolled the chevron with a 12dp spacer, leaving a gap no other row has. Use the standard DataBadgeChevron so the chevron sits flush against the value.
* Defer Auto Close validation until submit
Keep the confirm button enabled while there is a pending change and validate on press (revealing the inline error) instead of disabling on an invalid value, matching iOS's manual-validation behavior.
* Tidy Auto Close estimator and validator
Remove the unused AutocloseValidator.isValid and make AutocloseEstimator.priceChangePercent private (only roe uses it).
* Localize Auto Close trigger errors and separate them from the field
Route the trigger-price errors through the errors.perpetual.* localization keys on both platforms (Android R.string, iOS PerpetualError -> Localized.Errors.Perpetual, dropping the hardcoded TODO), and add a divider before the field error to match iOS.
* Update PerpetualError.swift
* Add Auto Close defaults and suggestion tiers to perpetual config
Expose take-profit/stop-loss percent options, their defaults, and a leverage-tiered get_autoclose_suggestions() helper from the shared perpetual config.
* Source Auto Close suggestions and options from core
Drop the hardcoded leverage->suggestion tiers duplicated in iOS and Android and read them, plus the TP/SL percent options and defaults, through the Gemstone config wrappers.
* Generalize leverage picker into reusable WheelPickerSheet
Replace LeveragePickerSheet/LeveragePickerView with a generic WheelPickerSheet over WheelPickerDisplayable so it can back any wheel-style option, and migrate the leverage selector to it.
* Add default Take Profit and Stop Loss preferences on iOS
Persist default TP/SL percents alongside leverage, add the AutocloseOption type and two picker rows to Preferences, and make the leverage default fall back to the core default via a 0 sentinel.
* Prefill Auto Close from defaults and recompute on leverage change
Seed TP/SL from the saved default percents when opening a position and re-derive the target prices when leverage changes, unless the user has already edited them.
* Add default Take Profit and Stop Loss preferences on Android
Store default TP/SL percents in UserConfig, expose them from SettingsViewModel, and add the rows to Preferences via a generic OptionPickerLinkItem.
* Prefill Auto Close from defaults via trigger flows
Derive TP/SL trigger prices from the saved default percents reactively against market price and leverage, falling back to user edits once a field is touched.
* Show Auto Close suggestions only when the field is empty
Match iOS by gating the suggestions bar on an empty active field, and stop the amount sheet from overwriting in-progress input on every reactive trigger update.
* Support indented LinkItem; reorder Perpetual VM
Add an indented flag to LinkItem (with Spacer import) to reserve the leading icon space when no painter is provided, and enable it in the preferences option picker. Also refactor AmountPerpetualViewModel by moving transferData/leverage properties and autoclose-related methods (onChangeLeverage, updateAutoclose) to a different location for clarity—no behavior changes intended.
* Remove Done button from Auto Close suggestions bar
Android dismisses the keyboard via the system IME affordance, so the suggestions bar no longer needs its own Done button; drop it and the now-unused focus manager wiring.
* Extend stop-loss percent options with 3% and 5%
* Show Perpetuals settings without developer mode on Android
Match iOS: the Perpetuals toggle is always visible in Preferences (no developer-mode gate), and the default leverage/take-profit/stop-loss rows show whenever the toggle is on. Feature visibility elsewhere still uses isPerpetualEnabled && hasPerpetualsSupport, identical to iOS.
* React to Perpetuals toggle for data sync on Android
Match iOS updatePerpetualConnection: observe session + isPerpetualEnabled and (re)sync perpetuals/positions when a perps-capable wallet has the toggle on, instead of snapshotting the flag once at wallet change.1 parent c056970 commit 5344191
79 files changed
Lines changed: 2726 additions & 293 deletions
File tree
- android
- data
- coordinators/src/main/kotlin/com/gemwallet/android/data/coordinators/perpetuals
- repositories/src/main/kotlin/com/gemwallet/android/data/repositories
- config
- stream
- features
- confirm
- presents/src/main/kotlin/com/gemwallet/android/features/confirm/presents
- viewmodels/src
- main/kotlin/com/gemwallet/android/features/confirm
- models
- viewmodels
- test/kotlin/com/gemwallet/android/features/confirm/models
- perpetual
- presents
- src/main/kotlin/com/gemwallet/android/features/perpetual/views
- autoclose
- components
- market
- position
- viewmodels/src/main/kotlin/com/gemwallet/android/features/perpetual/viewmodels
- settings/settings
- presents/src/main/kotlin/com/gemwallet/android/features/settings/settings/presents/views
- viewmodels/src/main/kotlin/com/gemwallet/android/features/settings/settings/viewmodels
- transfer_amount
- presents/src/main/kotlin/com/gemwallet/android/features/transfer_amount/presents
- dialogs
- viewmodels
- src
- main/kotlin/com/gemwallet/android/features/transfer_amount/viewmodels/providers
- test/kotlin/com/gemwallet/android/features/transfer_amount/viewmodels/providers
- gemcore/src
- main/kotlin/com/gemwallet/android
- application/perpetual/coordinators
- domains/perpetual
- autoclose
- ext
- model
- testFixtures/kotlin/com/gemwallet/android/testkit
- test/kotlin/com/gemwallet/android
- domains/perpetual/autoclose
- model
- ui-models/src
- main/kotlin/com/gemwallet/android/ui/models/perpetual/autoclose
- test/kotlin/com/gemwallet/android/ui/models/perpetual/autoclose
- ui/src/main
- kotlin/com/gemwallet/android/ui
- components
- list_item
- property
- perpetual
- viewmodel
- res/values
- core/gemstone/src/config
- ios
- Features
- Perpetuals/Sources/ViewModels
- Settings/Sources/Settings
- Scenes
- ViewModels
- Transfer/Sources/ViewModels
- Packages
- GemstonePrimitives/Sources
- Localization/Sources
- Resources/en.lproj
- Preferences
- Sources
- Tests
- PrimitivesComponents/Sources
- Scenes
- Types
- Views
- Validators/Sources/Errors
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
android/app/src/main/kotlin/com/gemwallet/android/ui/navigation/RouteArgumentsNavEntryDecorator.kt
Lines changed: 3 additions & 46 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | 6 | | |
12 | 7 | | |
13 | 8 | | |
14 | 9 | | |
15 | | - | |
16 | 10 | | |
17 | | - | |
18 | 11 | | |
19 | 12 | | |
20 | 13 | | |
| |||
23 | 16 | | |
24 | 17 | | |
25 | 18 | | |
26 | | - | |
27 | 19 | | |
28 | 20 | | |
29 | 21 | | |
30 | 22 | | |
31 | 23 | | |
| 24 | + | |
32 | 25 | | |
33 | 26 | | |
34 | 27 | | |
| |||
110 | 103 | | |
111 | 104 | | |
112 | 105 | | |
113 | | - | |
| 106 | + | |
114 | 107 | | |
115 | 108 | | |
116 | 109 | | |
| |||
158 | 151 | | |
159 | 152 | | |
160 | 153 | | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | 154 | | |
199 | 155 | | |
200 | 156 | | |
| |||
209 | 165 | | |
210 | 166 | | |
211 | 167 | | |
| 168 | + | |
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | | - | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | | - | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| |||
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
66 | 89 | | |
67 | 90 | | |
68 | 91 | | |
| |||
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
84 | 102 | | |
85 | 103 | | |
86 | 104 | | |
| |||
206 | 224 | | |
207 | 225 | | |
208 | 226 | | |
| 227 | + | |
| 228 | + | |
209 | 229 | | |
210 | 230 | | |
211 | 231 | | |
Lines changed: 28 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
31 | 33 | | |
32 | | - | |
| 34 | + | |
| 35 | + | |
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
| |||
64 | 67 | | |
65 | 68 | | |
66 | 69 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | 70 | | |
72 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
73 | 78 | | |
74 | 79 | | |
75 | 80 | | |
| |||
139 | 144 | | |
140 | 145 | | |
141 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
317 | 318 | | |
318 | 319 | | |
319 | 320 | | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
320 | 326 | | |
321 | 327 | | |
322 | 328 | | |
| |||
340 | 346 | | |
341 | 347 | | |
342 | 348 | | |
| 349 | + | |
| 350 | + | |
343 | 351 | | |
344 | 352 | | |
345 | 353 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
14 | 19 | | |
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
323 | 325 | | |
324 | 326 | | |
325 | 327 | | |
326 | | - | |
327 | | - | |
328 | | - | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
329 | 332 | | |
330 | 333 | | |
331 | 334 | | |
| |||
0 commit comments