I got this inside LazyVstack:
ForEach(memes, id: \.memeid){
meme in
if(!user.hiddenUsersString.contains(String(meme.userid) + ",")){
GeometryReader{ proxy in
MemeView(memeid: meme.memeid,
picUrl: Functions.getMediaUrl(media: meme.pic, serverScaling: serverScaling,
whichMedia: "memes"),
profilImgUrl: finalImgUrl(theUrl: Functions.getProfileImg(userid: meme.userid, serverScaling: serverScaling, imgTag: user.userid == meme.userid ? user.profilePicTag : nil), memeOwner: meme.userid),
memeWidth: memeWidth,
memeHeight: Functions.getMemeHeight(memeWidth: memeWidth, fileName: meme.pic, memeSize: meme.size),
position: proxy.frame(in: .global).origin.y,
meme: meme,
memes: self.$memes)
}
}
}
In the body of MemeView I got:
VStack{
HStack{
AsyncImage(url: URL(string: profilImgUrl)) { phase in
switch phase {
case .empty:
ProgressView()
.scaleEffect(x: 1.5, y: 1.5, anchor: .center)
.aspectRatio(contentMode: .fit)
.frame(maxWidth: 34)
case .success(let image):
image.resizable()
.aspectRatio(contentMode: .fit)
.frame(maxWidth: 34)
.cornerRadius(50)
case .failure:
Image(systemName: "person.circle.fill")
.resizable()
.aspectRatio(contentMode: .fit).frame(height: 34)
.cornerRadius(50)
.foregroundColor(Color.gray)
@unknown default:
Image(systemName: "person.circle.fill")
.resizable()
.aspectRatio(contentMode: .fit).frame(height: 34)
.cornerRadius(50)
.foregroundColor(Color.gray)
}
}
Text(meme.nickname)
}
.frame(height: 30)
ZStack{
if(meme.pic.contains(".mp4")){
VideoPlayer(player: player)
.frame(width: memeWidth,
height: memeHeight,
alignment: .center)
}else{
AsyncImage(url: URL(string: picUrl)) { phase in
switch phase {
case .empty:
ProgressView()
.scaleEffect(x: 1.5, y: 1.5, anchor: .center)
.aspectRatio(contentMode: .fit)
.frame(width: 34)
case .success(let image):
image.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: memeWidth, height: memeHeight)
.cornerRadius(50)
case .failure:
Image(systemName: "person.circle.fill")
.resizable()
.aspectRatio(contentMode: .fit).frame(height: 34)
.cornerRadius(50)
.foregroundColor(Color.gray)
@unknown default:
Image(systemName: "person.circle.fill")
.resizable()
.aspectRatio(contentMode: .fit).frame(height: 34)
.cornerRadius(50)
.foregroundColor(Color.gray)
}
}
}
}
.frame(width: memeWidth, height: 500)
}
.task {
if(meme.pic.contains(".mp4")){
player = AVPlayer(url: URL(string: picUrl)!)
}
}
Everything is squeezed together! VStack completely ignores the height of the children views.
Why is that and how to fix this?
I'm new to iOS / SwiftUI and must say that I absolutely loathe it. I'm shocked that apple think it's ok to release such a bugged and limited pile garbage into the world!