How do you keep 'fullScreenISPresented' from dismissing itself when the screen rotates?

204 views Asked by At

I have a LazyVGrid with a layout count: 2 when in portrait, and court: 3 when in landscape, in a scrollview. I use a ternary to change the count. Problem is when I scroll down than select a cell, when the model slides up and I rotate, the view dismisses by itself. I also notice the scroll seems to be in a totally different location. Do I need to build this differently? Funny thing is it only happens at certain places down in the scrollview. Its not consistent. Sometimes it works fine then as I continue to scroll down it'll start to happen. If I don't change the layout count in portrait or landscape, it works fine. It seems change the count causes this.

struct Feed_View: View {

@EnvironmentObject var viewModel : Post_View_Model 
@Environment(\.verticalSizeClass) var sizeClass 
@FocusState private var isFocused: Bool

var body: some View {
    
    Color("BGColor").ignoresSafeArea() 
    
    ZStack {
        
        VStack (alignment: .center, spacing: 0) {
            
            //MARK: - NAVIGATION BAR
            
            NavBar_View() // Top Navigation bar
                .frame(maxHeight: 40, alignment: .center)
            
            //MARK: - SCROLL VIEW
            ScrollView (.vertical, showsIndicators: false) {
                
                
                //MARK: - FEED FILL
                
                let layout =  Array(repeating: GridItem(.flexible(), spacing: 10), count: sizeClass == .compact ? 3 : 2)
                
                LazyVGrid(columns: layout, spacing: 10) {

                    ForEach (viewModel.posts, id: \.self) { posts in
                        
                        Feed_Cell(postModel: posts)
                        
                    } //LOOP
                    
                } //LAZYV
                .padding(.horizontal, 10).padding(.vertical, 10)
                
            } //SCROLL
  
            
        } //V
        
    } //Z

}

}

0

There are 0 answers