I am using a LazyVStack
to display a list of items. The LazyVStack
works well but I cannot find a good solution in order to open a details view on top to make the post full screen.
The LazyVStack
is defined as below:
struct FeedView: View {
var body: some View {
NavigationStack {
ScrollView {
LazyVStack(spacing: 8) {
ForEach(Post.MOCK_POSTS) { post in
FeedPostView(post: post)
}
}
.padding(.top, 10)
}
.navigationTitle("Feed")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Image(systemName: "message")
.imageScale(.large)
}
}
}
}
}
so the feed
looks like:
and the structure for the FeedPostView
is as below:
struct FeedPostView: View {
let post: Post
var body: some View {
NavigationStack {
ZStack {
NavigationLink(destination: PostDetailsView(post: post)) {
Image(post.images[0])
.resizable()
.aspectRatio(contentMode: .fit)
.scaledToFill()
}
}
.frame(maxWidth: .infinity, maxHeight: 450)
.clipShape(RoundedRectangle(cornerRadius: 15.0))
.overlay(PostHeaderView(post: post), alignment: .top)
.overlay(PostCaptionView(post: post), alignment: .bottom)
.padding([.leading, .trailing])
.padding(.bottom, 15)
}
}
}
What I am trying to do is to create an animation when the user tap on one of the post. This post become fullscreen not in the lazyView and instead of having an overlay like in the feed but the view transition to a details screen where you can see the move.
- Header slowly move to top of the screen
- The image move below the header.
- Then I will add a new setion below.
I have attached a url to the video on what is existing now but I am looking to see the transition of the header from the overlay to top of the screen for example.
video