Skip to content

Autoclose android#394

Open
gemdev111 wants to merge 36 commits into
mainfrom
autoclose-android
Open

Autoclose android#394
gemdev111 wants to merge 36 commits into
mainfrom
autoclose-android

Conversation

@gemdev111
Copy link
Copy Markdown
Contributor

@gemdev111 gemdev111 commented May 28, 2026

closes #420
closes #298

Images

@gemdev111 gemdev111 self-assigned this May 28, 2026
gemdev111 added 12 commits May 28, 2026 19:32
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.
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.
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.
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.
Remove the unused AutocloseValidator.isValid and make AutocloseEstimator.priceChangePercent private (only roe uses it).
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.
@gemdev111 gemdev111 marked this pull request as ready for review June 1, 2026 17:55
gemdev111 added 3 commits June 1, 2026 21:00
Expose take-profit/stop-loss percent options, their defaults, and a leverage-tiered get_autoclose_suggestions() helper from the shared perpetual config.
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.
gemdev111 added 8 commits June 2, 2026 18:32
Replace LeveragePickerSheet/LeveragePickerView with a generic WheelPickerSheet over WheelPickerDisplayable so it can back any wheel-style option, and migrate the leverage selector to it.
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.
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.
Store default TP/SL percents in UserConfig, expose them from SettingsViewModel, and add the rows to Preferences via a generic OptionPickerLinkItem.
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.
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.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrate autoclose feature open/modify flow Add perpetual default percent auto close

1 participant