Skip to content

Commit

Permalink
persist add/remove margin selection after dismiss and reopen
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-dydx committed Jun 28, 2024
1 parent 8a116e2 commit 7de65b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,16 @@ private class dydxAdjustMarginInputViewPresenter: HostedViewPresenter<dydxAdjust
}

private func updateForMarginDirection(input: AdjustIsolatedMarginInput) {

switch input.type {
case IsolatedMarginAdjustmentType.add:
viewModel?.marginDirection?.marginDirection = .add
viewModel?.amount?.label = DataLocalizer.localize(path: "APP.GENERAL.AMOUNT_TO_ADD")
case IsolatedMarginAdjustmentType.remove:
viewModel?.marginDirection?.marginDirection = .remove
viewModel?.amount?.label = DataLocalizer.localize(path: "APP.GENERAL.AMOUNT_TO_REMOVE")
default:
viewModel?.marginDirection?.marginDirection = .add
viewModel?.amount?.label = DataLocalizer.localize(path: "APP.GENERAL.AMOUNT")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class dydxAdjustMarginDirectionViewModel: PlatformViewModel {
}
}

@Published public var marginDirection: MarginDirection = .add
@Published public var marginDirection: MarginDirection?
@Published public var marginDirectionAction: ((MarginDirection) -> Void)?

public init() { }
Expand Down Expand Up @@ -63,7 +63,7 @@ public class dydxAdjustMarginDirectionViewModel: PlatformViewModel {
let view = ScrollView(.horizontal, showsIndicators: false) {
TabGroupModel(items: items,
selectedItems: selectedItems,
currentSelection: self.marginDirection.index,
currentSelection: self.marginDirection?.index,
onSelectionChanged: { index in
PlatformView.hideKeyboard()
self.marginDirectionAction?(MarginDirection(index: index))
Expand Down

0 comments on commit 7de65b5

Please sign in to comment.