До сих пор все работало с использованием листа.
Код: Выделить всё
Button(action: {
newTapas = addTapas()
/// Delay the toggle of the Sheet by .1 second.
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
shouldPresentSheet.toggle()
}
}, label: {
Text("New Tapas")
.font(.system(size: 17))
.padding(.trailing)
.padding([.top, .bottom], 10)
})
.sheet(isPresented: $shouldPresentSheet) {
print("Sheet dismissed!")
} content: {
EditTapasView(tapas: newTapas)
}
Когда Я просто использую NavigationLink и добавляю к нему функцию addTapas(), она постоянно создает новые тапы без каких-либо щелчков мышью.
Код: Выделить всё
NavigationLink(destination: EditTapasView(tapas: addTapas())) {
Text("New Tapas")
.font(.system(size: 17))
.padding(.trailing)
.padding([.top, .bottom], 10)
}
Код: Выделить всё
NavigationStack (path: $path) {
Button(action: {
newTapas = addTapas()
path = EditTapasView(tapas: newTapas)
}, label: {
Text("New Tapas")
.font(.system(size: 17))
.padding(.trailing)
.padding([.top, .bottom], 10)
})
}
Подробнее здесь: https://stackoverflow.com/questions/792 ... new-object
Мобильная версия