break profile view so that I fix it
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -81,37 +81,22 @@ struct ChatView: View {
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
|
||||
var body: some View {
|
||||
let profile = profiles.lookup(id: event.pubkey)
|
||||
HStack {
|
||||
//ZStack {
|
||||
//Rectangle()
|
||||
//.foregroundColor(Color.gray)
|
||||
//.frame(width: 2)
|
||||
|
||||
VStack {
|
||||
if is_active || just_started {
|
||||
ProfilePicView(picture: profile?.picture, size: 32, highlight: is_active ? .main : .none, image_cache: damus.image_cache)
|
||||
}
|
||||
/*
|
||||
if just_started {
|
||||
ProfilePicView(picture: profile?.picture, size: 32, highlight: thread.event.id == event.id ? .main : .none)
|
||||
} else {
|
||||
Text("\(format_relative_time(event.created_at))")
|
||||
.font(.footnote)
|
||||
.foregroundColor(.gray.opacity(0.5))
|
||||
}
|
||||
*/
|
||||
|
||||
Spacer()
|
||||
VStack {
|
||||
if is_active || just_started {
|
||||
ProfilePicView(pubkey: event.pubkey, size: 32, highlight: is_active ? .main : .none, image_cache: damus.image_cache)
|
||||
.environmentObject(profiles)
|
||||
}
|
||||
.frame(maxWidth: 32)
|
||||
//}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.frame(maxWidth: 32)
|
||||
|
||||
Group {
|
||||
VStack(alignment: .leading) {
|
||||
if just_started {
|
||||
HStack {
|
||||
ProfileName(pubkey: event.pubkey, profile: profile)
|
||||
ProfileName(pubkey: event.pubkey, profile: profiles.lookup(id: event.pubkey))
|
||||
.foregroundColor(colorScheme == .dark ? id_to_color(event.pubkey) : Color.black)
|
||||
//.shadow(color: Color.black, radius: 2)
|
||||
Text("\(format_relative_time(event.created_at))")
|
||||
|
||||
@@ -53,7 +53,8 @@ struct EventView: View {
|
||||
.environmentObject(profiles)
|
||||
|
||||
NavigationLink(destination: pv) {
|
||||
ProfilePicView(picture: profile?.picture, size: PFP_SIZE!, highlight: highlight, image_cache: damus.image_cache)
|
||||
ProfilePicView(pubkey: event.pubkey, size: PFP_SIZE!, highlight: highlight, image_cache: damus.image_cache)
|
||||
.environmentObject(profiles)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
@@ -33,7 +33,7 @@ func pfp_line_width(_ h: Highlight) -> CGFloat {
|
||||
}
|
||||
|
||||
struct ProfilePicView: View {
|
||||
let picture: String?
|
||||
let pubkey: String
|
||||
let size: CGFloat
|
||||
let highlight: Highlight
|
||||
let image_cache: ImageCache
|
||||
@@ -42,8 +42,12 @@ struct ProfilePicView: View {
|
||||
|
||||
@EnvironmentObject var profiles: Profiles
|
||||
|
||||
var PlaceholderColor: Color {
|
||||
return id_to_color(pubkey)
|
||||
}
|
||||
|
||||
var Placeholder: some View {
|
||||
Color.purple.opacity(0.2)
|
||||
PlaceholderColor.opacity(0.5)
|
||||
.frame(width: size, height: size)
|
||||
.cornerRadius(CORNER_RADIUS)
|
||||
.overlay(Circle().stroke(highlight_color(highlight), lineWidth: pfp_line_width(highlight)))
|
||||
@@ -72,6 +76,7 @@ struct ProfilePicView: View {
|
||||
|
||||
var MainContent: some View {
|
||||
Group {
|
||||
let picture = profiles.lookup(id: pubkey)?.picture
|
||||
if let pic_url = picture.flatMap { URL(string: $0) } {
|
||||
ProfilePic(pic_url)
|
||||
} else {
|
||||
|
||||
@@ -22,55 +22,44 @@ struct ProfileView: View {
|
||||
@EnvironmentObject var profiles: Profiles
|
||||
|
||||
var TopSection: some View {
|
||||
HStack(alignment: .top) {
|
||||
VStack{
|
||||
let data = profiles.lookup(id: profile.pubkey)
|
||||
ProfilePicView(picture: data?.picture, size: PFP_SIZE!, highlight: .custom(Color.black, 4), image_cache: damus.image_cache)
|
||||
//.border(Color.blue)
|
||||
VStack(alignment: .leading) {
|
||||
if let pubkey = profile.pubkey {
|
||||
ProfileName(pubkey: pubkey, profile: data)
|
||||
.font(.title)
|
||||
//.border(Color.green)
|
||||
Text("\(pubkey)")
|
||||
.textSelection(.enabled)
|
||||
.font(.footnote)
|
||||
.foregroundColor(id_to_color(pubkey))
|
||||
HStack {
|
||||
ProfilePicView(pubkey: profile.pubkey, size: PFP_SIZE!, highlight: .custom(Color.black, 2), image_cache: damus.image_cache)
|
||||
.environmentObject(profiles)
|
||||
|
||||
Spacer()
|
||||
|
||||
Button("Follow") {
|
||||
print("follow \(profile.pubkey)")
|
||||
}
|
||||
Text(data?.about ?? "")
|
||||
//.border(Color.red)
|
||||
}
|
||||
//.border(Color.purple)
|
||||
//Spacer()
|
||||
|
||||
if let pubkey = profile.pubkey {
|
||||
ProfileName(pubkey: pubkey, profile: data)
|
||||
.font(.title)
|
||||
//.border(Color.green)
|
||||
Text("\(pubkey)")
|
||||
.textSelection(.enabled)
|
||||
.font(.footnote)
|
||||
.foregroundColor(id_to_color(pubkey))
|
||||
}
|
||||
Text(data?.about ?? "")
|
||||
}
|
||||
//.border(Color.indigo)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
TopSection
|
||||
/*
|
||||
Picker("", selection: $selected_tab) {
|
||||
Text("Posts").tag(ProfileTab.posts)
|
||||
Text("Following").tag(ProfileTab.following)
|
||||
}
|
||||
.pickerStyle(SegmentedPickerStyle())
|
||||
*/
|
||||
|
||||
ScrollView {
|
||||
TopSection
|
||||
|
||||
Divider()
|
||||
|
||||
Group {
|
||||
switch(selected_tab) {
|
||||
case .posts:
|
||||
TimelineView(events: $profile.events, damus: damus)
|
||||
.environmentObject(profiles)
|
||||
case .following:
|
||||
Text("Following")
|
||||
}
|
||||
Divider()
|
||||
|
||||
InnerTimelineView(events: $profile.events, damus: damus)
|
||||
.environmentObject(profiles)
|
||||
}
|
||||
.frame(maxHeight: .infinity, alignment: .topLeading)
|
||||
}
|
||||
//.border(Color.white)
|
||||
.padding([.leading, .trailing], 6)
|
||||
.frame(maxWidth: .infinity, alignment: .topLeading)
|
||||
|
||||
|
||||
@@ -23,7 +23,8 @@ struct ReplyQuoteView: View {
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
HStack(alignment: .top) {
|
||||
ProfilePicView(picture: profiles.lookup(id: event.pubkey)?.picture, size: 16, highlight: .reply, image_cache: image_cache)
|
||||
ProfilePicView(pubkey: event.pubkey, size: 16, highlight: .reply, image_cache: image_cache)
|
||||
.environmentObject(profiles)
|
||||
Text(Profile.displayName(profile: profiles.lookup(id: event.pubkey), pubkey: event.pubkey))
|
||||
.foregroundColor(.accentColor)
|
||||
Text("\(format_relative_time(event.created_at))")
|
||||
|
||||
@@ -12,6 +12,27 @@ enum TimelineAction {
|
||||
case navigating
|
||||
}
|
||||
|
||||
struct InnerTimelineView: View {
|
||||
@Binding var events: [NostrEvent]
|
||||
@EnvironmentObject var profiles: Profiles
|
||||
let damus: DamusState
|
||||
|
||||
var body: some View {
|
||||
LazyVStack {
|
||||
ForEach(events, id: \.id) { (ev: NostrEvent) in
|
||||
let tv = ThreadView(thread: ThreadModel(event: ev, pool: damus.pool), damus: damus)
|
||||
.environmentObject(profiles)
|
||||
|
||||
NavigationLink(destination: tv) {
|
||||
EventView(event: ev, highlight: .none, has_action_bar: true, damus: damus)
|
||||
}
|
||||
.isDetailLink(true)
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct TimelineView: View {
|
||||
@Binding var events: [NostrEvent]
|
||||
|
||||
@@ -21,35 +42,15 @@ struct TimelineView: View {
|
||||
|
||||
var body: some View {
|
||||
MainContent
|
||||
.padding([.leading, .trailing], 6)
|
||||
.environmentObject(profiles)
|
||||
.padding([.leading, .trailing], 6)
|
||||
.environmentObject(profiles)
|
||||
}
|
||||
|
||||
var MainContent: some View {
|
||||
ScrollViewReader { scroller in
|
||||
ScrollView {
|
||||
LazyVStack {
|
||||
ForEach(events, id: \.id) { (ev: NostrEvent) in
|
||||
/*
|
||||
let evdet = EventDetailView(thread: ThreadModel(event: ev, pool: pool))
|
||||
.navigationBarTitle("Thread")
|
||||
.padding([.leading, .trailing], 6)
|
||||
.environmentObject(profiles)
|
||||
*/
|
||||
|
||||
let tv = ThreadView(thread: ThreadModel(event: ev, pool: damus.pool), damus: damus)
|
||||
.environmentObject(profiles)
|
||||
|
||||
NavigationLink(destination: tv) {
|
||||
EventView(event: ev, highlight: .none, has_action_bar: true, damus: damus)
|
||||
}
|
||||
.isDetailLink(true)
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
//.onTapGesture {
|
||||
//NotificationCenter.default.post(name: .open_thread, object: ev)
|
||||
//}
|
||||
}
|
||||
}
|
||||
InnerTimelineView(events: $events, damus: damus)
|
||||
.environmentObject(profiles)
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(for: .scroll_to_top)) { _ in
|
||||
guard let event = events.first else {
|
||||
|
||||
Reference in New Issue
Block a user