-
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.
add tp/sl button and screen stub (#126)
- Loading branch information
Showing
9 changed files
with
193 additions
and
1 deletion.
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
16 changes: 16 additions & 0 deletions
16
PlatformUI/PlatformUI/Components/Extensions/Text+Ext.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,16 @@ | ||
// | ||
// Text+Ext.swift | ||
// PlatformUI | ||
// | ||
// Created by Michael Maguire on 4/1/24. | ||
// | ||
|
||
import SwiftUI | ||
import Utilities | ||
|
||
public extension Text { | ||
init(localizerPathKey: String, params: [String: String]? = nil) { | ||
self = Text(DataLocalizer.shared?.localize(path: localizerPathKey, params: params) ?? "") | ||
} | ||
} | ||
|
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
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
49 changes: 49 additions & 0 deletions
49
...resenters/dydxPresenters/_v4/TakeProfitStopLoss/dydxTakeProfitStopLossViewPresenter.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,49 @@ | ||
// | ||
// dydxTakeProfitStopLossViewPresenter.swift | ||
// dydxPresenters | ||
// | ||
// Created by Michael Maguire on 4/1/24. | ||
// | ||
|
||
import dydxStateManager | ||
import dydxViews | ||
import ParticlesKit | ||
import PlatformParticles | ||
import PlatformUI | ||
import RoutingKit | ||
import Utilities | ||
import PlatformRouting | ||
import PanModal | ||
|
||
public class dydxTakeProfitStopLossViewBuilder: NSObject, ObjectBuilderProtocol { | ||
public func build<T>() -> T? { | ||
let presenter = dydxTakeProfitStopLossViewPresenter() | ||
let view = presenter.viewModel?.createView() ?? PlatformViewModel().createView() | ||
return dydxTakeProfitStopLossViewController(presenter: presenter, view: view, configuration: .default) as? T | ||
} | ||
} | ||
|
||
private class dydxTakeProfitStopLossViewController: HostingViewController<PlatformView, dydxTakeProfitStopLossViewModel> { | ||
override public func arrive(to request: RoutingRequest?, animated: Bool) -> Bool { | ||
if request?.path == "/trade/take_proft_stop_loss", let marketId = parser.asString(request?.params?["marketId"]) { | ||
AbacusStateManager.shared.setMarket(market: marketId) | ||
return true | ||
} | ||
return false | ||
} | ||
} | ||
|
||
private protocol dydxTakeProfitStopLossViewPresenterProtocol: HostedViewPresenterProtocol { | ||
var viewModel: dydxTakeProfitStopLossViewModel? { get } | ||
} | ||
|
||
private class dydxTakeProfitStopLossViewPresenter: HostedViewPresenter<dydxTakeProfitStopLossViewModel>, dydxTakeProfitStopLossViewPresenterProtocol { | ||
|
||
override init() { | ||
let viewModel = dydxTakeProfitStopLossViewModel() | ||
|
||
super.init() | ||
|
||
self.viewModel = viewModel | ||
} | ||
} |
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
63 changes: 63 additions & 0 deletions
63
dydx/dydxViews/dydxViews/_v4/TakeProfitStopLoss/dydxTakeProfitStopLossViewModel.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,63 @@ | ||
// | ||
// dydxTakeProfitStopLossViewModel.swift | ||
// dydxViews | ||
// | ||
// Created by Michael Maguire on 4/1/24. | ||
// | ||
|
||
import PlatformUI | ||
import SwiftUI | ||
import Utilities | ||
import Introspect | ||
|
||
public class dydxTakeProfitStopLossViewModel: PlatformViewModel { | ||
|
||
public init() {} | ||
|
||
public static var previewValue: dydxTakeProfitStopLossViewModel { | ||
let vm = dydxTakeProfitStopLossViewModel() | ||
return vm | ||
} | ||
|
||
override public func createView(parentStyle: ThemeStyle = ThemeStyle.defaultStyle, styleKey: String? = nil) -> PlatformUI.PlatformView { | ||
PlatformView(viewModel: self, parentStyle: parentStyle, styleKey: styleKey) { [weak self] _ in | ||
guard let self = self else { return AnyView(PlatformView.nilView) } | ||
|
||
let view = VStack { | ||
VStack(alignment: .leading, spacing: 6) { | ||
Text(localizerPathKey: "APP.TRIGGERS_MODAL.PRICE_TRIGGERS") | ||
.themeFont(fontType: .plus, fontSize: .larger) | ||
.themeColor(foreground: .textPrimary) | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
Text(localizerPathKey: "APP.TRIGGERS_MODAL.PRICE_TRIGGERS_DESCRIPTION") | ||
.themeFont(fontType: .base, fontSize: .small) | ||
.themeColor(foreground: .textTertiary) | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
} | ||
.frame(maxWidth: .infinity) | ||
HStack(alignment: .center, spacing: 8) { | ||
Text(localizerPathKey: "APP.GENERAL.ADVANCED") | ||
Rectangle() | ||
.frame(height: 1) | ||
.themeFont(fontType: .base, fontSize: .smallest) | ||
.themeColor(background: .textTertiary) | ||
} | ||
} | ||
.padding(.top, 32) | ||
.padding([.leading, .trailing]) | ||
.padding(.bottom, max((self.safeAreaInsets?.bottom ?? 0), 16)) | ||
.themeColor(background: .layer3) | ||
.makeSheet(sheetStyle: .fitSize) | ||
|
||
// make it visible under the tabbar | ||
return AnyView(view.ignoresSafeArea(edges: [.bottom])) | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
dydxTakeProfitStopLossViewModel.previewValue | ||
.createView() | ||
.previewLayout(.fixed(width: 375, height: 667)) | ||
.previewDisplayName("dydxTakeProfitStopLossViewModel") | ||
} |