Closed alinless closed 1 year ago
Hi, I tried to reproduce it and I couldn't. Could you please give us a minimal reproducible example?
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))
}
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.
I had same issue
Hi, I couldn't reproduce it in version 4.0.0. If it's still happening on this version, please reopen the issue.
Describe the bug Swift runtime crash
To Reproduce Steps to reproduce the behavior:
I use optional views and with closing I destroy it. So it seems that it is a GeometryReader bug
**Screens