Post

Replies

Boosts

Views

Activity

navigationDestination does not work
In the code below, I want to do a MbtiEntryView() transition, but I can't. What are the possible causes? By the way, GenderEntryView is transitioned from the previous View using NavigationStack. Version: iOS17 or later struct GenderEntryView: View { @Environment(\.dismiss) var dismiss @StateObject private var viewModel = UserDataViewModel() @State private var selectedIndex = 0 @State private var isPresented = false private let selectNames = ["男性", "女性", "その他"] var body: some View { VStack{ TextComponent(text: "性別を教えてください", foregroundStyle: .black, fontSize: 20) .frame(width: 260) .padding(.top, 50) .multilineTextAlignment(.center) List{ ForEach(0..<selectNames.count, id: \.self, content: { index in HStack{ TextComponent(text: selectNames[index], foregroundStyle: .black, fontSize: 20) Spacer() if selectedIndex == index { Image(systemName: "checkmark.circle.fill") .foregroundColor(.black) } } .padding(.vertical,20) .contentShape(Rectangle()) .onTapGesture { selectedIndex = index } }) } .scrollContentBackground(.hidden) .padding(.top,20) Spacer() ButtonComponentView(buttonText: "つぎへ", action: { viewModel.saveGender(gender: selectNames[selectedIndex]) isPresented = true }, paddingValue: 30, accessibilityLabel: "つぎへ", backgroundColor: .black, textColor: .white) ButtonComponentView(buttonText: "スキップ", action: { isPresented = true }, paddingValue: 80, accessibilityLabel: "スキップ", backgroundColor: .lowGray, textColor: .black) } .navigationTitle("Future") .navigationBarTitleDisplayMode(.inline) .navigationBarBackButtonHidden(true) .toolbar { backButtonToolbarItem(dismiss: { dismiss() }) } .navigationDestination(isPresented: $isPresented) { MbtiEntryView() } } } #Preview { GenderEntryView() }
1
0
751
Feb ’24