Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRCL-3098 : Add transfer entry point to profile page #16

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
75d5a4f
update profile buttons row to deposit/withdraw/transfer
mike-dydx Nov 8, 2023
91ff657
color the connect button purple
mike-dydx Nov 9, 2023
6e8a8ef
show settings and help buttons
mike-dydx Nov 10, 2023
3b81653
add switch wallet button
mike-dydx Nov 10, 2023
f35eba3
hide switch wallet button when no wallet connected
mike-dydx Nov 10, 2023
b4c1e4c
move export secret and etherscan lookup to wallet connection screen
mike-dydx Nov 27, 2023
b97d858
add copy and ehterscan buttons to profile
mike-dydx Nov 27, 2023
fa6cb3e
add source address receipt area
mike-dydx Nov 28, 2023
cc44ed2
fix button colors
mike-dydx Nov 28, 2023
968c498
clean up
mike-dydx Nov 28, 2023
96755a3
clean up
mike-dydx Nov 28, 2023
07f99c1
change visibility else case
mike-dydx Nov 28, 2023
d77d12d
flip bool
mike-dydx Nov 28, 2023
3932f40
update profile buttons row to deposit/withdraw/transfer
mike-dydx Nov 8, 2023
f223ac4
color the connect button purple
mike-dydx Nov 9, 2023
4d7b150
show settings and help buttons
mike-dydx Nov 10, 2023
965c56d
add switch wallet button
mike-dydx Nov 10, 2023
99b91ff
hide switch wallet button when no wallet connected
mike-dydx Nov 10, 2023
ab36544
move export secret and etherscan lookup to wallet connection screen
mike-dydx Nov 27, 2023
58fec6d
add copy and ehterscan buttons to profile
mike-dydx Nov 27, 2023
9e0f638
add source address receipt area
mike-dydx Nov 28, 2023
99e1510
fix button colors
mike-dydx Nov 28, 2023
4926a0f
clean up
mike-dydx Nov 28, 2023
79ac4f6
clean up
mike-dydx Nov 28, 2023
e279c30
change visibility else case
mike-dydx Nov 28, 2023
c77d738
flip bool
mike-dydx Nov 28, 2023
5e3a54b
Merge branch 'mike/trcl-3098-add-transfer-entry-point-to-profile-page…
mike-dydx Nov 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions PlatformUI/PlatformUI/DesignSystem/Theme/ThemeViewModifiers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public extension View {
}

func themeColor(background: ThemeColor.SemanticColor) -> some View {
modifier(SemanticColorModifier(layerColor: background))
modifier(BackgroundColorModifier(layerColor: background))
}

func themeGradient(background: ThemeColor.SemanticColor, gradientColor: Color) -> some View {
Expand All @@ -31,7 +31,7 @@ public extension Text {
}
}

