Created
March 26, 2020 17:53
-
-
Save DDavis1025/a78a71e856ce0f50307b0d19dc34505b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct Album: View { | |
var post:Post | |
var post2:[PostById] | |
var body: some View { | |
VStack { | |
Text("Title: ").bold() | |
+ Text("\(post.title)") | |
ImageView(withURL: "http://localhost:8000/\(post.path.replacingOccurrences(of: " ", with: "%20"))") | |
Text("Description: ").bold() | |
+ Text("\(post.description)") | |
List{ | |
ForEach(self.post2.filter { i in i.album_id == post.id }){ post in | |
Text("\(post.name ?? "title")") | |
} | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import ASCollectionView | |
struct ContentView: View { | |
@ObservedObject var model = PostListViewModel() | |
@ObservedObject var model2 = PostListViewByIdModel() | |
var body: some View { | |
NavigationView { | |
List(model.posts) { post in | |
VStack{ | |
Text("Title: ").bold() | |
+ Text("\(post.title)") | |
NavigationLink(destination: Album(post: post, post2: self.model2.postsById)) { | |
ImageView(withURL: "http://localhost:8000/\(post.path.replacingOccurrences(of: " ", with: "%20"))") | |
} | |
Text("Description: ").bold() | |
+ Text("\(post.description)") | |
} | |
} | |
} | |
.onReceive(model.$posts) { posts in // << first got finished | |
self.model2.fetchPostsById(for: posts) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment