Improve post header appearance
This commit is contained in:
parent
e38c45b353
commit
2d9178ad07
2 changed files with 32 additions and 11 deletions
|
@ -30,6 +30,7 @@ struct Post: Decodable, Identifiable {
|
|||
let originalUsername: String?
|
||||
|
||||
let originalPost: OriginalPost?
|
||||
let avatarUrl: String
|
||||
|
||||
func isReblogged() -> Bool {
|
||||
return originalUsername != nil
|
||||
|
@ -44,8 +45,10 @@ struct Post: Decodable, Identifiable {
|
|||
}
|
||||
}
|
||||
|
||||
let mediaURL = "https://homepages.cae.wisc.edu/~ece533/images/airplane.png"
|
||||
|
||||
let testMedia = Media(id: 0,
|
||||
url: "https://homepages.cae.wisc.edu/~ece533/images/airplane.png")
|
||||
url: mediaURL)
|
||||
|
||||
let fooPost = Post(id: 0,
|
||||
title: "Foo",
|
||||
|
@ -54,7 +57,8 @@ let fooPost = Post(id: 0,
|
|||
media: [testMedia],
|
||||
username: "foobar",
|
||||
originalUsername: nil,
|
||||
originalPost: nil)
|
||||
originalPost: nil,
|
||||
avatarUrl: mediaURL)
|
||||
|
||||
let fooPostReblog = Post(id: 1,
|
||||
title: nil,
|
||||
|
@ -63,4 +67,5 @@ let fooPostReblog = Post(id: 1,
|
|||
media: [testMedia],
|
||||
username: "foobar",
|
||||
originalUsername: "foobar2",
|
||||
originalPost: nil)
|
||||
originalPost: nil,
|
||||
avatarUrl: mediaURL)
|
||||
|
|
|
@ -12,13 +12,29 @@ struct PostView: View {
|
|||
|
||||
var body: some View {
|
||||
VStack {
|
||||
if post.isReblogged() {
|
||||
Text("Reblogged from " + post.originalUsername!)
|
||||
}
|
||||
|
||||
if post.getTitle() != nil {
|
||||
Text(post.getTitle()!)
|
||||
}
|
||||
HStack {
|
||||
RemoteImage(type: .url(URL(string: post.avatarUrl.encodeUrl()!)!), errorView: { error in
|
||||
Text(error.localizedDescription)
|
||||
}, imageView: { image in
|
||||
image
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
}, loadingView: {
|
||||
Text("Loading...")
|
||||
}).frame(width: 50.0, height: 50.0).padding(.leading)
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
if post.isReblogged() {
|
||||
Text("Reblogged from " + post.originalUsername!)
|
||||
}
|
||||
|
||||
if post.getTitle() != nil {
|
||||
Text(post.getTitle()!)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}.frame(maxWidth: .infinity)
|
||||
|
||||
VStack {
|
||||
ForEach(post.media) { media in
|
||||
|
@ -35,7 +51,7 @@ struct PostView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.frame(maxWidth: .infinity)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue