Так я реализовал свой экран. По сути, есть панель инструментов и панель хода.
Код: Выделить всё
struct QuizScreen: View {
@ObservredObject var model: AllQuizModel
@Environment(\.dismiss) private var dismiss
@State private var showMoveBackConfirm = false
@State private var showHelpDialog = false
var body: some View {
NavigationStack {
VStack (alignment: .center){
// Progress Bar
ProgressView(value: 0.5)
Spacer()
}
.toolbar {
ToolbarItem(placement: .topBarLeading){
Button{
showMoveBackConfirm.toggle()
} label: {
Image(systemName: "arrow.left")
}
}
ToolbarItem(placement: .principal){
Button{
showMoveBackConfirm.toggle()
} label: {
Text("Question 1 / 2")
}
}
ToolbarItem(placement: .topBarTrailing){
Button{
showHelpDialog.toggle()
} label: {
Image(systemName: "questionmark.bubble")
}
}
}
.alert("Exit", isPresented: $showMoveBackConfirm){
Button("Cancel", role: .cancel) { }
Button("Confirm", role: .destructive) {dismiss()}
}
.alert("Hint", isPresented: $showHelpDialog){
Button("OK", role: .cancel) { }
}
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... om-toolbar
Мобильная версия