Skip to content

Commit d63ae70

Browse files
committed
UI: add docs to AlertAction, AlertController
Add additional documentation for the members of these types.
1 parent 4d1d062 commit d63ae70

File tree

2 files changed

+36
-16
lines changed

2 files changed

+36
-16
lines changed

Sources/SwiftWin32/Windows and Screens/AlertAction.swift

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,25 @@
22
// SPDX-License-Identifier: BSD-3-Clause
33

44
extension AlertAction {
5+
/// Styles to apply to action buttons in an alert.
56
public enum Style: Int {
6-
case `default`
7-
case cancel
8-
case destructive
7+
/// Apply the default style to the action’s button.
8+
case `default`
9+
10+
/// Apply a style that indicates the action cancels the operation and leaves
11+
/// things unchanged.
12+
case cancel
13+
14+
/// Apply a style that indicates the action might change or delete data.
15+
case destructive
916
}
1017
}
1118

19+
/// An action that can be taken when the user taps a button in an alert.
1220
public class AlertAction {
1321
private let handler: ((AlertAction) -> Void)?
1422

15-
/// Creating an Alert Action
23+
// MARK - Creating an Alert Action
1624

1725
/// Create and return an action with the specified title and behavior.
1826
public init(title: String?, style: AlertAction.Style,
@@ -23,7 +31,7 @@ public class AlertAction {
2331
self.handler = handler
2432
}
2533

26-
/// Getting the Action's Attributes
34+
// MARK - Getting the Action's Attributes
2735

2836
/// The title of the action’s button.
2937
public let title: String?

Sources/SwiftWin32/Windows and Screens/AlertController.swift

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,41 @@
44
extension AlertController {
55
/// Constants indicating the type of alert to display.
66
public enum Style: Int {
7+
/// An action sheet displayed in the context of the view controller that
8+
/// presented it.
79
case actionSheet
10+
11+
/// An alert displayed modally for the app.
812
case alert
913
}
1014
}
1115

16+
/// An object that displays an alert message to the user.
1217
public class AlertController: ViewController {
13-
/// Configuring the Alert
18+
// MARK - Configuring the Alert
19+
20+
/// Descriptive text that provides more details about the reason for the
21+
/// alert.
1422
public var message: String?
23+
24+
/// The style of the alert controller.
1525
public let preferredStyle: AlertController.Style
1626

17-
/// Creating an Alert Controller
27+
// MARK - Creating an Alert Controller
28+
29+
/// Creates and returns a view controller for displaying an alert to the user.
1830
public init(title: String?, message: String?,
1931
preferredStyle: AlertController.Style) {
2032
self.message = message
2133
self.preferredStyle = preferredStyle
2234
super.init()
2335
}
2436

25-
/// Configuring the User Actions
37+
// MARK - Configuring the User Actions
38+
39+
/// Attaches an action object to the alert or action sheet.
40+
public func addAction(_ action: AlertAction) {
41+
}
2642

2743
/// The actions that the user can take in response to the alert or action
2844
/// sheet.
@@ -31,16 +47,12 @@ public class AlertController: ViewController {
3147
/// The preferred action for the user to take from an alert.
3248
public var preferredAction: AlertAction?
3349

34-
/// Attaches an action object to the alert or action sheet.
35-
public func addAction(_ action: AlertAction) {
36-
}
37-
38-
/// Configuring Text Fields
39-
40-
/// The array of text fields displayed by the alert.
41-
public private(set) var textFields: [TextField]?
50+
// MARK - Configuring Text Fields
4251

4352
/// Adds a text field to an alert.
4453
public func addTextField(configurationHandler: ((TextField) -> Void)? = nil) {
4554
}
55+
56+
/// The array of text fields displayed by the alert.
57+
public private(set) var textFields: [TextField]?
4658
}

0 commit comments

Comments
 (0)