damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 4cdef502e9f31996a84e7f95eabe0d0af1e292f1
parent ae2e70ba7d8ebaa7bf46262e974485ab91afa4fb
Author: Bryan Montz <bryanmontz@me.com>
Date:   Thu, 16 Feb 2023 06:12:16 -0800

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

Diffstat:
Ddamus/Assets.xcassets/Profile/ic-copy.imageset/Contents.json | 21---------------------
Ddamus/Assets.xcassets/Profile/ic-copy.imageset/ic-copy.png | 0
Ddamus/Assets.xcassets/ic-tick.imageset/Contents.json | 21---------------------
Ddamus/Assets.xcassets/ic-tick.imageset/ic-tick.png | 0
Mdamus/Views/ProfileView.swift | 40++++++++++++++++++++++------------------
5 files changed, 22 insertions(+), 60 deletions(-)

diff --git a/damus/Assets.xcassets/Profile/ic-copy.imageset/Contents.json b/damus/Assets.xcassets/Profile/ic-copy.imageset/Contents.json @@ -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 Binary files differ. diff --git a/damus/Assets.xcassets/ic-tick.imageset/Contents.json b/damus/Assets.xcassets/ic-tick.imageset/Contents.json @@ -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 Binary files differ. diff --git 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")) } } }