From 4cdef502e9f31996a84e7f95eabe0d0af1e292f1 Mon Sep 17 00:00:00 2001 From: Bryan Montz Date: Thu, 16 Feb 2023 06:12:16 -0800 Subject: [PATCH] profile: copy button polish - Updated checkmark icon to SF Symbols - Updated copy icon to one from SF Symbols Changelog-Changed: Polished profile key copy buttons, added animation Closes: #619 --- .../Profile/ic-copy.imageset/Contents.json | 21 --------- .../Profile/ic-copy.imageset/ic-copy.png | Bin 354 -> 0 bytes .../ic-tick.imageset/Contents.json | 21 --------- .../ic-tick.imageset/ic-tick.png | Bin 671 -> 0 bytes damus/Views/ProfileView.swift | 40 ++++++++++-------- 5 files changed, 22 insertions(+), 60 deletions(-) delete mode 100644 damus/Assets.xcassets/Profile/ic-copy.imageset/Contents.json delete mode 100644 damus/Assets.xcassets/Profile/ic-copy.imageset/ic-copy.png delete mode 100644 damus/Assets.xcassets/ic-tick.imageset/Contents.json delete mode 100644 damus/Assets.xcassets/ic-tick.imageset/ic-tick.png diff --git a/damus/Assets.xcassets/Profile/ic-copy.imageset/Contents.json b/damus/Assets.xcassets/Profile/ic-copy.imageset/Contents.json deleted file mode 100644 index 9d64bae7..00000000 --- a/damus/Assets.xcassets/Profile/ic-copy.imageset/Contents.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "images" : [ - { - "filename" : "ic-copy.png", - "idiom" : "universal", - "scale" : "1x" - }, - { - "idiom" : "universal", - "scale" : "2x" - }, - { - "idiom" : "universal", - "scale" : "3x" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/damus/Assets.xcassets/Profile/ic-copy.imageset/ic-copy.png b/damus/Assets.xcassets/Profile/ic-copy.imageset/ic-copy.png deleted file mode 100644 index ef8c1aca25b234ba78a87424d24c15d0e35139d6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 354 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VXMsm#F#`j)FbFd;%$g$s6l5$8 za(7}_cTVOdki(Mh=Xf^@O$H*Z=ULecSnfE?zv?32 z`DTH%gn0qWT!*=i9`e3_I+IVZSv8nXb>r07*6?FNywjyE@jK7%40v!|@otmAZ^g}X zTu&YSY{h&3{(Od)HrrZH$|T&Lu`4f~RoF``>9GR)(;xrd&3Uf4F0RGs-SZV^u3TK~ zK5gx+vb7ZldRFGfN6))nYoe9sASiU*%YRp%y^E{PU!hiwGt%bg)@j`m4$JcrixhwK zLZLl;`7+_oCoMD0150Pr**?pjdt#PC^_%tS8i&7DUDw`pGQ?)?!#N#djs+Qq4%iz1 yRsUL2%X+X(MYVVF!k0_Mr`}As5cf!bCu4Gbb=bXIHvPaLVDNPHb6Mw<&;$VJB94my diff --git a/damus/Assets.xcassets/ic-tick.imageset/Contents.json b/damus/Assets.xcassets/ic-tick.imageset/Contents.json deleted file mode 100644 index 30f153b0..00000000 --- a/damus/Assets.xcassets/ic-tick.imageset/Contents.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "images" : [ - { - "filename" : "ic-tick.png", - "idiom" : "universal", - "scale" : "1x" - }, - { - "idiom" : "universal", - "scale" : "2x" - }, - { - "idiom" : "universal", - "scale" : "3x" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/damus/Assets.xcassets/ic-tick.imageset/ic-tick.png b/damus/Assets.xcassets/ic-tick.imageset/ic-tick.png deleted file mode 100644 index 37bc751d46d46a6df8f4a69bc7b1fc3e2453fe0c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 671 zcmV;Q0$}}#P)+n|Y3t`Mz*Xc6sU3JSkA37=dZC5ZzJ zNB$rExOm??q*vJIVQ?cPUTMLHMzh1^S6KMtt^i+t1z!4J?;Ef3yhu%BSbRpuo@zkW z!qLg;!pb-t1+Dd(^HoMzsv9A6%JT1B!ANY31SX|>iZ^$8AV#VMe0jpu+i(OI*@*x4 zp1*!?B(p3S)*I{fRNYf#d0NQJ#4ydQP;*`ouXPhN=0*0O1xx$7+L_*^7xhlevPs^& zDC1qgn52rw#OOh^yq-PK#Yj0&Wxx)Z;o3a5d}kh*2kNBblnV-Oy#(fbH84?9SfE>P z3e*;5J5hfNw2@5d1+z;rQR>Ae*2pLg^r>Tx+q9>t2Dt2?Jo<0+p))AN=eXKvA5aGd zwNVY|u4Ife2O>A<;FLDxS^2^_tqR>ezo=b5PR*9Uo?*7Z`1V>vS(F9KNm6==1tXRU zK083rAE++v&-8>Tux0XzoQN*P0GtKt1n)uVf#ST*{|DJfC_`&kPb&Zb002ovPDHLk FV1hsGCqMuI diff --git a/damus/Views/ProfileView.swift b/damus/Views/ProfileView.swift index 1be8b605..b35054c7 100644 --- a/damus/Views/ProfileView.swift +++ b/damus/Views/ProfileView.swift @@ -463,22 +463,30 @@ struct KeyView: View { colorScheme == .light ? Color("DamusBlack") : Color("DamusWhite") } + private func copyPubkey(_ pubkey: String) { + UIPasteboard.general.string = pubkey + UIImpactFeedbackGenerator(style: .medium).impactOccurred() + withAnimation { + isCopied = true + DispatchQueue.main.asyncAfter(deadline: .now() + 3) { + withAnimation { + isCopied = false + } + } + } + } + var body: some View { let bech32 = bech32_pubkey(pubkey) ?? pubkey HStack { - RoundedRectangle(cornerRadius: 24) - .frame(width: 275, height:22) + RoundedRectangle(cornerRadius: 11) + .frame(height: 22) .foregroundColor(fillColor()) .overlay( HStack { Button { - UIPasteboard.general.string = bech32 - UIImpactFeedbackGenerator(style: .medium).impactOccurred() - isCopied = true - DispatchQueue.main.asyncAfter(deadline: .now() + 3) { - isCopied = false - } + copyPubkey(bech32) } label: { Label(NSLocalizedString("Public Key", comment: "Label indicating that the text is a user's public account key."), systemImage: "key.fill") .font(.custom("key", size: 12.0)) @@ -490,23 +498,18 @@ struct KeyView: View { Text(abbrev_pubkey(bech32, amount: 16)) .font(.footnote) .foregroundColor(keyColor()) - .offset(x:-3) // Not sure why this is needed. } ) if isCopied != true { Button { - UIPasteboard.general.string = bech32 - UIImpactFeedbackGenerator(style: .medium).impactOccurred() - isCopied = true - DispatchQueue.main.asyncAfter(deadline: .now() + 3) { - isCopied = false - } + copyPubkey(bech32) } label: { Label { Text("Public key", comment: "Label indicating that the text is a user's public account key.") } icon: { - Image("ic-copy") + Image(systemName: "square.on.square.dashed") .contentShape(Rectangle()) + .foregroundColor(.gray) .frame(width: 20, height: 20) } .labelStyle(IconOnlyLabelStyle()) @@ -514,12 +517,13 @@ struct KeyView: View { } } else { HStack { - Image("ic-tick") + Image(systemName: "checkmark.circle") .frame(width: 20, height: 20) Text(NSLocalizedString("Copied", comment: "Label indicating that a user's key was copied.")) .font(.footnote) - .foregroundColor(Color("DamusGreen")) + .layoutPriority(1) } + .foregroundColor(Color("DamusGreen")) } } }