ios – View Flickering When Choosing the Picker Option


When changing the picker from “None” to any other, it flickers to the left of the screen and only then goes away. When changing the other properties, it is working fine.

This is the picker with Alert Options (I don’t think there is something wrong here, but anyways):

HStack {
                                Text("Alert")
                                    .font(.title3.bold())
                                Spacer()
                                Picker("Alert", selection:
                                        detailType == .event
                                       ?
                                        $calendarViewModel.selectedEvent.alert
                                       :
                                        $remindersViewModel.selectedReminder.alert
                                ) {
                                    ForEach(Event.Alerts.allCases, id: \.self) { alert in
                                        Text(alert.rawValue)
                                    }
                                }
                            }
                            .onChange(of:
                                        detailType == .event
                                      ?
                                       calendarViewModel.selectedEvent.alert
                                      :
                                       remindersViewModel.selectedReminder.alert
                            ) { alert in
                                remindersViewModel.center.getNotificationSettings { settings in
                                    if settings.authorizationStatus != .authorized && alert != .noAlerts {
                                        remindersViewModel.center.requestAuthorization(options: [.alert, .badge, .sound]) { success, error in
                                            if !success {
                                                Task { @MainActor in
                                                    switch detailType {
                                                    case .reminder:
                                                        remindersViewModel.showingAlertErrorAlert = true
                                                    case .event:
                                                        calendarViewModel.showingAlertErrorAlert = true
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }

I think “flickering” of the picker is connected to this segment of code showing only when the picker option is not “None”:

// MARK: - Optional Alert Misc Info
                        Group {
                            HStack {
                                Text("Additional Alert Settings")
                                
                                Image(systemName: "chevron.right")
                                    .rotationEffect(alertSettingsTapped ? .degrees(90) : .degrees(0))
                            }
                            .font(.system(size: 15, weight: .bold))
                            .onTapGesture {
                                alertSettingsTapped.toggle()
                            }
                            .padding(.vertical)
                            
                            // MARK: - List of additional alert settings
                            ZStack {
                            }
                            .tint(.black)
                            .opacity(alertSettingsTapped ? 1 : 0)
                            
                        }
                        .animation(.default, value: alertSettingsTapped)
                        .opacity(correctAlertType != .noAlerts ? 1 : 0)
                        .animation(.default, value: correctAlertType)

Here is also small video with the problem I am facing:
problem

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img