damus

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

commit cc95931dec68d0a18356a284f57bca069ac791d3
parent 200cbe3728a47df7bcd7fefc177c03223c6afdbb
Author: William Casarin <jb55@jb55.com>
Date:   Sat, 28 May 2022 08:31:53 -0700

robohash avatars

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Mdamus/Views/EventActionBar.swift | 13++++++++++++-
Mdamus/Views/FollowingView.swift | 24++++++++++++++++--------
Mdamus/Views/ProfilePicView.swift | 4++--
Mdamus/Views/ProfileView.swift | 4++--
4 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/damus/Views/EventActionBar.swift b/damus/Views/EventActionBar.swift @@ -100,8 +100,19 @@ func EventActionButton(img: String, col: Color?, action: @escaping () -> ()) -> Button(action: action) { Label("", systemImage: img) .font(.footnote) - .frame(maxWidth: .infinity) .foregroundColor(col == nil ? Color.gray : col!) } + .padding(.trailing, 40) } + +struct EventActionBar_Previews: PreviewProvider { + static var previews: some View { + let pk = "pubkey" + let kp = Keypair(pubkey: pk, privkey: nil) + let ds = test_damus_state() + let bar = ActionBarModel(likes: 0, boosts: 0, tips: 0, our_like: nil, our_boost: nil, our_tip: nil) + let ev = NostrEvent(content: "hi", pubkey: pk) + EventActionBar(event: ev, keypair: kp, profiles: ds.profiles, bar: bar) + } +} diff --git a/damus/Views/FollowingView.swift b/damus/Views/FollowingView.swift @@ -19,17 +19,18 @@ struct FollowUserView: View { NavigationLink(destination: pv) { ProfilePicView(pubkey: target.pubkey, size: PFP_SIZE, highlight: .none, image_cache: damus_state.image_cache, profiles: damus_state.profiles) - } - VStack(alignment: .leading) { - let profile = damus_state.profiles.lookup(id: target.pubkey) - ProfileName(pubkey: target.pubkey, profile: profile) - if let about = profile.flatMap { $0.about } { - Text(about) + VStack(alignment: .leading) { + let profile = damus_state.profiles.lookup(id: target.pubkey) + ProfileName(pubkey: target.pubkey, profile: profile) + if let about = profile.flatMap { $0.about } { + Text(about) + } } + + Spacer() } - - Spacer() + .buttonStyle(PlainButtonStyle()) FollowButtonView(target: target, follow_state: damus_state.contacts.follow_state(target.pubkey)) } @@ -38,10 +39,12 @@ struct FollowUserView: View { struct FollowersView: View { let damus_state: DamusState + let whos: String @EnvironmentObject var followers: FollowersModel var body: some View { + let profile = damus_state.profiles.lookup(id: whos) ScrollView { LazyVStack(alignment: .leading) { ForEach(followers.contacts, id: \.self) { pk in @@ -49,6 +52,7 @@ struct FollowersView: View { } } } + .navigationBarTitle("\(Profile.displayName(profile: profile, pubkey: whos))'s Followers") } } @@ -57,8 +61,11 @@ struct FollowingView: View { let damus_state: DamusState let following: FollowingModel + let whos: String var body: some View { + let profile = damus_state.profiles.lookup(id: whos) + let who = Profile.displayName(profile: profile, pubkey: whos) ScrollView { LazyVStack(alignment: .leading) { ForEach(following.contacts, id: \.self) { pk in @@ -72,6 +79,7 @@ struct FollowingView: View { .onDisappear { following.unsubscribe() } + .navigationBarTitle("\(who) following") } } diff --git a/damus/Views/ProfilePicView.swift b/damus/Views/ProfilePicView.swift @@ -75,8 +75,8 @@ struct ProfilePicView: View { var MainContent: some View { Group { - let picture = picture ?? profiles.lookup(id: pubkey)?.picture - if let pic_url = picture.flatMap { URL(string: $0) } { + let picture = picture ?? profiles.lookup(id: pubkey)?.picture ?? "https://robohash.org/\(pubkey).png" + if let pic_url = URL(string: picture) { ProfilePic(pic_url) } else { Placeholder diff --git a/damus/Views/ProfileView.swift b/damus/Views/ProfileView.swift @@ -90,7 +90,7 @@ struct ProfileView: View { let contacts = contact.referenced_pubkeys.map { $0.ref_id } let following_model = FollowingModel(damus_state: damus_state, contacts: contacts) HStack { - NavigationLink(destination: FollowingView(damus_state: damus_state, following: following_model)) { + NavigationLink(destination: FollowingView(damus_state: damus_state, following: following_model, whos: profile.pubkey)) { HStack { Text("\(profile.following)") Text("Following") @@ -99,7 +99,7 @@ struct ProfileView: View { } .buttonStyle(PlainButtonStyle()) - let fview = FollowersView(damus_state: damus_state) + let fview = FollowersView(damus_state: damus_state, whos: profile.pubkey) .environmentObject(followers) NavigationLink(destination: fview) { HStack {