struct TextColorModifier: ViewModifier {
private struct TextColorModifier: ViewModifier {
@EnvironmentObject var themeSettings: ThemeSettings

let textColor: ThemeColor.SemanticColor
Expand All @@ -42,7 +42,7 @@ struct TextColorModifier: ViewModifier {
}
}

struct SemanticColorModifier: ViewModifier {
private struct BackgroundColorModifier: ViewModifier {
@EnvironmentObject var themeSettings: ThemeSettings

let layerColor: ThemeColor.SemanticColor
Expand All @@ -53,7 +53,7 @@ struct SemanticColorModifier: ViewModifier {
}
}

struct GradientColorModifier: ViewModifier {
private struct GradientColorModifier: ViewModifier {
@EnvironmentObject var themeSettings: ThemeSettings

let layerColor: ThemeColor.SemanticColor
Expand Down Expand Up @@ -268,8 +268,43 @@ public extension View {
func border(borderWidth: CGFloat = 1, cornerRadius: CGFloat = 0, borderColor: Color? = ThemeColor.SemanticColor.layer5.color) -> some View {
modifier(BorderModifier(cornerRadius: cornerRadius, borderWidth: borderWidth, borderColor: borderColor))
}

func borderAndClip(style: BorderAndClipStyle, borderColor: ThemeColor.SemanticColor, lineWidth: CGFloat) -> some View {
modifier(BorderAndClipModifier(style: style, borderColor: borderColor, lineWidth: lineWidth))
}
}

/// The clip shape/style
public enum BorderAndClipStyle {
/// A rectangular shape with rounded corners with specified corner radius, aligned inside the frame of the view containing it.
case cornerRadius(CGFloat)
/// A capsule shape is equivalent to a rounded rectangle where the corner radius is chosen as half the length of the rectangle’s smallest edge.
case capsule
}

private struct BorderAndClipModifier: ViewModifier {
let style: BorderAndClipStyle
let borderColor: ThemeColor.SemanticColor
let lineWidth: CGFloat

func body(content: Content) -> some View {
switch style {
case .cornerRadius(let cornerRadius):
content
.clipShape(RoundedRectangle(cornerSize: .init(width: cornerRadius, height: cornerRadius)))
.overlay(RoundedRectangle(cornerRadius: cornerRadius)
.strokeBorder(borderColor.color, lineWidth: lineWidth))

case .capsule:
content
.clipShape(Capsule())
.overlay(Capsule()
.strokeBorder(borderColor.color, lineWidth: lineWidth))
}
}
}


private struct BorderModifier: ViewModifier {
var cornerRadius: CGFloat = .infinity
var borderWidth: CGFloat = 1
Expand Down
16 changes: 4 additions & 12 deletions dydx/dydxPresenters/dydxPresenters.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -131,6 +130,7 @@
2741E3702A68787A000FA190 /* settings_direction_color_preference.json in Resources */ = {isa = PBXBuildFile; fileRef = 2741E3632A68787A000FA190 /* settings_direction_color_preference.json */; };
2741E3732A689740000FA190 /* dydxDirectionColorPreferenceViewBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2741E3722A689740000FA190 /* dydxDirectionColorPreferenceViewBuilder.swift */; };
276908FF2AAFB22F0075B2D6 /* dydxPortfolioTransfersViewPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 276908FE2AAFB22F0075B2D6 /* dydxPortfolioTransfersViewPresenter.swift */; };
27C027532AFD761300E92CCB /* dydxSettingsHelpRowViewPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27C027522AFD761300E92CCB /* dydxSettingsHelpRowViewPresenter.swift */; };
27DB2EA32AC1E7B20047BC39 /* dydxTradeRestrictedViewPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27DB2EA22AC1E7B20047BC39 /* dydxTradeRestrictedViewPresenter.swift */; };
314BBDE9F332ECA910BC414E /* Pods_iOS_dydxPresenters.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F1551C00FFF41C29CFC5BD94 /* Pods_iOS_dydxPresenters.framework */; };
6448800B2AA248340068DD87 /* dydxAlertsWorker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64487FFE2AA248340068DD87 /* dydxAlertsWorker.swift */; };
Expand Down Expand Up @@ -415,7 +415,6 @@
02860A9329C15E760079E644 /* dydxOnboardScanViewBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = dydxOnboardScanViewBuilder.swift; sourceTree = "<group>"; };
028AC6A32A5E564B00FE0891 /* dydxTransferAlertsProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxTransferAlertsProvider.swift; sourceTree = "<group>"; };
028DB33F2A05893D0090BE58 /* dydxProfileHeaderViewPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxProfileHeaderViewPresenter.swift; sourceTree = "<group>"; };
028DB3552A05BF630090BE58 /* dydxAddressDetailsViewBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxAddressDetailsViewBuilder.swift; sourceTree = "<group>"; };
028FB3EB2AD642B30013136C /* dydxTokenConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxTokenConstants.swift; sourceTree = "<group>"; };
0295392229FB256E009026E3 /* dydxThemeViewBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxThemeViewBuilder.swift; sourceTree = "<group>"; };
0295392629FB28B7009026E3 /* settings_theme.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = settings_theme.json; sourceTree = "<group>"; };
Expand Down Expand Up @@ -469,6 +468,7 @@
2741E3632A68787A000FA190 /* settings_direction_color_preference.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = settings_direction_color_preference.json; sourceTree = "<group>"; };
2741E3722A689740000FA190 /* dydxDirectionColorPreferenceViewBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = dydxDirectionColorPreferenceViewBuilder.swift; sourceTree = "<group>"; };
276908FE2AAFB22F0075B2D6 /* dydxPortfolioTransfersViewPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxPortfolioTransfersViewPresenter.swift; sourceTree = "<group>"; };
27C027522AFD761300E92CCB /* dydxSettingsHelpRowViewPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxSettingsHelpRowViewPresenter.swift; sourceTree = "<group>"; };
27DB2EA22AC1E7B20047BC39 /* dydxTradeRestrictedViewPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxTradeRestrictedViewPresenter.swift; sourceTree = "<group>"; };
64487FFE2AA248340068DD87 /* dydxAlertsWorker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = dydxAlertsWorker.swift; sourceTree = "<group>"; };
645299E22AE86FB1000810E6 /* dydxUpdateViewPresenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = dydxUpdateViewPresenter.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -852,7 +852,6 @@
023848C32A9E6BCD00B1A673 /* SystemStatus */,
2741E3712A689702000FA190 /* DirectionColorPreference */,
02F958152A1BDEEF00828F9A /* KeyExport */,
028DB34D2A05BE650090BE58 /* AddressDetails */,
02E90C4C29D62702004E2311 /* FeatureFlags */,
02FAFA4E29D4E079001A0903 /* Debug */,
027E1EEA29CA27B00098666F /* Settings */,
Expand All @@ -873,6 +872,7 @@
028DB33F2A05893D0090BE58 /* dydxProfileHeaderViewPresenter.swift */,
02F95A8D2A1D6AAD00828F9A /* dydxProfileHistoryViewPresenter.swift */,
02F6E71E2A8293270018F00C /* dydxProfileFeesViewPresenter.swift */,
27C027522AFD761300E92CCB /* dydxSettingsHelpRowViewPresenter.swift */,
);
path = Components;
sourceTree = "<group>";
Expand Down Expand Up @@ -1009,14 +1009,6 @@
path = Scan;
sourceTree = "<group>";
};
028DB34D2A05BE650090BE58 /* AddressDetails */ = {
isa = PBXGroup;
children = (
028DB3552A05BF630090BE58 /* dydxAddressDetailsViewBuilder.swift */,
);
path = AddressDetails;
sourceTree = "<group>";
};
0295391529FB254C009026E3 /* Theme */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1755,10 +1747,10 @@
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 */,
27C027532AFD761300E92CCB /* dydxSettingsHelpRowViewPresenter.swift in Sources */,
02EF485629F732C600C97746 /* dydxFavoriteStore.swift in Sources */,
0208627C28F4DAC000C9D3A0 /* dydxMarketInfoPagingViewPresenter.swift in Sources */,
0238FECB2970D681002E1C1A /* SharedAccountPresenter.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,16 @@ class dydxProfileButtonsViewPresenter: HostedViewPresenter<dydxProfileButtonsVie

self.viewModel = viewModel

viewModel.settingsAction = {
Router.shared?.navigate(to: RoutingRequest(path: "/settings"), animated: true, completion: nil)
viewModel.depositAction = {
Router.shared?.navigate(to: RoutingRequest(path: "/transfer", params: ["section": TransferSection.deposit.rawValue]), animated: true, completion: nil)
}

viewModel.helpAction = {
let request = RoutingRequest(path: "/help")
Router.shared?.navigate(to: request, animated: true, completion: nil)
viewModel.withdrawAction = {
Router.shared?.navigate(to: RoutingRequest(path: "/transfer", params: ["section": TransferSection.withdrawal.rawValue]), animated: true, completion: nil)
}

viewModel.walletAction = { [weak self] in
guard let self = self else {
return
}
AbacusStateManager.shared.state.walletState
.prefix(1)
.sink { walletState in
if walletState.wallets.count > 0 {
Router.shared?.navigate(to: RoutingRequest(path: "/wallets"), animated: true, completion: nil)
} else {
Router.shared?.navigate(to: RoutingRequest(path: "/onboard/wallets"), animated: true, completion: nil)
}
}
.store(in: &self.subscriptions)
viewModel.transferAction = {
Router.shared?.navigate(to: RoutingRequest(path: "/transfer", params: ["section": TransferSection.transferOut.rawValue]), animated: true, completion: nil)
}

viewModel.signOutAction = { [weak self] in
Expand Down Expand Up @@ -76,11 +63,5 @@ class dydxProfileButtonsViewPresenter: HostedViewPresenter<dydxProfileButtonsVie
self?.viewModel?.onboarded = onboarded
}
.store(in: &subscriptions)

AbacusStateManager.shared.state.currentWallet
.sink { [weak self] wallet in
self?.viewModel?.walletImageUrl = wallet?.imageUrl
}
.store(in: &subscriptions)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Abacus
import dydxStateManager
import dydxViews
import RoutingKit
import Utilities

protocol dydxProfileHeaderViewPresenterProtocol: HostedViewPresenterProtocol {
var viewModel: dydxProfileHeaderViewModel? { get }
Expand All @@ -23,8 +24,20 @@ class dydxProfileHeaderViewPresenter: HostedViewPresenter<dydxProfileHeaderViewM
if let chainLogo = AbacusStateManager.shared.environment?.chainLogo {
self.viewModel?.dydxChainLogoUrl = URL(string: chainLogo)
}
self.viewModel?.onTapAction = {
Router.shared?.navigate(to: RoutingRequest(path: "/my-profile/address"), animated: true, completion: nil)
self.viewModel?.manageWalletAction = { [weak self] in
guard let self = self else {
return
}
AbacusStateManager.shared.state.walletState
.prefix(1)
.sink { walletState in
if walletState.wallets.count > 0 {
Router.shared?.navigate(to: RoutingRequest(path: "/wallets"), animated: true, completion: nil)
} else {
Router.shared?.navigate(to: RoutingRequest(path: "/onboard/wallets"), animated: true, completion: nil)
}
}
.store(in: &self.subscriptions)
}
}

Expand All @@ -34,6 +47,24 @@ class dydxProfileHeaderViewPresenter: HostedViewPresenter<dydxProfileHeaderViewM
AbacusStateManager.shared.state.walletState
.sink { [weak self] walletState in
self?.viewModel?.dydxAddress = walletState.currentWallet?.cosmoAddress
self?.viewModel?.sourceAddress = walletState.currentWallet?.ethereumAddress
if let cosmoAddress = walletState.currentWallet?.cosmoAddress {
self?.viewModel?.copyAction = {
UIPasteboard.general.string = cosmoAddress
}
} else {
self?.viewModel?.copyAction = nil
}
if let ethereumAddress = walletState.currentWallet?.ethereumAddress {
self?.viewModel?.openInEtherscanAction = {
let urlString = "https://etherscan.io/address/\(ethereumAddress)"
if let url = URL(string: urlString), URLHandler.shared?.canOpenURL(url) ?? false {
URLHandler.shared?.open(url, completionHandler: nil)
}
}
} else {
self?.viewModel?.openInEtherscanAction = nil
}
}
.store(in: &subscriptions)
}
Expand Down
Loading
Loading