reduce code duplication in nip05 gradients
This commit is contained in:
@@ -28,8 +28,8 @@ struct NIP05Badge: View {
|
|||||||
return use_nip05_color(pubkey: pubkey, contacts: contacts)
|
return use_nip05_color(pubkey: pubkey, contacts: contacts)
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var Seal: some View {
|
||||||
HStack(spacing: 2) {
|
Group {
|
||||||
if nip05_color {
|
if nip05_color {
|
||||||
LINEAR_GRADIENT
|
LINEAR_GRADIENT
|
||||||
.mask(Image(systemName: "checkmark.seal.fill")
|
.mask(Image(systemName: "checkmark.seal.fill")
|
||||||
@@ -40,12 +40,17 @@ struct NIP05Badge: View {
|
|||||||
.font(.footnote)
|
.font(.footnote)
|
||||||
.foregroundColor(.gray)
|
.foregroundColor(.gray)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
HStack(spacing: 2) {
|
||||||
|
Seal
|
||||||
|
|
||||||
if show_domain {
|
if show_domain {
|
||||||
if clickable {
|
if clickable {
|
||||||
if nip05_color {
|
|
||||||
Text(nip05.host)
|
Text(nip05.host)
|
||||||
.foregroundStyle(LINEAR_GRADIENT)
|
.nip05_colorized(gradient: nip05_color)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
if let nip5url = nip05.siteUrl {
|
if let nip5url = nip05.siteUrl {
|
||||||
openURL(nip5url)
|
openURL(nip5url)
|
||||||
@@ -54,17 +59,19 @@ struct NIP05Badge: View {
|
|||||||
} else {
|
} else {
|
||||||
Text(nip05.host)
|
Text(nip05.host)
|
||||||
.foregroundColor(.gray)
|
.foregroundColor(.gray)
|
||||||
.onTapGesture {
|
|
||||||
if let nip5url = nip05.siteUrl {
|
|
||||||
openURL(nip5url)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension View {
|
||||||
|
func nip05_colorized(gradient: Bool) -> some View {
|
||||||
|
if gradient {
|
||||||
|
return AnyView(self.foregroundStyle(LINEAR_GRADIENT))
|
||||||
} else {
|
} else {
|
||||||
Text(nip05.host)
|
return AnyView(self.foregroundColor(.gray))
|
||||||
.foregroundColor(.gray)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,16 +77,10 @@ struct EventActionBar: View {
|
|||||||
send_like()
|
send_like()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if bar.liked {
|
|
||||||
Text(verbatim: "\(bar.likes > 0 ? "\(bar.likes)" : "")")
|
|
||||||
.font(.footnote.weight(.medium))
|
|
||||||
.foregroundStyle(LINEAR_GRADIENT)
|
|
||||||
} else {
|
|
||||||
Text(verbatim: "\(bar.likes > 0 ? "\(bar.likes)" : "")")
|
|
||||||
.font(.footnote.weight(.medium))
|
|
||||||
.foregroundColor(Color.gray)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Text(verbatim: "\(bar.likes > 0 ? "\(bar.likes)" : "")")
|
||||||
|
.font(.footnote.weight(.medium))
|
||||||
|
.nip05_colorized(gradient: bar.liked)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let lnurl = self.lnurl {
|
if let lnurl = self.lnurl {
|
||||||
|
|||||||
Reference in New Issue
Block a user