Skip to content

Commit

Permalink
dismiss on success, update button state on submission
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-dydx committed Jun 12, 2024
1 parent 71b70b8 commit 2b106fb
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 17 deletions.
57 changes: 42 additions & 15 deletions dydx/dydx.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "3cd7346cace16cf660f9c22302c5ca6770335c67902f3fd155011356a9d43929",
"originHash" : "975d00e29efb8d2ca017c5e61df90418ac01f7d7143e85a3f9ddb4eb982154e4",
"pins" : [
{
"identity" : "bigint",
Expand Down Expand Up @@ -37,6 +37,15 @@
"version" : "2.0.2"
}
},
{
"identity" : "keyboardobserving",
"kind" : "remoteSourceControl",
"location" : "https://github.com/nickffox/KeyboardObserving",
"state" : {
"branch" : "master",
"revision" : "48134b5460435cc9d048223ad7560ee2e40f3d4a"
}
},
{
"identity" : "percy-xcui-swift",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -87,8 +96,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"revision" : "a902f1823a7ff3c9ab2fba0f992396b948eda307",
"version" : "1.0.5"
"revision" : "ee97538f5b81ae89698fd95938896dec5217b148",
"version" : "1.1.1"
}
},
{
Expand All @@ -105,26 +114,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "532d8b529501fb73a2455b179e0bbb6d49b652ed",
"version" : "1.5.3"
"revision" : "e97a6fcb1ab07462881ac165fdbb37f067e205d5",
"version" : "1.5.4"
}
},
{
"identity" : "swift-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "853522d90871b4b63262843196685795b5008c46",
"version" : "2.61.1"
"revision" : "9428f62793696d9a0cc1f26a63f63bb31da0516d",
"version" : "2.66.0"
}
},
{
"identity" : "swift-nio-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-extras.git",
"state" : {
"revision" : "798c962495593a23fdea0c0c63fd55571d8dff51",
"version" : "1.20.0"
"revision" : "a3b640d7dc567225db7c94386a6e71aded1bfa63",
"version" : "1.22.0"
}
},
{
Expand All @@ -141,17 +150,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-ssl.git",
"state" : {
"revision" : "320bd978cceb8e88c125dcbb774943a92f6286e9",
"version" : "2.25.0"
"revision" : "2b09805797f21c380f7dc9bedaab3157c5508efb",
"version" : "2.27.0"
}
},
{
"identity" : "swift-nio-transport-services",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-transport-services.git",
"state" : {
"revision" : "ebf8b9c365a6ce043bf6e6326a04b15589bd285e",
"version" : "1.20.0"
"revision" : "38ac8221dd20674682148d6451367f89c2652980",
"version" : "1.21.0"
}
},
{
Expand All @@ -163,6 +172,15 @@
"version" : "1.0.3"
}
},
{
"identity" : "swift-system",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-system.git",
"state" : {
"revision" : "f9266c85189c2751589a50ea5aec72799797e471",
"version" : "1.3.0"
}
},
{
"identity" : "swiftimagereadwrite",
"kind" : "remoteSourceControl",
Expand All @@ -181,6 +199,15 @@
"version" : "9.0.9"
}
},
{
"identity" : "swiftui-introspect",
"kind" : "remoteSourceControl",
"location" : "https://github.com/siteline/SwiftUI-Introspect.git",
"state" : {
"revision" : "121c146fe591b1320238d054ae35c81ffa45f45a",
"version" : "0.12.0"
}
},
{
"identity" : "wallet-mobile-sdk",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -222,8 +249,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/websocket-kit.git",
"state" : {
"revision" : "53fe0639a98903858d0196b699720decb42aee7b",
"version" : "2.14.0"
"revision" : "4232d34efa49f633ba61afde365d3896fc7f8740",
"version" : "2.15.0"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,15 @@ private class dydxAdjustMarginInputViewPresenter: HostedViewPresenter<dydxAdjust
AbacusStateManager.shared.adjustIsolatedMargin(input: "1", type: .amountpercent)
}

ctaButtonPresenter.viewModel?.ctaAction = {
ctaButtonPresenter.viewModel?.ctaAction = { [weak self] in
self?.ctaButtonPresenter.viewModel?.ctaButtonState = .thinking
AbacusStateManager.shared.commitAdjustIsolatedMargin { [weak self] (_, error, _) in
self?.ctaButtonPresenter.viewModel?.ctaButtonState = .disabled()
if let error = error {
self?.viewModel?.submissionError = InlineAlertViewModel(.init(title: nil, body: error.message, level: .error))
return
} else {
self?.viewModel?.submissionError = nil
Router.shared?.navigate(to: RoutingRequest(path: "/action/dismiss"), animated: true, completion: nil)
}
}
}
Expand Down Expand Up @@ -122,6 +125,12 @@ private class dydxAdjustMarginInputViewPresenter: HostedViewPresenter<dydxAdjust
self?.updateButtonState(input: input)
}
.store(in: &subscriptions)

AbacusStateManager.shared.state.adjustIsolatedMarginInput
.sink { [weak self] _ in
self?.viewModel?.submissionError = nil
}
.store(in: &subscriptions)
}

private func updateState(market: PerpetualMarket, assetMap: [String: Asset]) {
Expand Down

0 comments on commit 2b106fb

Please sign in to comment.