Skip to content

Commit

Permalink
add back button
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-dydx committed Sep 18, 2024
1 parent 63af734 commit 68a83f0
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 175 deletions.
14 changes: 1 addition & 13 deletions dydx/dydxPresenters/dydxPresenters.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@
27592DF92C9A54D6002FBD4B /* dydxSystemAlertsProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27592DEF2C9A54D6002FBD4B /* dydxSystemAlertsProvider.swift */; };
27592DFA2C9A54D6002FBD4B /* dydxTransferAlertsProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27592DF02C9A54D6002FBD4B /* dydxTransferAlertsProvider.swift */; };
27592DFB2C9A54D6002FBD4B /* dydxAlertsProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27592DF22C9A54D6002FBD4B /* dydxAlertsProvider.swift */; };
27592DFC2C9A54D6002FBD4B /* dydxAlertsViewPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27592DF42C9A54D6002FBD4B /* dydxAlertsViewPresenter.swift */; };
27592E052C9A57D4002FBD4B /* dydxAlertsViewBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27592E042C9A57D4002FBD4B /* dydxAlertsViewBuilder.swift */; };
276908FF2AAFB22F0075B2D6 /* dydxPortfolioTransfersViewPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 276908FE2AAFB22F0075B2D6 /* dydxPortfolioTransfersViewPresenter.swift */; };
277754352C069F8600E3E985 /* OnboardingAnalytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 277754282C069F8600E3E985 /* OnboardingAnalytics.swift */; };
Expand Down Expand Up @@ -537,7 +536,6 @@
27592DEF2C9A54D6002FBD4B /* dydxSystemAlertsProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = dydxSystemAlertsProvider.swift; sourceTree = "<group>"; };
27592DF02C9A54D6002FBD4B /* dydxTransferAlertsProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = dydxTransferAlertsProvider.swift; sourceTree = "<group>"; };
27592DF22C9A54D6002FBD4B /* dydxAlertsProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = dydxAlertsProvider.swift; sourceTree = "<group>"; };
27592DF42C9A54D6002FBD4B /* dydxAlertsViewPresenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = dydxAlertsViewPresenter.swift; sourceTree = "<group>"; };
27592E042C9A57D4002FBD4B /* dydxAlertsViewBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxAlertsViewBuilder.swift; sourceTree = "<group>"; };
276908FE2AAFB22F0075B2D6 /* dydxPortfolioTransfersViewPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxPortfolioTransfersViewPresenter.swift; sourceTree = "<group>"; };
277754282C069F8600E3E985 /* OnboardingAnalytics.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingAnalytics.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -698,7 +696,6 @@
024F487B29657DFC00E40247 /* User */,
2751D6442C59642000B36F95 /* Vault */,
0262EFA729D79EF3009889E2 /* Wallet */,
27592E042C9A57D4002FBD4B /* dydxAlertsViewBuilder.swift */,
);
path = _v4;
sourceTree = "<group>";
Expand Down Expand Up @@ -1438,19 +1435,11 @@
path = AlertProvider;
sourceTree = "<group>";
};
27592DF52C9A54D6002FBD4B /* Components */ = {
isa = PBXGroup;
children = (
27592DF42C9A54D6002FBD4B /* dydxAlertsViewPresenter.swift */,
);
path = Components;
sourceTree = "<group>";
};
27592DF72C9A54D6002FBD4B /* Alerts */ = {
isa = PBXGroup;
children = (
27592E042C9A57D4002FBD4B /* dydxAlertsViewBuilder.swift */,
27592DF32C9A54D6002FBD4B /* AlertProvider */,
27592DF52C9A54D6002FBD4B /* Components */,
);
path = Alerts;
sourceTree = "<group>";
Expand Down Expand Up @@ -2040,7 +2029,6 @@
6488BBC7296F2CD50096502F /* AbacusUtils.swift in Sources */,
277E90192B1EA3C3005CCBCB /* dydxRewardsSummaryPresenter.swift in Sources */,
026FC3E42AFACA3300C52F20 /* dydxPresentersBundleClass.swift in Sources */,
27592DFC2C9A54D6002FBD4B /* dydxAlertsViewPresenter.swift in Sources */,
025841F228EE9D7C007338D3 /* dydxMarketAssetListViewPresenter.swift in Sources */,
02F95A8E2A1D6AAD00828F9A /* dydxProfileHistoryViewPresenter.swift in Sources */,
02E90C5A29D62719004E2311 /* dydxFeatureFlagsViewBuilder.swift in Sources */,
Expand Down

This file was deleted.

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 dydx/dydxPresenters/dydxPresenters/_v4/dydxAlertsViewBuilder.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Utilities

public class dydxAlertsViewModel: PlatformViewModel {
@Published public var listViewModel: PlatformListViewModel
@Published public var backAction: (() -> Void)?

public init() {
self.listViewModel = .init()
Expand All @@ -37,9 +38,18 @@ public class dydxAlertsViewModel: PlatformViewModel {
}

private func createHeader(parentStyle: ThemeStyle) -> some View {
Text(DataLocalizer.localize(path: "APP.GENERAL.ALERTS", params: nil))
.themeFont(fontType: .plus, fontSize: .largest)
.leftAligned()
HStack(spacing: 16) {
let buttonContent = PlatformIconViewModel(type: .system(name: "chevron.left"), size: CGSize(width: 16, height: 16), templateColor: .textTertiary)
PlatformButtonViewModel(content: buttonContent, type: .iconType) {[weak self] in
self?.backAction?()
}
.createView()
.padding([.leading, .vertical], 8)
Text(DataLocalizer.localize(path: "APP.GENERAL.ALERTS", params: nil))
.themeFont(fontType: .base, fontSize: .largest)
.themeColor(foreground: .textPrimary)
Spacer()
}
}

public override func createView(parentStyle: ThemeStyle = ThemeStyle.defaultStyle, styleKey: String? = nil) -> PlatformView {
Expand Down

0 comments on commit 68a83f0

Please sign in to comment.