From b51814ce63ee398fdf6f1741d52dd7b6c6ebb0ef Mon Sep 17 00:00:00 2001 From: mike-dydx Date: Mon, 27 Nov 2023 18:56:39 -0500 Subject: [PATCH] add copy and ehterscan buttons to profile --- .../dydxProfileHeaderViewPresenter.swift | 18 +++++-- .../icon_copy.imageset/Contents.json | 12 +++++ .../icon_copy.imageset/icon_copy.pdf | Bin 0 -> 4921 bytes .../Components/dydxProfileHeaderView.swift | 45 +++++++++++++----- 4 files changed, 61 insertions(+), 14 deletions(-) create mode 100644 dydx/dydxViews/dydxViews/Media.xcassets/icon_copy.imageset/Contents.json create mode 100644 dydx/dydxViews/dydxViews/Media.xcassets/icon_copy.imageset/icon_copy.pdf diff --git a/dydx/dydxPresenters/dydxPresenters/_v4/Profile/Components/dydxProfileHeaderViewPresenter.swift b/dydx/dydxPresenters/dydxPresenters/_v4/Profile/Components/dydxProfileHeaderViewPresenter.swift index cf3856e7a..91f96e9e4 100644 --- a/dydx/dydxPresenters/dydxPresenters/_v4/Profile/Components/dydxProfileHeaderViewPresenter.swift +++ b/dydx/dydxPresenters/dydxPresenters/_v4/Profile/Components/dydxProfileHeaderViewPresenter.swift @@ -10,6 +10,7 @@ import Abacus import dydxStateManager import dydxViews import RoutingKit +import Utilities protocol dydxProfileHeaderViewPresenterProtocol: HostedViewPresenterProtocol { var viewModel: dydxProfileHeaderViewModel? { get } @@ -38,9 +39,6 @@ class dydxProfileHeaderViewPresenter: HostedViewPresentervTSj>)o(=Gye6o8SlS+E$-g;|J$5~KL0l?PbJcc4F6oL6*N}vF$*9b2~i3ekC`(niReV zJ+hU8U~s$eB7Ls)4#?FEt-Q#_WY8qxBqiNYvO6p!WwaGjc-9DC za;ue?96H;O4eCLmdDk$e;$*edA=Tfe_g67u#vU}6{D0`6lztKiMG1nC(E`XeCs!BA zF^oJ)o4m>>E`v%2pKL^xgVZMapdejsj7O2-#%CSj5CxOk8VFiwCwPRa#xR~Jt2DJ^eE^dP+dpGGJ=1b21bCFi(Qx&k9=Y;AC-7eak`(g{d zD=$ODvMvd!iE}bLN0n#x4z)`Lh3abSrPB$kweTs~@DP4T!J=Vs%7RobM}=m5Ng}h@ zbd(vK)s@{+)2!07GGUeagnU819{BO6>z4znvJ^CGsl zUUx$-%>-I!CfkOw*RF#vVcoZn?Q2G{Lec4+bulzI)M%qJ$al*V5~YID)Z$tdl{DEW ztP+k7d4W9>vnQ~oAIDm1};5_O0*PP~igf&ii&jH7Nb6pS24S&7Cz1 zGjH6lkjCKigDInZ(MQ)tOPKYBAT#o1hNuEWls0!FciKjgA%rmr*<=n)7IRTIOslmOpB& zy;TZHK(92;xzhQa)WPadHfPbgpvqXcG8p_18x8D|qQc@P>zQUfo_Mu%j2N5giW!xB zEieFoi|wJxWEUOV2Tzeq)(oDoMa>w_WjjiRA#74O8W?<` zr8elAnobBMQiV}syk`ZJDBH9MYYS1slS!tX`0QbFjt(7ukiFD~;d*=9FP zXE)RqKnH_Laoeytol1NW?7n_%-!r-!piHARHYkkY;NmgtC=)eb=;bNnLw)arijwho1+!<)~K}m-`O7+L-P^Fx3=agW&q1 zU5~83-tQ0Rllbr}u1oM+{qpx8qgcILe;Or|p1kN1=>h5d^;=7#H_fHR?Dky?` z_H%dmjBoV~{}YhTQkYqy08i|&1%9_aueXO!^H0AV$B%;&ahRf}e+4dgtQUam4>tql zN$eT2;7LD*9G#%Ap^P%k-}2ZZTtRffa)Hjr_0x7d4!GP}efI|Gcz!zU#uwuG)5D7? lDXaU#;VdZNlHk?*r+-GUFPB{F Void)? + @Published public var copyAction: (() -> Void)? + @Published public var openInEtherscanAction: (() -> Void)? @Published public var manageWalletAction: (() -> Void)? public init() { } @@ -55,7 +56,32 @@ public class dydxProfileHeaderViewModel: PlatformViewModel { .truncationMode(.middle) } - let seeMoreButton = self.dydxAddress != nil ? PlatformIconViewModel(type: .system(name: "chevron.right"), size: CGSize(width: 16, height: 16)) : PlatformView.nilViewModel + let iconDim: CGFloat = 40 + let iconSpacing: CGFloat = 18 + + let copyButton: Button? = copyAction == nil ? nil : Button { [weak self] in + if let copyAction = self?.copyAction { + copyAction() + ErrorInfo.shared?.info(title: nil, + message: DataLocalizer.localize(path: "APP.V4.DYDX_ADDRESS_COPIED"), + type: .info, + error: nil, time: 3) + } + } label: { + PlatformIconViewModel(type: .asset(name: "icon_copy", bundle: .dydxView), + clip: .circle(background: .layer4, spacing: iconSpacing, borderColor: .layer6), + size: CGSize(width: iconDim, height: iconDim)) + .createView() + } + + let openInEtherscanAction: Button? = openInEtherscanAction == nil ? nil : Button { [weak self] in + self?.openInEtherscanAction?() + } label: { + PlatformIconViewModel(type: .asset(name: "icon_external_link", bundle: .dydxView), + clip: .circle(background: .layer4, spacing: iconSpacing, borderColor: .layer6), + size: CGSize(width: iconDim, height: iconDim)) + .createView() + } let content = VStack(spacing: 16) { HStack(alignment: .top) { @@ -66,16 +92,13 @@ public class dydxProfileHeaderViewModel: PlatformViewModel { manageWalletButton } } - HStack { + HStack(spacing: 0) { addressInfoView - Spacer() - seeMoreButton - .createView(parentStyle: parentStyle) - .onTapGesture { [weak self] in - if self?.dydxAddress != nil { - self?.seeMoreInfoAction?() - } - } + Spacer(minLength: 12) + HStack(spacing: 12) { + copyButton + openInEtherscanAction + } } } .padding(.all, 20)