Post

Replies

Boosts

Views

Activity

Reply to SwiftUI App crashes while switching orientation
Here is the Home view... struct HomeView: View { @Namespace var namespace var homeWidgetConfigurations = LoadHomeWidgetConfigurations() @State private var scale: CGFloat = 1.0 @State private var offset: CGFloat = 0 @Environment(.colorScheme) private var deviceColorScheme var body: some View { GeometryReader { geometry in VStack { NavigationStack { ScrollView { Label("Home", systemImage: "house.fill") .font(.title2) .fontWeight(.bold) .foregroundColor(deviceColorScheme == .light ? .black : .black) .padding() .background( LinearGradient(gradient: Gradient(colors: [deviceColorScheme == .light ? .gray : .white, deviceColorScheme == .light ? .yellow : .yellow]), startPoint: .top, endPoint: .bottom) ) .cornerRadius(10) Text("") ForEach(homeWidgetConfigurations, id: \.id) { image in NavigationLink(value: image) { WidgetsView(widget: image) .matchedTransitionSource(id: image.id, in: namespace, configuration: { source in source .background(Color.yellow) .clipShape(RoundedRectangle(cornerRadius: 20)) }) } .clipShape(RoundedRectangle(cornerRadius: 10)) .shadow(radius: 10) .shadow(radius: 15) .shadow(radius: 20) .shadow(radius: 20) .shadow(radius: 20) .shadow(radius: 20) .shadow(radius: 20) .padding(.horizontal, 7) } } .navigationDestination(for: HomeViewWidgetItem.self) { item in DismissableView { if (item.title == "Entertainment"){ EntertainmentView() .navigationTransition(.zoom(sourceID: item.id, in: namespace)) } else if (item.title == "News"){ NewsHomeView() .navigationTransition(.zoom(sourceID: item.id, in: namespace)) } else{ Text ("In Dismissable View") } } } } } //end of VStack } //end of Geometry }
Nov ’24