mirror of https://github.com/lukechilds/damus.git
William Casarin
3 years ago
8 changed files with 168 additions and 37 deletions
@ -0,0 +1,44 @@ |
|||
// |
|||
// FollowButtonView.swift |
|||
// damus |
|||
// |
|||
// Created by William Casarin on 2022-05-16. |
|||
// |
|||
|
|||
import SwiftUI |
|||
|
|||
struct FollowButtonView: View { |
|||
let pubkey: String |
|||
@State var follow_state: FollowState |
|||
|
|||
var body: some View { |
|||
Button("\(follow_btn_txt(follow_state))") { |
|||
follow_state = perform_follow_btn_action(follow_state, target: pubkey) |
|||
} |
|||
.buttonStyle(.bordered) |
|||
.onReceive(handle_notify(.followed)) { notif in |
|||
let pk = notif.object as! String |
|||
if pk != pubkey { |
|||
return |
|||
} |
|||
|
|||
self.follow_state = .follows |
|||
} |
|||
.onReceive(handle_notify(.unfollowed)) { notif in |
|||
let pk = notif.object as! String |
|||
if pk != pubkey { |
|||
return |
|||
} |
|||
|
|||
self.follow_state = .unfollows |
|||
} |
|||
} |
|||
} |
|||
|
|||
/* |
|||
struct FollowButtonView_Previews: PreviewProvider { |
|||
static var previews: some View { |
|||
FollowButtonView() |
|||
} |
|||
} |
|||
*/ |
@ -0,0 +1,59 @@ |
|||
// |
|||
// FollowingView.swift |
|||
// damus |
|||
// |
|||
// Created by William Casarin on 2022-05-16. |
|||
// |
|||
|
|||
import SwiftUI |
|||
|
|||
struct FollowUserView: View { |
|||
let pubkey: String |
|||
let damus_state: DamusState |
|||
|
|||
var body: some View { |
|||
HStack(alignment: .top) { |
|||
let pmodel = ProfileModel(pubkey: pubkey, damus: damus_state) |
|||
let pv = ProfileView(damus_state: damus_state, profile: pmodel) |
|||
|
|||
NavigationLink(destination: pv) { |
|||
ProfilePicView(pubkey: 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: pubkey) |
|||
ProfileName(pubkey: pubkey, profile: profile) |
|||
if let about = profile.flatMap { $0.about } { |
|||
Text(about) |
|||
} |
|||
} |
|||
|
|||
Spacer() |
|||
|
|||
FollowButtonView(pubkey: pubkey, follow_state: damus_state.contacts.follow_state(pubkey)) |
|||
} |
|||
} |
|||
} |
|||
|
|||
struct FollowingView: View { |
|||
let contact: NostrEvent |
|||
let damus_state: DamusState |
|||
|
|||
var body: some View { |
|||
ScrollView { |
|||
LazyVStack(alignment: .leading) { |
|||
ForEach(contact.referenced_pubkeys) { pk in |
|||
FollowUserView(pubkey: pk.ref_id, damus_state: damus_state) |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
/* |
|||
struct FollowingView_Previews: PreviewProvider { |
|||
static var previews: some View { |
|||
FollowingView(contact: <#NostrEvent#>, damus_state: <#DamusState#>) |
|||
} |
|||
} |
|||
*/ |
Loading…
Reference in new issue