Colorize friend icons
No reason why nip05 badges should have all the fun Changelog-Added: Colorize friend icons
This commit is contained in:
@@ -142,6 +142,7 @@
|
|||||||
4C8D00CC29DF92DF0036AF10 /* Hashtags.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C8D00CB29DF92DF0036AF10 /* Hashtags.swift */; };
|
4C8D00CC29DF92DF0036AF10 /* Hashtags.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C8D00CB29DF92DF0036AF10 /* Hashtags.swift */; };
|
||||||
4C8D00CF29E38B950036AF10 /* nostr_bech32.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C8D00CE29E38B950036AF10 /* nostr_bech32.c */; };
|
4C8D00CF29E38B950036AF10 /* nostr_bech32.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C8D00CE29E38B950036AF10 /* nostr_bech32.c */; };
|
||||||
4C8D00D429E3C5D40036AF10 /* NIP19Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C8D00D329E3C5D40036AF10 /* NIP19Tests.swift */; };
|
4C8D00D429E3C5D40036AF10 /* NIP19Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C8D00D329E3C5D40036AF10 /* NIP19Tests.swift */; };
|
||||||
|
4C8D1A6C29F1DFC200ACDF75 /* FriendIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C8D1A6B29F1DFC200ACDF75 /* FriendIcon.swift */; };
|
||||||
4C8EC52529D1FA6C0085D9A8 /* DamusColors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C8EC52429D1FA6C0085D9A8 /* DamusColors.swift */; };
|
4C8EC52529D1FA6C0085D9A8 /* DamusColors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C8EC52429D1FA6C0085D9A8 /* DamusColors.swift */; };
|
||||||
4C90BD18283A9EE5008EE7EF /* LoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C90BD17283A9EE5008EE7EF /* LoginView.swift */; };
|
4C90BD18283A9EE5008EE7EF /* LoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C90BD17283A9EE5008EE7EF /* LoginView.swift */; };
|
||||||
4C90BD1A283AA67F008EE7EF /* Bech32.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C90BD19283AA67F008EE7EF /* Bech32.swift */; };
|
4C90BD1A283AA67F008EE7EF /* Bech32.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C90BD19283AA67F008EE7EF /* Bech32.swift */; };
|
||||||
@@ -548,6 +549,7 @@
|
|||||||
4C8D00D129E397AD0036AF10 /* block.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = block.h; sourceTree = "<group>"; };
|
4C8D00D129E397AD0036AF10 /* block.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = block.h; sourceTree = "<group>"; };
|
||||||
4C8D00D229E3C19F0036AF10 /* str_block.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = str_block.h; sourceTree = "<group>"; };
|
4C8D00D229E3C19F0036AF10 /* str_block.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = str_block.h; sourceTree = "<group>"; };
|
||||||
4C8D00D329E3C5D40036AF10 /* NIP19Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NIP19Tests.swift; sourceTree = "<group>"; };
|
4C8D00D329E3C5D40036AF10 /* NIP19Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NIP19Tests.swift; sourceTree = "<group>"; };
|
||||||
|
4C8D1A6B29F1DFC200ACDF75 /* FriendIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FriendIcon.swift; sourceTree = "<group>"; };
|
||||||
4C8EC52429D1FA6C0085D9A8 /* DamusColors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DamusColors.swift; sourceTree = "<group>"; };
|
4C8EC52429D1FA6C0085D9A8 /* DamusColors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DamusColors.swift; sourceTree = "<group>"; };
|
||||||
4C90BD17283A9EE5008EE7EF /* LoginView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginView.swift; sourceTree = "<group>"; };
|
4C90BD17283A9EE5008EE7EF /* LoginView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginView.swift; sourceTree = "<group>"; };
|
||||||
4C90BD19283AA67F008EE7EF /* Bech32.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Bech32.swift; sourceTree = "<group>"; };
|
4C90BD19283AA67F008EE7EF /* Bech32.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Bech32.swift; sourceTree = "<group>"; };
|
||||||
@@ -1054,6 +1056,7 @@
|
|||||||
4CB9D4A82992D2F400A9A7E4 /* FollowsYou.swift */,
|
4CB9D4A82992D2F400A9A7E4 /* FollowsYou.swift */,
|
||||||
4C9F18E329ABDE6D008C55EC /* MaybeAnonPfpView.swift */,
|
4C9F18E329ABDE6D008C55EC /* MaybeAnonPfpView.swift */,
|
||||||
4C9BB83329C12D9900FC4E37 /* EventProfileName.swift */,
|
4C9BB83329C12D9900FC4E37 /* EventProfileName.swift */,
|
||||||
|
4C8D1A6B29F1DFC200ACDF75 /* FriendIcon.swift */,
|
||||||
);
|
);
|
||||||
path = Profile;
|
path = Profile;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -1478,6 +1481,7 @@
|
|||||||
4C3AC79D2833036D00E1F516 /* FollowingView.swift in Sources */,
|
4C3AC79D2833036D00E1F516 /* FollowingView.swift in Sources */,
|
||||||
5CF72FC229B9142F00124A13 /* ShareAction.swift in Sources */,
|
5CF72FC229B9142F00124A13 /* ShareAction.swift in Sources */,
|
||||||
4C363A8A28236B57006E126D /* MentionView.swift in Sources */,
|
4C363A8A28236B57006E126D /* MentionView.swift in Sources */,
|
||||||
|
4C8D1A6C29F1DFC200ACDF75 /* FriendIcon.swift in Sources */,
|
||||||
4CE4F8CD281352B30009DFBB /* Notifications.swift in Sources */,
|
4CE4F8CD281352B30009DFBB /* Notifications.swift in Sources */,
|
||||||
4C30AC7829A577AB00E2BD5A /* EventCache.swift in Sources */,
|
4C30AC7829A577AB00E2BD5A /* EventCache.swift in Sources */,
|
||||||
4C285C8428385690008A31F1 /* CreateAccountView.swift in Sources */,
|
4C285C8428385690008A31F1 /* CreateAccountView.swift in Sources */,
|
||||||
@@ -2004,7 +2008,7 @@
|
|||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CODE_SIGN_ENTITLEMENTS = damus/damus.entitlements;
|
CODE_SIGN_ENTITLEMENTS = damus/damus.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 3;
|
CURRENT_PROJECT_VERSION = 5;
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"damus/Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"damus/Preview Content\"";
|
||||||
DEVELOPMENT_TEAM = XK7H4JAB3D;
|
DEVELOPMENT_TEAM = XK7H4JAB3D;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
@@ -2051,7 +2055,7 @@
|
|||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CODE_SIGN_ENTITLEMENTS = damus/damus.entitlements;
|
CODE_SIGN_ENTITLEMENTS = damus/damus.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 3;
|
CURRENT_PROJECT_VERSION = 5;
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"damus/Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"damus/Preview Content\"";
|
||||||
DEVELOPMENT_TEAM = XK7H4JAB3D;
|
DEVELOPMENT_TEAM = XK7H4JAB3D;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ struct NIP05Badge: View {
|
|||||||
.mask(Image(systemName: "checkmark.seal.fill")
|
.mask(Image(systemName: "checkmark.seal.fill")
|
||||||
.resizable()
|
.resizable()
|
||||||
).frame(width: 14, height: 14)
|
).frame(width: 14, height: 14)
|
||||||
} else {
|
} else if show_domain {
|
||||||
Image(systemName: "checkmark.seal.fill")
|
Image(systemName: "checkmark.seal.fill")
|
||||||
.font(.footnote)
|
.font(.footnote)
|
||||||
.foregroundColor(.gray)
|
.nip05_colorized(gradient: nip05_color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ struct EventProfileName: View {
|
|||||||
self.size = size
|
self.size = size
|
||||||
}
|
}
|
||||||
|
|
||||||
var friend_icon: String? {
|
var friend_type: FriendType? {
|
||||||
return get_friend_icon(contacts: damus_state.contacts, pubkey: pubkey, show_confirmed: show_friend_confirmed)
|
return get_friend_type(contacts: damus_state.contacts, pubkey: self.pubkey)
|
||||||
}
|
}
|
||||||
|
|
||||||
var current_nip05: NIP05? {
|
var current_nip05: NIP05? {
|
||||||
@@ -71,10 +71,8 @@ struct EventProfileName: View {
|
|||||||
NIP05Badge(nip05: nip05, pubkey: pubkey, contacts: damus_state.contacts, show_domain: false, clickable: false)
|
NIP05Badge(nip05: nip05, pubkey: pubkey, contacts: damus_state.contacts, show_domain: false, clickable: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let frend = friend_icon, current_nip05 == nil {
|
if current_nip05 == nil, let frend = friend_type {
|
||||||
Label("", systemImage: frend)
|
FriendIcon(friend: frend)
|
||||||
.foregroundColor(.gray)
|
|
||||||
.font(.footnote)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onReceive(handle_notify(.profile_updated)) { notif in
|
.onReceive(handle_notify(.profile_updated)) { notif in
|
||||||
|
|||||||
39
damus/Views/Profile/FriendIcon.swift
Normal file
39
damus/Views/Profile/FriendIcon.swift
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
//
|
||||||
|
// FriendIcon.swift
|
||||||
|
// damus
|
||||||
|
//
|
||||||
|
// Created by William Casarin on 2023-04-20.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct FriendIcon: View {
|
||||||
|
let friend: FriendType
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
Group {
|
||||||
|
switch friend {
|
||||||
|
case .friend:
|
||||||
|
LINEAR_GRADIENT
|
||||||
|
.mask(Image(systemName: "person.fill.checkmark")
|
||||||
|
.resizable()
|
||||||
|
).frame(width: 20, height: 14)
|
||||||
|
case .fof:
|
||||||
|
Image(systemName: "person.fill.and.arrow.left.and.arrow.right")
|
||||||
|
.resizable()
|
||||||
|
.frame(width: 21, height: 14)
|
||||||
|
.foregroundColor(.gray)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct FriendIcon_Previews: PreviewProvider {
|
||||||
|
static var previews: some View {
|
||||||
|
VStack {
|
||||||
|
FriendIcon(friend: .friend)
|
||||||
|
|
||||||
|
FriendIcon(friend: .fof)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,17 +7,18 @@
|
|||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
func get_friend_icon(contacts: Contacts, pubkey: String, show_confirmed: Bool) -> String? {
|
enum FriendType {
|
||||||
if !show_confirmed {
|
case friend
|
||||||
return nil
|
case fof
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func get_friend_type(contacts: Contacts, pubkey: String) -> FriendType? {
|
||||||
if contacts.is_friend_or_self(pubkey) {
|
if contacts.is_friend_or_self(pubkey) {
|
||||||
return "person.fill.checkmark"
|
return .friend
|
||||||
}
|
}
|
||||||
|
|
||||||
if contacts.is_friend_of_friend(pubkey) {
|
if contacts.is_friend_of_friend(pubkey) {
|
||||||
return "person.fill.and.arrow.left.and.arrow.right"
|
return .fof
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -53,8 +54,8 @@ struct ProfileName: View {
|
|||||||
self.show_nip5_domain = show_nip5_domain
|
self.show_nip5_domain = show_nip5_domain
|
||||||
}
|
}
|
||||||
|
|
||||||
var friend_icon: String? {
|
var friend_type: FriendType? {
|
||||||
return get_friend_icon(contacts: damus_state.contacts, pubkey: pubkey, show_confirmed: show_friend_confirmed)
|
return get_friend_type(contacts: damus_state.contacts, pubkey: self.pubkey)
|
||||||
}
|
}
|
||||||
|
|
||||||
var current_nip05: NIP05? {
|
var current_nip05: NIP05? {
|
||||||
@@ -77,9 +78,8 @@ struct ProfileName: View {
|
|||||||
if let nip05 = current_nip05 {
|
if let nip05 = current_nip05 {
|
||||||
NIP05Badge(nip05: nip05, pubkey: pubkey, contacts: damus_state.contacts, show_domain: show_nip5_domain, clickable: true)
|
NIP05Badge(nip05: nip05, pubkey: pubkey, contacts: damus_state.contacts, show_domain: show_nip5_domain, clickable: true)
|
||||||
}
|
}
|
||||||
if let friend = friend_icon, current_nip05 == nil {
|
if let friend = friend_type, current_nip05 == nil {
|
||||||
Image(systemName: friend)
|
FriendIcon(friend: friend)
|
||||||
.foregroundColor(.gray)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onReceive(handle_notify(.profile_updated)) { notif in
|
.onReceive(handle_notify(.profile_updated)) { notif in
|
||||||
|
|||||||
Reference in New Issue
Block a user