PagerTabStripView icon indicating copy to clipboard operation
PagerTabStripView copied to clipboard

Crash with fullScreencover

Open alinless opened this issue 2 years ago • 2 comments

Describe the bug Swift runtime crash

To Reproduce Steps to reproduce the behavior:

  1. open fullScreenCover with pagerTabStropView
  2. try to close it from parent view.

I use optional views and with closing I destroy it. So it seems that it is a GeometryReader bug

**Screens

image

alinless avatar Aug 03 '22 09:08 alinless

Hi, I tried to reproduce it and I couldn't. Could you please give us a minimal reproducible example?

cecipirotto avatar Aug 10 '22 19:08 cecipirotto

For what it's worth, I was able to avoid the crash by commenting out this style line:

struct LocationsLanding: View {

var body: some View {
    VStack {
        PagerTabStripView() {
            LocationsMap()
                .pagerTabItem {
                    TitleNavBarItem(title: "Map")
                }
            
            LocationsList()
                .pagerTabItem {
                    TitleNavBarItem(title: "List")
                }
        }
        //.pagerTabStripViewStyle(.barButton(indicatorBarColor: .gray, tabItemSpacing: 0, tabItemHeight: 50))
    }

iconico-us avatar Aug 18 '22 18:08 iconico-us


import SwiftUI

struct PagerTabItemModifier<NavTabView: View> : ViewModifier {
    
    private var navTabView: () -> NavTabView
    
    init(navTabView: @escaping () -> NavTabView) {
        self.navTabView = navTabView
    }

    func body(content: Content) -> some View {
        GeometryReader { reader in
            content
                .onAppear {
                    DispatchQueue.main.async {
                        let frame = reader.frame(in: .named("PagerViewScrollView"))
                        if (!frame.equalTo(CGRect(x: 0, y: 0, width: 0, height: 0))){
                            index = Int(round(frame.minX / frame.width))
                        }
                        let tabView = navTabView()
                        let tabViewDelegate = tabView as? PagerTabViewDelegate
                        dataStore.setView(AnyView(tabView), at: index)
                        dataStore.setTabViewDelegate(tabViewDelegate, at: index)
                    }
                }.onDisappear {
                    dataStore.items[index]?.tabViewDelegate?.setState(state: .normal)
                    dataStore.remove(at: index)
                }
        }
    }
    
    @EnvironmentObject private var dataStore: DataStore
    @EnvironmentObject private var settings: PagerSettings
    @State private var index = -1
}

Had the same issue so made a quickfix that worked for me.

Macrid avatar Oct 13 '22 11:10 Macrid

I had same issue

tinblanc91 avatar Feb 22 '23 09:02 tinblanc91

Hi, I couldn't reproduce it in version 4.0.0. If it's still happening on this version, please reopen the issue.

cecipirotto avatar Aug 07 '23 19:08 cecipirotto