Код: Выделить всё
struct ContentView: View {
@State private var isSheetVisible: Bool = false
@State private var text: String = ""
var body: some View {
VStack {
Button {
isSheetVisible.toggle()
} label: {
Text("Show Sheet")
.font(.system(size: 20))
.fontWeight(.semibold)
}
.buttonStyle(.glassProminent)
.controlSize(.large)
.buttonSizing(.flexible)
.tint(.red)
.frame(width: 340)
.disabled(text.isEmpty)
}
.padding()
.sheet(isPresented: $isSheetVisible) {
OverlaySheet()
}
}
}

Далее я хочу показать лист над этим представлением, и на этом листе у меня также есть аналогичная кнопка.
Код: Выделить всё
struct OverlaySheet: View {
@Environment(\.dismiss) private var dismiss
@State private var text: String = ""
var body: some View {
VStack {
Button {
dismiss()
} label: {
Text("Dismiss")
.font(.system(size: 20))
.fontWeight(.semibold)
}
.buttonStyle(.glassProminent)
.controlSize(.large)
.buttonSizing(.flexible)
.tint(.red)
.frame(width: 340)
.disabled(text.isEmpty)
}
.padding()
.presentationDetents([.fraction(0.5)])
}
}

Есть идеи, что это происходит?
Подробнее здесь: https://stackoverflow.com/questions/798 ... bled-state
Мобильная версия