-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MOB-483 Add isolated / cross margin mode button, Add target leverage …
…button (#158)
- Loading branch information
Showing
12 changed files
with
454 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
43 changes: 43 additions & 0 deletions
43
dydx/dydxPresenters/dydxPresenters/_v4/Trade/Margin/dydxMarginModeViewBuilder.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// dydxMarginModeViewBuilder.swift | ||
// dydxPresenters | ||
// | ||
// Created by Rui Huang on 07/05/2024. | ||
// | ||
|
||
import Utilities | ||
import dydxViews | ||
import PlatformParticles | ||
import RoutingKit | ||
import ParticlesKit | ||
import PlatformUI | ||
|
||
public class dydxMarginModeViewBuilder: NSObject, ObjectBuilderProtocol { | ||
public func build<T>() -> T? { | ||
let presenter = dydxMarginModeViewPresenter() | ||
let view = presenter.viewModel?.createView() ?? PlatformViewModel().createView() | ||
return dydxMarginModeViewController(presenter: presenter, view: view, configuration: .default) as? T | ||
// return HostingViewController(presenter: presenter, view: view) as? T | ||
} | ||
} | ||
|
||
private class dydxMarginModeViewController: HostingViewController<PlatformView, dydxMarginModeViewModel> { | ||
override public func arrive(to request: RoutingRequest?, animated: Bool) -> Bool { | ||
if request?.path == "/trade/margin_type" { | ||
return true | ||
} | ||
return false | ||
} | ||
} | ||
|
||
private protocol dydxMarginModeViewPresenterProtocol: HostedViewPresenterProtocol { | ||
var viewModel: dydxMarginModeViewModel? { get } | ||
} | ||
|
||
private class dydxMarginModeViewPresenter: HostedViewPresenter<dydxMarginModeViewModel>, dydxMarginModeViewPresenterProtocol { | ||
override init() { | ||
super.init() | ||
|
||
viewModel = dydxMarginModeViewModel() | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
dydx/dydxPresenters/dydxPresenters/_v4/Trade/Margin/dydxTargetLeverageViewBuilder.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// dydxTargetLeverageViewBuilder.swift | ||
// dydxPresenters | ||
// | ||
// Created by Rui Huang on 07/05/2024. | ||
// | ||
|
||
import Utilities | ||
import dydxViews | ||
import PlatformParticles | ||
import RoutingKit | ||
import ParticlesKit | ||
import PlatformUI | ||
|
||
public class dydxTargetLeverageViewBuilder: NSObject, ObjectBuilderProtocol { | ||
public func build<T>() -> T? { | ||
let presenter = dydxTargetLeverageViewPresenter() | ||
let view = presenter.viewModel?.createView() ?? PlatformViewModel().createView() | ||
return dydxTargetLeverageViewController(presenter: presenter, view: view, configuration: .default) as? T | ||
// return HostingViewController(presenter: presenter, view: view) as? T | ||
} | ||
} | ||
|
||
private class dydxTargetLeverageViewController: HostingViewController<PlatformView, dydxTargetLeverageViewModel> { | ||
override public func arrive(to request: RoutingRequest?, animated: Bool) -> Bool { | ||
if request?.path == "/trade/target_leverage" { | ||
return true | ||
} | ||
return false | ||
} | ||
} | ||
|
||
private protocol dydxTargetLeverageViewPresenterProtocol: HostedViewPresenterProtocol { | ||
var viewModel: dydxTargetLeverageViewModel? { get } | ||
} | ||
|
||
private class dydxTargetLeverageViewPresenter: HostedViewPresenter<dydxTargetLeverageViewModel>, dydxTargetLeverageViewPresenterProtocol { | ||
override init() { | ||
super.init() | ||
|
||
viewModel = dydxTargetLeverageViewModel() | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
.../_v4/Trade/TradeInput/Components/TradeInputFields/dydxTradeInputMarginViewPresenter.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// dydxTradeInputMarginViewPresenter.swift | ||
// dydxPresenters | ||
// | ||
// Created by Rui Huang on 07/05/2024. | ||
// | ||
|
||
import Utilities | ||
import dydxViews | ||
import PlatformParticles | ||
import RoutingKit | ||
import ParticlesKit | ||
import PlatformUI | ||
|
||
protocol dydxTradeInputMarginViewPresenterProtocol: HostedViewPresenterProtocol { | ||
var viewModel: dydxTradeInputMarginViewModel? { get } | ||
} | ||
|
||
class dydxTradeInputMarginViewPresenter: HostedViewPresenter<dydxTradeInputMarginViewModel>, dydxTradeInputMarginViewPresenterProtocol { | ||
override init() { | ||
super.init() | ||
|
||
viewModel = dydxTradeInputMarginViewModel() | ||
} | ||
|
||
override func start() { | ||
super.start() | ||
|
||
// TODO: Fetch from Abacus | ||
viewModel?.marginMode = DataLocalizer.localize(path: "APP.GENERAL.ISOLATED") | ||
viewModel?.marginLeverage = "2x" | ||
|
||
viewModel?.marginModeAction = { | ||
Router.shared?.navigate(to: RoutingRequest(path: "/trade/margin_type"), animated: true, completion: nil) | ||
} | ||
viewModel?.marginLeverageAction = { | ||
Router.shared?.navigate(to: RoutingRequest(path: "/trade/target_leverage"), animated: true, completion: nil) | ||
} | ||
} | ||
} |
This file contains 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
Oops, something went wrong.