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
This commit is contained in:
committed by
William Casarin
parent
ae2e70ba7d
commit
4cdef502e9
@@ -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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 354 B |
@@ -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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BIN
damus/Assets.xcassets/ic-tick.imageset/ic-tick.png
vendored
BIN
damus/Assets.xcassets/ic-tick.imageset/ic-tick.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 671 B |
@@ -463,22 +463,30 @@ struct KeyView: View {
|
|||||||
colorScheme == .light ? Color("DamusBlack") : Color("DamusWhite")
|
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 {
|
var body: some View {
|
||||||
let bech32 = bech32_pubkey(pubkey) ?? pubkey
|
let bech32 = bech32_pubkey(pubkey) ?? pubkey
|
||||||
|
|
||||||
HStack {
|
HStack {
|
||||||
RoundedRectangle(cornerRadius: 24)
|
RoundedRectangle(cornerRadius: 11)
|
||||||
.frame(width: 275, height:22)
|
.frame(height: 22)
|
||||||
.foregroundColor(fillColor())
|
.foregroundColor(fillColor())
|
||||||
.overlay(
|
.overlay(
|
||||||
HStack {
|
HStack {
|
||||||
Button {
|
Button {
|
||||||
UIPasteboard.general.string = bech32
|
copyPubkey(bech32)
|
||||||
UIImpactFeedbackGenerator(style: .medium).impactOccurred()
|
|
||||||
isCopied = true
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
|
|
||||||
isCopied = false
|
|
||||||
}
|
|
||||||
} label: {
|
} label: {
|
||||||
Label(NSLocalizedString("Public Key", comment: "Label indicating that the text is a user's public account key."), systemImage: "key.fill")
|
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))
|
.font(.custom("key", size: 12.0))
|
||||||
@@ -490,23 +498,18 @@ struct KeyView: View {
|
|||||||
Text(abbrev_pubkey(bech32, amount: 16))
|
Text(abbrev_pubkey(bech32, amount: 16))
|
||||||
.font(.footnote)
|
.font(.footnote)
|
||||||
.foregroundColor(keyColor())
|
.foregroundColor(keyColor())
|
||||||
.offset(x:-3) // Not sure why this is needed.
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
if isCopied != true {
|
if isCopied != true {
|
||||||
Button {
|
Button {
|
||||||
UIPasteboard.general.string = bech32
|
copyPubkey(bech32)
|
||||||
UIImpactFeedbackGenerator(style: .medium).impactOccurred()
|
|
||||||
isCopied = true
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
|
|
||||||
isCopied = false
|
|
||||||
}
|
|
||||||
} label: {
|
} label: {
|
||||||
Label {
|
Label {
|
||||||
Text("Public key", comment: "Label indicating that the text is a user's public account key.")
|
Text("Public key", comment: "Label indicating that the text is a user's public account key.")
|
||||||
} icon: {
|
} icon: {
|
||||||
Image("ic-copy")
|
Image(systemName: "square.on.square.dashed")
|
||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
|
.foregroundColor(.gray)
|
||||||
.frame(width: 20, height: 20)
|
.frame(width: 20, height: 20)
|
||||||
}
|
}
|
||||||
.labelStyle(IconOnlyLabelStyle())
|
.labelStyle(IconOnlyLabelStyle())
|
||||||
@@ -514,12 +517,13 @@ struct KeyView: View {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
HStack {
|
HStack {
|
||||||
Image("ic-tick")
|
Image(systemName: "checkmark.circle")
|
||||||
.frame(width: 20, height: 20)
|
.frame(width: 20, height: 20)
|
||||||
Text(NSLocalizedString("Copied", comment: "Label indicating that a user's key was copied."))
|
Text(NSLocalizedString("Copied", comment: "Label indicating that a user's key was copied."))
|
||||||
.font(.footnote)
|
.font(.footnote)
|
||||||
.foregroundColor(Color("DamusGreen"))
|
.layoutPriority(1)
|
||||||
}
|
}
|
||||||
|
.foregroundColor(Color("DamusGreen"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user