From ba52620710df4da6ab04e6a909670e276e7b4b88 Mon Sep 17 00:00:00 2001 From: redstrate <54911369+redstrate@users.noreply.github.com> Date: Wed, 3 Jun 2020 21:56:33 -0400 Subject: [PATCH] Decode post's media and decode url --- MobileFort/MobileFort/Common.swift | 8 ++++++++ MobileFort/MobileFort/ContentView.swift | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/MobileFort/MobileFort/Common.swift b/MobileFort/MobileFort/Common.swift index f6d6086..b7e0418 100644 --- a/MobileFort/MobileFort/Common.swift +++ b/MobileFort/MobileFort/Common.swift @@ -4,6 +4,12 @@ enum PostType: String, Decodable { case picture } +struct Media: Decodable, Identifiable { + let id: Int + + let url: String +} + struct Post: Decodable, Identifiable { let id: Int @@ -11,4 +17,6 @@ struct Post: Decodable, Identifiable { let content: String let postType: PostType + + let media: [Media] } diff --git a/MobileFort/MobileFort/ContentView.swift b/MobileFort/MobileFort/ContentView.swift index f4d32de..2eaf518 100644 --- a/MobileFort/MobileFort/ContentView.swift +++ b/MobileFort/MobileFort/ContentView.swift @@ -14,6 +14,12 @@ struct ProfileView: View { if post.title != nil { Text(post.title!) } + + VStack { + ForEach(post.media) { media in + Text(media.url) + } + } } } }.navigationBarTitle(username + "'s Feed").onAppear {