Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2022-04-30 10:37:29 -07:00
parent ce989450f4
commit a88324333b
12 changed files with 289 additions and 68 deletions

View File

@@ -107,14 +107,14 @@ struct ChatView: View {
}
.frame(maxWidth: 32)
//}
Group {
VStack(alignment: .leading) {
if just_started {
HStack {
ProfileName(pubkey: event.pubkey, profile: profile)
.foregroundColor(id_to_color(event.pubkey))
//.shadow(color: Color.secondary, radius: 2, x: 2, y: 2)
.foregroundColor(colorScheme == .dark ? id_to_color(event.pubkey) : Color.black)
//.shadow(color: Color.black, radius: 2)
Text("\(format_relative_time(event.created_at))")
.foregroundColor(.gray)
}

View File

@@ -9,7 +9,7 @@ import SwiftUI
func ProfileName(pubkey: String, profile: Profile?) -> some View {
Text(String(Profile.displayName(profile: profile, pubkey: pubkey)))
.foregroundColor(hex_to_rgb(pubkey))
//.foregroundColor(hex_to_rgb(pubkey))
.bold()
}

View File

@@ -7,20 +7,70 @@
import SwiftUI
enum ProfileTab: Hashable {
case posts
case following
}
struct ProfileView: View {
let profile: Profile? = nil
let pool: RelayPool
@State private var selected_tab: ProfileTab = .posts
@EnvironmentObject var profile: ProfileModel
@EnvironmentObject var profiles: Profiles
var TopSection: some View {
HStack(alignment: .top) {
let data = profile.pubkey.flatMap { profiles.lookup(id: $0) }
ProfilePicView(picture: data?.picture, size: 64, highlight: .custom(Color.black, 4))
//.border(Color.blue)
VStack(alignment: .leading) {
if let pubkey = profile.pubkey {
ProfileName(pubkey: pubkey, profile: data)
.font(.title)
//.border(Color.green)
}
Text(data?.about ?? "")
//.border(Color.red)
}
//.border(Color.purple)
//Spacer()
}
//.border(Color.indigo)
}
var body: some View {
VStack {
ProfilePicView(picture: profile?.picture, size: 64, highlight: .custom(Color.black, 4))
//ProfileName(pubkey: <#T##String#>, profile: <#T##Profile?#>)
VStack(alignment: .leading) {
TopSection
Picker("", selection: $selected_tab) {
Text("Posts").tag(ProfileTab.posts)
Text("Following").tag(ProfileTab.following)
}
.pickerStyle(SegmentedPickerStyle())
Divider()
Group {
switch(selected_tab) {
case .posts:
TimelineView(events: $profile.events, pool: pool)
.environmentObject(profiles)
case .following:
Text("Following")
}
}
.frame(maxHeight: .infinity, alignment: .topLeading)
}
//.border(Color.white)
.frame(maxWidth: .infinity, alignment: .topLeading)
.navigationBarTitle("Profile")
}
}
/*
struct ProfileView_Previews: PreviewProvider {
static var previews: some View {
ProfileView()
}
}
*/