Autoclose android#394
Open
gemdev111 wants to merge 36 commits into
Open
Conversation
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 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.
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #420
closes #298
Images