Load post media in profile view
This commit is contained in:
parent
33ef5896db
commit
e93af7503a
1 changed files with 30 additions and 13 deletions
|
@ -1,13 +1,16 @@
|
|||
import SwiftUI
|
||||
import URLImage
|
||||
|
||||
struct ProfileView: View {
|
||||
let username: String
|
||||
extension String {
|
||||
func encodeUrl() -> String? {
|
||||
return self.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
|
||||
}
|
||||
}
|
||||
|
||||
@State var posts: [Post] = []
|
||||
struct PostView: View {
|
||||
let post: Post
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
List(posts) { post in
|
||||
VStack {
|
||||
Text(String(post.id))
|
||||
|
||||
|
@ -17,11 +20,25 @@ struct ProfileView: View {
|
|||
|
||||
VStack {
|
||||
ForEach(post.media) { media in
|
||||
Text(media.url)
|
||||
VStack {
|
||||
URLImage(URL(string: media.url.encodeUrl()!)!)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ProfileView: View {
|
||||
let username: String
|
||||
|
||||
@State var posts: [Post] = []
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
List(posts) { post in
|
||||
PostView(post: post)
|
||||
}
|
||||
}.navigationBarTitle(username + "'s Feed").onAppear {
|
||||
let url = URL(string: "https://www.pillowfort.social/" + self.username + "/json")!
|
||||
|
||||
|
|
Reference in a new issue