Skip to content

Commit b5ee806

Browse files
committed
home: fix wizard not appearing on < iOS 14.5
A SwiftUI bug prevents multiple .sheet() from working. Fixes #4776
1 parent 75ae26c commit b5ee806

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

Platform/Shared/VMNavigationListView.swift

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ struct VMNavigationListView: View {
9696
private struct VMListModifier: ViewModifier {
9797
@EnvironmentObject private var data: UTMData
9898
@State private var settingsPresented = false
99+
@State private var sheetPresented = false
99100

100101
func body(content: Content) -> some View {
101102
content
@@ -126,13 +127,37 @@ private struct VMListModifier: ViewModifier {
126127
}
127128
#endif
128129
}
130+
#if os(iOS)
131+
// SwiftUI bug on iOS 14.4 and previous versions prevents multiple .sheet from working
132+
.sheet(isPresented: $sheetPresented) {
133+
if data.showNewVMSheet {
134+
VMWizardView()
135+
} else if settingsPresented {
136+
UTMSettingsView()
137+
}
138+
}
139+
.onChange(of: data.showNewVMSheet) { newValue in
140+
if newValue {
141+
settingsPresented = false
142+
sheetPresented = true
143+
}
144+
}
145+
.onChange(of: settingsPresented) { newValue in
146+
if newValue {
147+
data.showNewVMSheet = false
148+
sheetPresented = true
149+
}
150+
}
151+
.onChange(of: sheetPresented) { newValue in
152+
if !newValue {
153+
settingsPresented = false
154+
data.showNewVMSheet = false
155+
}
156+
}
157+
#else
129158
.sheet(isPresented: $data.showNewVMSheet) {
130159
VMWizardView()
131160
}
132-
#if os(iOS)
133-
.sheet(isPresented: $settingsPresented) {
134-
UTMSettingsView()
135-
}
136161
#endif
137162
}
138163

0 commit comments

Comments
 (0)