extract HomeModel from ContentView
huge refactor Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -8,21 +8,21 @@
|
||||
import SwiftUI
|
||||
|
||||
struct FollowUserView: View {
|
||||
let pubkey: String
|
||||
let target: FollowTarget
|
||||
let damus_state: DamusState
|
||||
|
||||
var body: some View {
|
||||
HStack(alignment: .top) {
|
||||
let pmodel = ProfileModel(pubkey: pubkey, damus: damus_state)
|
||||
let pmodel = ProfileModel(pubkey: target.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)
|
||||
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: pubkey)
|
||||
ProfileName(pubkey: pubkey, profile: profile)
|
||||
let profile = damus_state.profiles.lookup(id: target.pubkey)
|
||||
ProfileName(pubkey: target.pubkey, profile: profile)
|
||||
if let about = profile.flatMap { $0.about } {
|
||||
Text(about)
|
||||
}
|
||||
@@ -30,7 +30,7 @@ struct FollowUserView: View {
|
||||
|
||||
Spacer()
|
||||
|
||||
FollowButtonView(pubkey: pubkey, follow_state: damus_state.contacts.follow_state(pubkey))
|
||||
FollowButtonView(target: target, follow_state: damus_state.contacts.follow_state(target.pubkey))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@ struct FollowingView: View {
|
||||
ScrollView {
|
||||
LazyVStack(alignment: .leading) {
|
||||
ForEach(contact.referenced_pubkeys) { pk in
|
||||
FollowUserView(pubkey: pk.ref_id, damus_state: damus_state)
|
||||
FollowUserView(target: .pubkey(pk.ref_id), damus_state: damus_state)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user