Decode post's media and decode url
This commit is contained in:
parent
f7372d6473
commit
ba52620710
2 changed files with 14 additions and 0 deletions
|
@ -4,6 +4,12 @@ enum PostType: String, Decodable {
|
||||||
case picture
|
case picture
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Media: Decodable, Identifiable {
|
||||||
|
let id: Int
|
||||||
|
|
||||||
|
let url: String
|
||||||
|
}
|
||||||
|
|
||||||
struct Post: Decodable, Identifiable {
|
struct Post: Decodable, Identifiable {
|
||||||
let id: Int
|
let id: Int
|
||||||
|
|
||||||
|
@ -11,4 +17,6 @@ struct Post: Decodable, Identifiable {
|
||||||
let content: String
|
let content: String
|
||||||
|
|
||||||
let postType: PostType
|
let postType: PostType
|
||||||
|
|
||||||
|
let media: [Media]
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,12 @@ struct ProfileView: View {
|
||||||
if post.title != nil {
|
if post.title != nil {
|
||||||
Text(post.title!)
|
Text(post.title!)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VStack {
|
||||||
|
ForEach(post.media) { media in
|
||||||
|
Text(media.url)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.navigationBarTitle(username + "'s Feed").onAppear {
|
}.navigationBarTitle(username + "'s Feed").onAppear {
|
||||||
|
|
Reference in a new issue