Make a header of a View 1 disappear according to the position of the body of a View 2

Good evening,

I am a beginner in SwiftUI (and in code in general). I am currently trying to make an application for a university project. I would like to organize the layout of my different tabs.

I'm trying to manage by taking different pieces of code from the internet to form what I want to achieve.

Currently I'm stuck for 8 hours on something that seems simple:

A code I copied allowed me to put a presentation name that disappears when you scroll up the page content.

I didn't like the TabBar, so I replaced it with a template that has a more fluid animation.

I am in the following situation:

I would like to form a "Home" tab with 2 categories: "News" and "Challenges".

For this, I have four Swift files:

i. MixView ii. MixTabBar iii. NewsView iv. ChallengesView

The problem comes from the fact that initially on the viewed youtube video, the data of the "News" page was present on the home page. Scrolling this data made the header disappear.

As I also have the "Challenges", I have to (I think) find a way to make the body contained in the views iii and iv to trigger the hiding of the header on my central page.

                if !isHide{

                    HStack(spacing:12){

                        

                        Text("Home")

                            .font(.largeTitle)

                            .fontWeight(.heavy)

                            .foregroundColor(Color(.black))

                        

                        Spacer(minLength: 0)

                        

                        Button(action:{}) {

                            

                            Image(systemName:"gear")

                                .foregroundColor(.black)

                                .padding(10)

                                .font(.title2)

                                .clipShape(Circle())

                        }

                    }

                    .padding(.horizontal)

                }

                          
GeometryReader{reader -> AnyView in

              let yAxis = reader.frame(in: .global).minY

              if yAxis < -30 && !isHide{
                    DispatchQueue.main.async{
                        withAnimation{isHide = true}

                                    }

                    }

              if yAxis > -30 && isHide{
                      DispatchQueue.main.async{
                           withAnimation{isHide = false}

                                   }

                    }


              return AnyView(
                    Text("")
                         .frame(width: 0, height: 0)

                                )

                            }

                           

I specify that the code worked very well with the View one, but it is the implementation of the second one that causes problems.

The final goal would be to have a page that has a title that disappears when I scroll (on the news sub-tab as on the Challenges sub-tab). As well as being able to swipe from one sub-tab to another (which is the case).

On the second part of the screen, I left the text with the initial code, it makes the header disappear.

I have seen examples with @State and @Binding, but I could not solve my problem.

I recorded my screen so that you have as much information as possible.

https://youtu.be/bf_EjFBXKWU

Thanks in advance and have a great week.

Make a header of a View 1 disappear according to the position of the body of a View 2
 
 
Q