-
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.
- Loading branch information
Showing
5 changed files
with
77 additions
and
175 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
39 changes: 0 additions & 39 deletions
39
dydx/dydxPresenters/dydxPresenters/_v4/Alerts/Components/dydxAlertsViewPresenter.swift
This file was deleted.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
dydx/dydxPresenters/dydxPresenters/_v4/Alerts/dydxAlertsViewBuilder.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 @@ | ||
// | ||
// dydxAlertsViewBuilder.swift | ||
// dydxUI | ||
// | ||
// Created by Michael Maguire on 9/17/24. | ||
// Copyright © 2024 dYdX Trading Inc. All rights reserved. | ||
// | ||
|
||
import Utilities | ||
import dydxViews | ||
import PlatformParticles | ||
import RoutingKit | ||
import ParticlesKit | ||
import PlatformUI | ||
|
||
public class dydxAlertsViewBuilder: NSObject, ObjectBuilderProtocol { | ||
public func build<T>() -> T? { | ||
let presenter = dydxAlertsViewBuilderPresenter() | ||
let view = presenter.viewModel?.createView() ?? PlatformViewModel().createView() | ||
return dydxAlertsViewController(presenter: presenter, view: view, configuration: .default) as? T | ||
} | ||
} | ||
|
||
private class dydxAlertsViewController: HostingViewController<PlatformView, dydxAlertsViewModel> { | ||
override public func arrive(to request: RoutingRequest?, animated: Bool) -> Bool { | ||
if request?.path == "/alerts" { | ||
return true | ||
} | ||
return false | ||
} | ||
} | ||
|
||
private protocol dydxAlertsViewBuilderPresenterProtocol: HostedViewPresenterProtocol { | ||
var viewModel: dydxAlertsViewModel? { get } | ||
} | ||
|
||
private class dydxAlertsViewBuilderPresenter: HostedViewPresenter<dydxAlertsViewModel>, dydxAlertsViewBuilderPresenterProtocol { | ||
private let alertsProvider = dydxAlertsProvider.shared | ||
|
||
override init() { | ||
super.init() | ||
|
||
viewModel = dydxAlertsViewModel() | ||
|
||
viewModel?.listViewModel.contentChanged = { [weak self] in | ||
self?.viewModel?.objectWillChange.send() | ||
} | ||
|
||
viewModel?.backAction = { | ||
Router.shared?.navigate(to: RoutingRequest(path: "/action/dismiss"), animated: true, completion: nil) | ||
} | ||
} | ||
|
||
override func start() { | ||
super.start() | ||
|
||
alertsProvider.items | ||
.sink { [weak self] viewModels in | ||
self?.viewModel?.listViewModel.items = viewModels | ||
} | ||
.store(in: &subscriptions) | ||
} | ||
} |
120 changes: 0 additions & 120 deletions
120
dydx/dydxPresenters/dydxPresenters/_v4/dydxAlertsViewBuilder.swift
This file was deleted.
Oops, something went wrong.
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