ios: fix alert reseting list position (#4554)

Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com>
This commit is contained in:
Arturs Krumins
2024-08-01 12:21:31 +03:00
committed by GitHub
parent 229ea80499
commit bfab2d9fb6
+18 -18
View File
@@ -72,25 +72,25 @@ extension View {
_ errorAlert: Binding<ErrorAlert?>,
@ViewBuilder actions: (ErrorAlert) -> A = { _ in EmptyView() }
) -> some View {
if let alert = errorAlert.wrappedValue {
self.alert(
alert.title,
isPresented: Binding<Bool>(
get: { errorAlert.wrappedValue != nil },
set: { if !$0 { errorAlert.wrappedValue = nil } }
),
actions: {
if let actions_ = alert.actions {
actions_()
} else {
actions(alert)
}
},
message: {
if let message = alert.message { Text(message) }
alert(
errorAlert.wrappedValue?.title ?? "",
isPresented: Binding<Bool>(
get: { errorAlert.wrappedValue != nil },
set: { if !$0 { errorAlert.wrappedValue = nil } }
),
actions: {
if let actions_ = errorAlert.wrappedValue?.actions {
actions_()
} else {
if let alert = errorAlert.wrappedValue { actions(alert) }
}
)
} else { self }
},
message: {
if let message = errorAlert.wrappedValue?.message {
Text(message)
}
}
)
}
}