iOS Development

ios – View Flickering When Selecting the Picker Choice

Spread the love


When altering the picker from “None” to another, it sparkles to the left of the display screen and solely then goes away. When altering the opposite properties, it’s working high-quality.

That is the picker with Alert Choices (I do not assume there’s something flawed right here, however in any case):

HStack {
                                Textual content("Alert")
                                    .font(.title3.daring())
                                Spacer()
                                Picker("Alert", choice:
                                        detailType == .occasion
                                       ?
                                        $calendarViewModel.selectedEvent.alert
                                       :
                                        $remindersViewModel.selectedReminder.alert
                                ) {
                                    ForEach(Occasion.Alerts.allCases, id: .self) { alert in
                                        Textual content(alert.rawValue)
                                    }
                                }
                            }
                            .onChange(of:
                                        detailType == .occasion
                                      ?
                                       calendarViewModel.selectedEvent.alert
                                      :
                                       remindersViewModel.selectedReminder.alert
                            ) { alert in
                                remindersViewModel.middle.getNotificationSettings { settings in
                                    if settings.authorizationStatus != .approved && alert != .noAlerts {
                                        remindersViewModel.middle.requestAuthorization(choices: [.alert, .badge, .sound]) { success, error in
                                            if !success {
                                                Job { @MainActor in
                                                    swap detailType {
                                                    case .reminder:
                                                        remindersViewModel.showingAlertErrorAlert = true
                                                    case .occasion:
                                                        calendarViewModel.showingAlertErrorAlert = true
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }

I believe “flickering” of the picker is linked to this phase of code displaying solely when the picker choice is just not “None”:

// MARK: - Optionally available Alert Misc Information
                        Group {
                            HStack {
                                Textual content("Further Alert Settings")
                                
                                Picture(systemName: "chevron.proper")
                                    .rotationEffect(alertSettingsTapped ? .levels(90) : .levels(0))
                            }
                            .font(.system(dimension: 15, weight: .daring))
                            .onTapGesture {
                                alertSettingsTapped.toggle()
                            }
                            .padding(.vertical)
                            
                            // MARK: - Record of extra alert settings
                            ZStack {
                            }
                            .tint(.black)
                            .opacity(alertSettingsTapped ? 1 : 0)
                            
                        }
                        .animation(.default, worth: alertSettingsTapped)
                        .opacity(correctAlertType != .noAlerts ? 1 : 0)
                        .animation(.default, worth: correctAlertType)

Right here can be small video with the issue I’m going through:
problem

Leave a Reply

Your email address will not be published. Required fields are marked *