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