Skip to content

Commit e7441dc

Browse files
authored
Fix some Xcode 26.4 warnings (#330)
1 parent 2dc175f commit e7441dc

File tree

3 files changed

+59
-7
lines changed

3 files changed

+59
-7
lines changed

Sources/SwiftUINavigation/Alert.swift

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,22 @@
231231
)
232232
}
233233

234+
/// Presents an alert from a binding to optional alert state.
235+
///
236+
/// See <doc:AlertsDialogs> for more information on how to use this API.
237+
///
238+
/// - Parameter state: A binding to optional alert state that determines whether an alert should
239+
/// be presented. When the binding is updated with non-`nil` value, it is unwrapped and used
240+
/// to populate the fields of an alert that the system displays to the user. When the user
241+
/// presses or taps one of the alert's actions, the system sets this value to `nil` and
242+
/// dismisses the alert, and the action is fed to the `action` closure.
243+
#if compiler(>=6)
244+
@MainActor
245+
#endif
246+
public func alert<Value>(_ state: Binding<AlertState<Value>?>) -> some View {
247+
alert(state) { _ in }
248+
}
249+
234250
/// Presents an alert from a binding to optional alert state.
235251
///
236252
/// See <doc:AlertsDialogs> for more information on how to use this API.
@@ -248,7 +264,7 @@
248264
#endif
249265
public func alert<Value>(
250266
_ state: Binding<AlertState<Value>?>,
251-
action handler: @escaping (Value?) -> Void = { (_: Never?) in }
267+
action handler: @escaping (Value?) -> Void
252268
) -> some View {
253269
alert(item: state) {
254270
Text($0.title)
@@ -278,7 +294,7 @@
278294
/// tapped.
279295
public func alert<Value: Sendable>(
280296
_ state: Binding<AlertState<Value>?>,
281-
action handler: @escaping @Sendable (Value?) async -> Void = { (_: Never?) async in }
297+
action handler: @escaping @Sendable (Value?) async -> Void
282298
) -> some View {
283299
alert(item: state) {
284300
Text($0.title)

Sources/SwiftUINavigation/ConfirmationDialog.swift

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,21 @@
160160
)
161161
}
162162

163+
/// Presents a confirmation dialog from a binding to optional confirmation dialog state.
164+
///
165+
/// See <doc:AlertsDialogs> for more information on how to use this API.
166+
///
167+
/// - Parameter state: A binding to optional state that determines whether a confirmation dialog
168+
/// should be presented. When the binding is updated with non-`nil` value, it is unwrapped and
169+
/// used to populate the fields of a dialog that the system displays to the user. When the
170+
/// user presses or taps one of the dialog's actions, the system sets this value to `nil` and
171+
/// dismisses the dialog, and the action is fed to the `action` closure.
172+
public func confirmationDialog<Value>(
173+
_ state: Binding<ConfirmationDialogState<Value>?>,
174+
) -> some View {
175+
confirmationDialog(state) { _ in }
176+
}
177+
163178
/// Presents a confirmation dialog from a binding to optional confirmation dialog state.
164179
///
165180
/// See <doc:AlertsDialogs> for more information on how to use this API.
@@ -174,7 +189,7 @@
174189
/// tapped.
175190
public func confirmationDialog<Value>(
176191
_ state: Binding<ConfirmationDialogState<Value>?>,
177-
action handler: @escaping (Value?) -> Void = { (_: Never?) in }
192+
action handler: @escaping (Value?) -> Void
178193
) -> some View {
179194
confirmationDialog(
180195
item: state,
@@ -207,7 +222,7 @@
207222
/// tapped.
208223
public func confirmationDialog<Value: Sendable>(
209224
_ state: Binding<ConfirmationDialogState<Value>?>,
210-
action handler: @escaping @Sendable (Value?) async -> Void = { (_: Never?) async in }
225+
action handler: @escaping @Sendable (Value?) async -> Void
211226
) -> some View {
212227
confirmationDialog(
213228
item: state,

Sources/UIKitNavigation/Navigation/UIAlertController.swift

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,21 @@
77
@available(tvOS 13, *)
88
@available(watchOS, unavailable)
99
extension UIAlertController {
10+
/// Creates and returns a view controller for displaying an alert using a data description.
11+
///
12+
/// - Parameter state: A data description of the alert.
13+
public convenience init<Action>(state: AlertState<Action>) {
14+
self.init(state: state) { _ in }
15+
}
16+
1017
/// Creates and returns a view controller for displaying an alert using a data description.
1118
///
1219
/// - Parameters:
1320
/// - state: A data description of the alert.
1421
/// - handler: A closure that is invoked with an action held in `state`.
1522
public convenience init<Action>(
1623
state: AlertState<Action>,
17-
handler: @escaping (_ action: Action?) -> Void = { (_: Never?) in }
24+
handler: @escaping (_ action: Action?) -> Void
1825
) {
1926
self.init(
2027
title: String(state: state.title),
@@ -29,6 +36,14 @@
2936
}
3037
}
3138

39+
/// Creates and returns a view controller for displaying an action sheet using a data
40+
/// description.
41+
///
42+
/// - Parameter state: A data description of the alert.
43+
public convenience init<Action>(state: ConfirmationDialogState<Action>) {
44+
self.init(state: state) { _ in }
45+
}
46+
3247
/// Creates and returns a view controller for displaying an action sheet using a data
3348
/// description.
3449
///
@@ -37,7 +52,7 @@
3752
/// - handler: A closure that is invoked with an action held in `state`.
3853
public convenience init<Action>(
3954
state: ConfirmationDialogState<Action>,
40-
handler: @escaping (_ action: Action?) -> Void = { (_: Never?) in }
55+
handler: @escaping (_ action: Action?) -> Void
4156
) {
4257
self.init(
4358
title: {
@@ -92,7 +107,13 @@
92107
extension UIAlertAction {
93108
public convenience init<Action>(
94109
_ button: ButtonState<Action>,
95-
action handler: @escaping (_ action: Action?) -> Void = { (_: Never?) in }
110+
) {
111+
self.init(button) { _ in }
112+
}
113+
114+
public convenience init<Action>(
115+
_ button: ButtonState<Action>,
116+
action handler: @escaping (_ action: Action?) -> Void
96117
) {
97118
self.init(
98119
title: String(state: button.label),

0 commit comments

Comments
 (0)