4.5 C
New York
Thursday, December 12, 2024

ios – SideMenu Gadgets Navigation in swiftUI


I simply need to requested in regards to the aspect Menu gadgets navigation Now the Principal level is my app has 4 tabs suppose tab1,tab2,tab3,tab4 so in tab1 display i open and shut the aspect Menu this works prefectly however when i click on the gadgets of sideMenu merchandise then nothing occur. My aspect menu all code is

struct SideMenuView: View {
    @Binding var isShowing: Bool
    @State personal var isOn = false
    
    //    @State personal var selectedDestination: MenuDestination?
    //       @Atmosphere(.dismiss) personal var dismiss
    
    let profile = UserProfile(
        title: "Mr. Henry Edward",
        earningPoints: 556,
        profileImage: "particular person.circle.fill"
    )
    
    let menuItems = [
        SideMenuItem(title: "Edit your info", icon: "edit-profile", destination: .profile),
        SideMenuItem(title: "Order History", icon: "order-history", destination: .orderHistory),
        SideMenuItem(title: "Reviews", icon: "ranking", destination: .reviews),
        SideMenuItem(title: "Setting", icon: "settings", destination: .settings),
        SideMenuItem(title: "Change Password", icon: "cart", destination: .changePassword),
        SideMenuItem(title: "Franchise Locations", icon: "maps-location", destination: .franchiseLocations),
        SideMenuItem(title: "Terms & Conditions", icon: "terms", destination: .termsConditions)
    ]
    
    
    var physique: some View {
        ZStack {
            // Dimmed Background
            if isShowing {
                Coloration.black
                    .opacity(0.5)
                    .ignoresSafeArea()
                    .onTapGesture {
                        withAnimation(.spring()) {
                            isShowing.toggle()
                        }
                    }
            }
            
            //MARK: - Menu Content material
            HStack {
                VStack(spacing: 0) {
                    // Profile Header
                    
                    HStack{
                        Picture(.again)
                            .onTapGesture {
                                isShowing = false
                            }
                        Spacer()
                        Toggle(isOn: $isOn) {
                            
                        }
                        
                        
                    }
                    .padding()
                    .padding(.prime,70)
                    
                    ZStack {
                        Rectangle()
                            .fill(Coloration(.tabBackground))
                            .body(width: 290, peak: 112)
                            .cornerRadius(10)
                            .padding()
                        
                        HStack(spacing: 16) {
                            Picture(.particular person)
                                .resizable()
                                .aspectRatio(contentMode: .fill)
                                .body(width: 40, peak: 40)
                                .clipShape(Circle())
                                .overlay(Circle().stroke(Coloration.white, lineWidth: 2))
                            
                            VStack  (profile.earningPoints)")
                                    .font(Font.customized("Poppins-Medium", measurement: 11))
                                    .body(width: 150, peak: 22)
                                    .foregroundColor(.black)
                                    .background(Coloration.white)
                                    .cornerRadius(5)
                                
                            
                            Picture(.qrScan)
                                .applyTapAnimation()
                                .onTapGesture {
                                    
                                }
                            
                        }
                        .padding(.prime, 20)
                        
                    }
                    
                    ScrollView {
                        VStack(spacing: 0) {
                            ForEach(menuItems) { merchandise in
                                NavigationLink(vacation spot: destinationView(for: merchandise.vacation spot)) {
                                    ProfileMenuItem(merchandise: merchandise)
                                }
                                
                            }
                            
                            Spacer()
                            
                            AuthButton(title: "Logout", icon: Picture(.logout), backgroundColor: .clear, motion: {})
                                .padding()
                                .foregroundColor(.tabBackground)
                            
                        }
                        .background(Coloration(UIColor.systemBackground))
                    }
                }
                .body(width: UIScreen.fundamental.bounds.width * 0.8)
                .background(Coloration(UIColor.systemBackground))
                .cornerRadius(20, corners: [.topRight,.bottomRight])
                .offset(x: isShowing ? 0 : -UIScreen.fundamental.bounds.width)
                .animation(.spring(), worth: isShowing)
                
                
                
                Spacer()
            }
            .ignoresSafeArea()
            
        }
    }
    
}

#Preview {
    SideMenuView(isShowing: .fixed(true))
}


struct ProfileMenuItem: View {
    let merchandise: SideMenuItem
    
    
    var physique: some View {
        Button(motion: {}) {
            HStack(spacing:16) {
                Picture(merchandise.icon)
                    .body(width: 24, peak: 24)
                    .foregroundStyle(.colorBlack)
                
                
                Textual content(merchandise.title)
                    .foregroundColor(.black)
                    .font(Font.customized("Poppins-Medium", measurement: 14))
                
                Spacer()
                
                Picture(systemName: "chevron.proper")
                    .foregroundColor(.black)
            }
            .padding()
            .background(Coloration.card)
            .cornerRadius(20)
            .padding(.horizontal, 26)
            .padding(.vertical, 5)
            
        }
        
    }
}


@ViewBuilder
personal func destinationView(for vacation spot: MenuDestination) -> some View {
    swap vacation spot {
    case .profile:
        ProfileView()
    case .orderHistory:
        OrderHistoryView()
    case .opinions:
        ReviewsView()
    case .settings:
        SettingsView()
    case .changePassword:
        ChangePasswordView()
    case .franchiseLocations:
        FranchiseLocationsView()
    case .termsConditions:
        TermsConditionsView()
    }
}

I need to open corresponding view of Merchandise when click on on merchandise.Observe that my app has additionally 4 tabs and in tab 1 display aspect menu open and shut on button click on then how we handle the aspect Menu gadgets views. however i need to present siudeMenu gadgets views independently means not within the tabs

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles