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,4 +1,33 @@
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import URLImage
|
||||||
|
|
||||||
|
extension String {
|
||||||
|
func encodeUrl() -> String? {
|
||||||
|
return self.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct PostView: View {
|
||||||
|
let post: Post
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
VStack {
|
||||||
|
Text(String(post.id))
|
||||||
|
|
||||||
|
if post.title != nil {
|
||||||
|
Text(post.title!)
|
||||||
|
}
|
||||||
|
|
||||||
|
VStack {
|
||||||
|
ForEach(post.media) { media in
|
||||||
|
VStack {
|
||||||
|
URLImage(URL(string: media.url.encodeUrl()!)!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct ProfileView: View {
|
struct ProfileView: View {
|
||||||
let username: String
|
let username: String
|
||||||
|
@ -8,19 +37,7 @@ struct ProfileView: View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
List(posts) { post in
|
List(posts) { post in
|
||||||
VStack {
|
PostView(post: post)
|
||||||
Text(String(post.id))
|
|
||||||
|
|
||||||
if post.title != nil {
|
|
||||||
Text(post.title!)
|
|
||||||
}
|
|
||||||
|
|
||||||
VStack {
|
|
||||||
ForEach(post.media) { media in
|
|
||||||
Text(media.url)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}.navigationBarTitle(username + "'s Feed").onAppear {
|
}.navigationBarTitle(username + "'s Feed").onAppear {
|
||||||
let url = URL(string: "https://www.pillowfort.social/" + self.username + "/json")!
|
let url = URL(string: "https://www.pillowfort.social/" + self.username + "/json")!
|
||||||
|
|
Reference in a new issue