From 608ed194e0a67429d23cfa8ab34f0f155aa3d6e8 Mon Sep 17 00:00:00 2001 From: mike-dydx Date: Tue, 28 Nov 2023 14:21:09 -0500 Subject: [PATCH] clean up --- .../Theme/ThemeViewModifiers.swift | 11 -- .../dydxPresenters.xcodeproj/project.pbxproj | 12 -- .../_Features/routing_swiftui.json | 4 - .../dydxAddressDetailsViewBuilder.swift | 74 ------- .../dydxViews.xcodeproj/project.pbxproj | 12 -- .../dydxAddressDetailsView.swift | 184 ------------------ 6 files changed, 297 deletions(-) delete mode 100644 dydx/dydxPresenters/dydxPresenters/_v4/Profile/AddressDetails/dydxAddressDetailsViewBuilder.swift delete mode 100644 dydx/dydxViews/dydxViews/_v4/Profile/AddressDetails/dydxAddressDetailsView.swift diff --git a/PlatformUI/PlatformUI/DesignSystem/Theme/ThemeViewModifiers.swift b/PlatformUI/PlatformUI/DesignSystem/Theme/ThemeViewModifiers.swift index eef42dce6..d556e3748 100644 --- a/PlatformUI/PlatformUI/DesignSystem/Theme/ThemeViewModifiers.swift +++ b/PlatformUI/PlatformUI/DesignSystem/Theme/ThemeViewModifiers.swift @@ -53,17 +53,6 @@ private struct BackgroundColorModifier: ViewModifier { } } -private struct BorderColorModifier: ViewModifier { - @EnvironmentObject var themeSettings: ThemeSettings - - let layerColor: ThemeColor.SemanticColor - - func body(content: Content) -> some View { - content - .background(themeSettings.themeConfig.themeColor.color(of: layerColor)) - } -} - private struct GradientColorModifier: ViewModifier { @EnvironmentObject var themeSettings: ThemeSettings diff --git a/dydx/dydxPresenters/dydxPresenters.xcodeproj/project.pbxproj b/dydx/dydxPresenters/dydxPresenters.xcodeproj/project.pbxproj index 503aa2cc0..d4af7aebc 100644 --- a/dydx/dydxPresenters/dydxPresenters.xcodeproj/project.pbxproj +++ b/dydx/dydxPresenters/dydxPresenters.xcodeproj/project.pbxproj @@ -77,7 +77,6 @@ 02860A9F29C15E760079E644 /* dydxOnboardScanViewBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02860A9329C15E760079E644 /* dydxOnboardScanViewBuilder.swift */; }; 028AC6A42A5E564B00FE0891 /* dydxTransferAlertsProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 028AC6A32A5E564B00FE0891 /* dydxTransferAlertsProvider.swift */; }; 028DB3402A05893D0090BE58 /* dydxProfileHeaderViewPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 028DB33F2A05893D0090BE58 /* dydxProfileHeaderViewPresenter.swift */; }; - 028DB3562A05BF630090BE58 /* dydxAddressDetailsViewBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 028DB3552A05BF630090BE58 /* dydxAddressDetailsViewBuilder.swift */; }; 028FB3EC2AD642B30013136C /* dydxTokenConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 028FB3EB2AD642B30013136C /* dydxTokenConstants.swift */; }; 0295392329FB256E009026E3 /* dydxThemeViewBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0295392229FB256E009026E3 /* dydxThemeViewBuilder.swift */; }; 0295392729FB28B7009026E3 /* settings_theme.json in Resources */ = {isa = PBXBuildFile; fileRef = 0295392629FB28B7009026E3 /* settings_theme.json */; }; @@ -416,7 +415,6 @@ 02860A9329C15E760079E644 /* dydxOnboardScanViewBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = dydxOnboardScanViewBuilder.swift; sourceTree = ""; }; 028AC6A32A5E564B00FE0891 /* dydxTransferAlertsProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxTransferAlertsProvider.swift; sourceTree = ""; }; 028DB33F2A05893D0090BE58 /* dydxProfileHeaderViewPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxProfileHeaderViewPresenter.swift; sourceTree = ""; }; - 028DB3552A05BF630090BE58 /* dydxAddressDetailsViewBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxAddressDetailsViewBuilder.swift; sourceTree = ""; }; 028FB3EB2AD642B30013136C /* dydxTokenConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxTokenConstants.swift; sourceTree = ""; }; 0295392229FB256E009026E3 /* dydxThemeViewBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxThemeViewBuilder.swift; sourceTree = ""; }; 0295392629FB28B7009026E3 /* settings_theme.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = settings_theme.json; sourceTree = ""; }; @@ -854,7 +852,6 @@ 023848C32A9E6BCD00B1A673 /* SystemStatus */, 2741E3712A689702000FA190 /* DirectionColorPreference */, 02F958152A1BDEEF00828F9A /* KeyExport */, - 028DB34D2A05BE650090BE58 /* AddressDetails */, 02E90C4C29D62702004E2311 /* FeatureFlags */, 02FAFA4E29D4E079001A0903 /* Debug */, 027E1EEA29CA27B00098666F /* Settings */, @@ -1012,14 +1009,6 @@ path = Scan; sourceTree = ""; }; - 028DB34D2A05BE650090BE58 /* AddressDetails */ = { - isa = PBXGroup; - children = ( - 028DB3552A05BF630090BE58 /* dydxAddressDetailsViewBuilder.swift */, - ); - path = AddressDetails; - sourceTree = ""; - }; 0295391529FB254C009026E3 /* Theme */ = { isa = PBXGroup; children = ( @@ -1758,7 +1747,6 @@ 0230376F28C11BE600412B72 /* dydxMarketsViewBuilder.swift in Sources */, 270BA8F32A6F278F009212EA /* dydxDebugThemeViewerBuilder.swift in Sources */, 02669B952AD87A9D00A756AA /* dydxGlobalWorkers.swift in Sources */, - 028DB3562A05BF630090BE58 /* dydxAddressDetailsViewBuilder.swift in Sources */, 027CB28729EEFF910069781A /* dydxTransferStatusViewBuilder.swift in Sources */, 0257C78E2A00485500F6160B /* SparklineDataPoint.swift in Sources */, 028DB3402A05893D0090BE58 /* dydxProfileHeaderViewPresenter.swift in Sources */, diff --git a/dydx/dydxPresenters/dydxPresenters/_Features/routing_swiftui.json b/dydx/dydxPresenters/dydxPresenters/_Features/routing_swiftui.json index 9d57d5602..e8053c750 100644 --- a/dydx/dydxPresenters/dydxPresenters/_Features/routing_swiftui.json +++ b/dydx/dydxPresenters/dydxPresenters/_Features/routing_swiftui.json @@ -152,10 +152,6 @@ "/my-profile":{ "destination":"dydxPresenters.dydxProfileViewBuilder" }, - "/my-profile/address":{ - "destination":"dydxPresenters.dydxAddressDetailsViewBuilder", - "presentation":"push" - }, "/my-profile/keyexport":{ "destination":"dydxPresenters.dydxKeyExportViewBuilder", "presentation":"prompt" diff --git a/dydx/dydxPresenters/dydxPresenters/_v4/Profile/AddressDetails/dydxAddressDetailsViewBuilder.swift b/dydx/dydxPresenters/dydxPresenters/_v4/Profile/AddressDetails/dydxAddressDetailsViewBuilder.swift deleted file mode 100644 index e1a588ffe..000000000 --- a/dydx/dydxPresenters/dydxPresenters/_v4/Profile/AddressDetails/dydxAddressDetailsViewBuilder.swift +++ /dev/null @@ -1,74 +0,0 @@ -// -// dydxAddressDetailsViewBuilder.swift -// dydxPresenters -// -// Created by Rui Huang on 5/5/23. -// - -import Utilities -import dydxViews -import PlatformParticles -import RoutingKit -import ParticlesKit -import PlatformUI -import Abacus -import dydxStateManager -import Cartera - -public class dydxAddressDetailsViewBuilder: NSObject, ObjectBuilderProtocol { - public func build() -> T? { - let presenter = dydxAddressDetailsViewPresenter() - let view = presenter.viewModel?.createView() ?? PlatformViewModel().createView() - return dydxAddressDetailsViewController(presenter: presenter, view: view, configuration: .default) as? T - } -} - -private class dydxAddressDetailsViewController: HostingViewController { - override public func arrive(to request: RoutingRequest?, animated: Bool) -> Bool { - if request?.path == "/my-profile/address" { - return true - } - return false - } -} - -private protocol dydxAddressDetailsViewPresenterProtocol: HostedViewPresenterProtocol { - var viewModel: dydxAddressDetailsViewModel? { get } -} - -private class dydxAddressDetailsViewPresenter: HostedViewPresenter, dydxAddressDetailsViewPresenterProtocol { - override init() { - super.init() - - viewModel = dydxAddressDetailsViewModel() - if let chainLogo = AbacusStateManager.shared.environment?.chainLogo { - viewModel?.dydxChainLogoUrl = URL(string: chainLogo) - } - } - - override func start() { - super.start() - - AbacusStateManager.shared.state.walletState - .sink { [weak self] walletState in - self?.viewModel?.dydxAddress = walletState.currentWallet?.cosmoAddress - self?.viewModel?.sourceAddress = walletState.currentWallet?.ethereumAddress - - self?.viewModel?.sourceWalletImageUrl = walletState.currentWallet?.imageUrl - - self?.viewModel?.copyAddressAction = { - guard let cosmoAddress = walletState.currentWallet?.cosmoAddress else { - return - } - let pasteboard = UIPasteboard.general - pasteboard.string = cosmoAddress - - ErrorInfo.shared?.info(title: nil, - message: DataLocalizer.localize(path: "APP.V4.DYDX_ADDRESS_COPIED"), - type: .success, - error: nil, time: 3) - } - } - .store(in: &subscriptions) - } -} diff --git a/dydx/dydxViews/dydxViews.xcodeproj/project.pbxproj b/dydx/dydxViews/dydxViews.xcodeproj/project.pbxproj index e42bd2e0b..e76cdfe4a 100644 --- a/dydx/dydxViews/dydxViews.xcodeproj/project.pbxproj +++ b/dydx/dydxViews/dydxViews.xcodeproj/project.pbxproj @@ -105,7 +105,6 @@ 0284201629AD71B600C0E7CC /* Enums.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0284201529AD71B600C0E7CC /* Enums.swift */; }; 02860A9129C15E670079E644 /* dydxOnboardScanView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02860A8429C15E670079E644 /* dydxOnboardScanView.swift */; }; 028DB33E2A0589270090BE58 /* dydxProfileHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 028DB33D2A0589270090BE58 /* dydxProfileHeaderView.swift */; }; - 028DB3542A05BF530090BE58 /* dydxAddressDetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 028DB3532A05BF530090BE58 /* dydxAddressDetailsView.swift */; }; 02934CE5290067F1005DB99C /* SideChange.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02934CE4290067F1005DB99C /* SideChange.swift */; }; 0297A0F72A6109E500619181 /* ProgressStepView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0297A0F62A6109E500619181 /* ProgressStepView.swift */; }; 029CBE6C28F5F3F600259C1D /* dydxMarketFundingChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 029CBE6B28F5F3F600259C1D /* dydxMarketFundingChartView.swift */; }; @@ -440,7 +439,6 @@ 0284201529AD71B600C0E7CC /* Enums.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Enums.swift; sourceTree = ""; }; 02860A8429C15E670079E644 /* dydxOnboardScanView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = dydxOnboardScanView.swift; sourceTree = ""; }; 028DB33D2A0589270090BE58 /* dydxProfileHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxProfileHeaderView.swift; sourceTree = ""; }; - 028DB3532A05BF530090BE58 /* dydxAddressDetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxAddressDetailsView.swift; sourceTree = ""; }; 02934CE4290067F1005DB99C /* SideChange.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SideChange.swift; sourceTree = ""; }; 0297A0F62A6109E500619181 /* ProgressStepView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressStepView.swift; sourceTree = ""; }; 029CBE6B28F5F3F600259C1D /* dydxMarketFundingChartView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxMarketFundingChartView.swift; sourceTree = ""; }; @@ -1004,7 +1002,6 @@ 024FEB622ACB75C00087A55E /* FeesStructure */, 270BA8C12A6F145B009212EA /* Settings */, 02F958062A1BDED300828F9A /* KeyExport */, - 028DB3502A05BEA30090BE58 /* AddressDetails */, 0253177C29C126C800D6CC9B /* TradingNetwork */, 0258BA2429929D050098E1BE /* Components */, 0258BA1C2992949D0098E1BE /* dydxProfileView.swift */, @@ -1131,14 +1128,6 @@ path = Components; sourceTree = ""; }; - 028DB3502A05BEA30090BE58 /* AddressDetails */ = { - isa = PBXGroup; - children = ( - 028DB3532A05BF530090BE58 /* dydxAddressDetailsView.swift */, - ); - path = AddressDetails; - sourceTree = ""; - }; 029CBE5E28F5F3C800259C1D /* Funding */ = { isa = PBXGroup; children = ( @@ -1894,7 +1883,6 @@ 02678F5B2965DEAD00EE346B /* dydxPortfolioSectionsView.swift in Sources */, 64A4DB762966276B008D8E20 /* dydxTradeInputTriggerPriceView.swift in Sources */, 0238FEBF2970CBEF002E1C1A /* dydxMarketAccountView.swift in Sources */, - 028DB3542A05BF530090BE58 /* dydxAddressDetailsView.swift in Sources */, 02E5996128FF46B500F62F28 /* MarginUsageChange.swift in Sources */, 6453A7BB299C26DE0041A0C4 /* dydxClosePositionInputView.swift in Sources */, 02D1379D28EE452200B46941 /* UIView+SwiftUI.swift in Sources */, diff --git a/dydx/dydxViews/dydxViews/_v4/Profile/AddressDetails/dydxAddressDetailsView.swift b/dydx/dydxViews/dydxViews/_v4/Profile/AddressDetails/dydxAddressDetailsView.swift deleted file mode 100644 index c667abe11..000000000 --- a/dydx/dydxViews/dydxViews/_v4/Profile/AddressDetails/dydxAddressDetailsView.swift +++ /dev/null @@ -1,184 +0,0 @@ -// -// dydxAddressDetailsView.swift -// dydxUI -// -// Created by Rui Huang on 5/5/23. -// Copyright © 2023 dYdX Trading Inc. All rights reserved. -// - -import SwiftUI -import PlatformUI -import Utilities -import RoutingKit - -public class dydxAddressDetailsViewModel: PlatformViewModel { - @Published public var text: String? - @Published public var dydxChainLogoUrl: URL? - @Published public var dydxAddress: String? - @Published public var sourceAddress: String? - @Published public var sourceWalletImageUrl: URL? - @Published public var copyAddressAction: (() -> Void)? - @Published public var etherscanAction: (() -> Void)? - @Published public var keyExportAction: (() -> Void)? - - public init() { } - - public static var previewValue: dydxAddressDetailsViewModel { - let vm = dydxAddressDetailsViewModel() - vm.text = "Test String" - return vm - } - - public override func createView(parentStyle: ThemeStyle = ThemeStyle.defaultStyle, styleKey: String? = nil) -> PlatformView { - PlatformView(viewModel: self, parentStyle: parentStyle, styleKey: styleKey) { [weak self] style in - guard let self = self else { return AnyView(PlatformView.nilView) } - - return AnyView( - VStack(alignment: .leading, spacing: 12) { - self.createHeader(parentStyle: style) - .frame(height: 48) - .padding([.leading, .trailing]) - - self.createDydxAddressView(parentStyle: style) - - /* - TODO: source address should be different than dydx address. This if condition should evntually be removed before production launch. - When this comment was made, the "sync with desktop" flow would not bring over the source address from web app. This will have to change - before this if can be removed. - */ - if self.sourceAddress != self.dydxAddress { - self.createSourceAddressView(parentStyle: style) - } - - DividerModel().createView(parentStyle: style) - - self.createEtherscanView(parentStyle: style) - - DividerModel().createView(parentStyle: style) - - self.createKeyExportView(parentStyle: style) - - DividerModel().createView(parentStyle: style) - - Spacer() - } - .themeColor(background: .layer2) - .animation(.default) - ) - } - } - - private func createHeader(parentStyle: ThemeStyle) -> some View { - HStack { - PlatformButtonViewModel(content: PlatformIconViewModel(type: .system(name: "chevron.left"), size: CGSize(width: 16, height: 16)), type: .iconType) { - Router.shared?.navigate(to: RoutingRequest(url: "/action/dismiss"), animated: true, completion: nil) - } - .createView(parentStyle: parentStyle) - - Text(DataLocalizer.localize(path: "APP.GENERAL.PROFILE", params: nil)) - .themeFont(fontType: .bold, fontSize: .largest) - - Spacer() - } - } - - private func createDydxAddressView(parentStyle: ThemeStyle) -> some View { - let icon = PlatformIconViewModel(type: .url(url: dydxChainLogoUrl), - size: CGSize(width: 64, height: 64)) - let main = VStack(alignment: .leading, spacing: 4) { - Text(DataLocalizer.localize(path: "APP.V4.DYDX_ADDRESS")) - .themeFont(fontSize: .small) - - Text(self.dydxAddress ?? "-") - .themeColor(foreground: .textPrimary) - .lineLimit(1) - .truncationMode(.middle) - } - let copyText = Text(DataLocalizer.localize(path: "APP.GENERAL.COPY")) - .themeFont(fontSize: .small) - let trailing = PlatformButtonViewModel(content: copyText.wrappedViewModel, type: .pill, state: .secondary) { [weak self] in - self?.copyAddressAction?() - } - return PlatformTableViewCellViewModel(leading: icon, - main: main.wrappedViewModel, - trailing: trailing) - .createView(parentStyle: parentStyle) - } - - private func createSourceAddressView(parentStyle: ThemeStyle) -> some View { - let icon: PlatformViewModel - if let sourceWalletImageUrl = sourceWalletImageUrl { - icon = PlatformIconViewModel(type: .url(url: sourceWalletImageUrl), - clip: .circle(background: .layer4, spacing: 0), - size: CGSize(width: 64, height: 64)) - } else { - icon = PlatformIconViewModel(type: .system(name: "folder"), - clip: .circle(background: .layer4, spacing: 32), - size: CGSize(width: 64, height: 64)) - } - let main = VStack(alignment: .leading, spacing: 4) { - Text(DataLocalizer.localize(path: "APP.V4.SOURCE_ADDRESS")) - .themeFont(fontSize: .small) - - Text(self.sourceAddress ?? "-") - .themeColor(foreground: .textPrimary) - .lineLimit(1) - .truncationMode(.middle) - } - let trailing = PlatformView.nilViewModel - return PlatformTableViewCellViewModel(leading: icon, - main: main.wrappedViewModel, - trailing: trailing) - .createView(parentStyle: parentStyle) - } - - private func createEtherscanView(parentStyle: ThemeStyle) -> some View { - let main = Text(DataLocalizer.localize(path: "APP.HEADER.OPEN_IN_ETHERSCAN")) - let trailing = PlatformIconViewModel(type: .system(name: "chevron.right"), size: CGSize(width: 16, height: 16)) - return PlatformTableViewCellViewModel(main: main.wrappedViewModel, - trailing: trailing) - .createView(parentStyle: parentStyle) - .onTapGesture { [weak self] in - self?.etherscanAction?() - } - } - - private func createKeyExportView(parentStyle: ThemeStyle) -> some View { - let main = Text(DataLocalizer.localize(path: "APP.MNEMONIC_EXPORT.EXPORT_SECRET_PHRASE")) - let trailing = PlatformIconViewModel(type: .system(name: "chevron.right"), size: CGSize(width: 16, height: 16)) - return PlatformTableViewCellViewModel(main: main.wrappedViewModel, - trailing: trailing) - .createView(parentStyle: parentStyle) - .onTapGesture { [weak self] in - self?.keyExportAction?() - } - } -} - -#if DEBUG -struct dydxAddressDetailsView_Previews_Dark: PreviewProvider { - @StateObject static var themeSettings = ThemeSettings.shared - - static var previews: some View { - ThemeSettings.applyDarkTheme() - ThemeSettings.applyStyles() - return dydxAddressDetailsViewModel.previewValue - .createView() - // .edgesIgnoringSafeArea(.bottom) - .previewLayout(.sizeThatFits) - } -} - -struct dydxAddressDetailsView_Previews_Light: PreviewProvider { - @StateObject static var themeSettings = ThemeSettings.shared - - static var previews: some View { - ThemeSettings.applyLightTheme() - ThemeSettings.applyStyles() - return dydxAddressDetailsViewModel.previewValue - .createView() - // .edgesIgnoringSafeArea(.bottom) - .previewLayout(.sizeThatFits) - } -} -#endif