react-native-unified-action-sheet 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -1
- package/README.md +25 -113
- package/android/build.gradle +28 -1
- package/android/src/main/java/com/unifiedactionsheet/ActionSheetOptions.kt +6 -2
- package/android/src/main/java/com/unifiedactionsheet/UnifiedActionSheetModule.kt +6 -0
- package/android/src/material/java/com/unifiedactionsheet/BottomSheetPresenterFactory.kt +10 -0
- package/android/src/material/java/com/unifiedactionsheet/MaterialBottomSheetPresenter.kt +90 -0
- package/android/src/material/res/values/unified_action_sheet_bottom_sheet.xml +22 -0
- package/android/src/noMaterial/java/com/unifiedactionsheet/BottomSheetPresenterFactory.kt +10 -0
- package/app.plugin.js +1 -0
- package/ios/BottomSheetViewController.swift +208 -0
- package/ios/UnifiedActionSheet.mm +26 -1
- package/ios/UnifiedActionSheetImpl.swift +147 -7
- package/lib/commonjs/NativeUnifiedActionSheet.js.map +1 -1
- package/lib/commonjs/index.js +18 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/NativeUnifiedActionSheet.js.map +1 -1
- package/lib/module/index.js +18 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/NativeUnifiedActionSheet.d.ts +3 -0
- package/lib/typescript/commonjs/src/NativeUnifiedActionSheet.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/action-sheet-options.interface.d.ts +1 -1
- package/lib/typescript/commonjs/src/action-sheet-options.interface.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeUnifiedActionSheet.d.ts +3 -0
- package/lib/typescript/module/src/NativeUnifiedActionSheet.d.ts.map +1 -1
- package/lib/typescript/module/src/action-sheet-options.interface.d.ts +1 -1
- package/lib/typescript/module/src/action-sheet-options.interface.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/package.json +12 -2
- package/plugin/withUnifiedActionSheet.js +58 -0
- package/src/NativeUnifiedActionSheet.ts +5 -0
- package/src/action-sheet-options.interface.ts +1 -1
- package/src/index.tsx +35 -3
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
|
|
3
|
+
/// presentationStyle 'bottom' on iPhone: the rows of an action sheet inside a
|
|
4
|
+
/// UISheetPresentationController, which UIAlertController cannot be. Styled
|
|
5
|
+
/// like the rest of iOS rather than like the Android sheet: system fonts, the
|
|
6
|
+
/// label color (or tintColor), system red for destructive rows.
|
|
7
|
+
final class BottomSheetViewController: UIViewController {
|
|
8
|
+
struct Row {
|
|
9
|
+
let index: Int
|
|
10
|
+
let label: String
|
|
11
|
+
let isDestructive: Bool
|
|
12
|
+
let isEnabled: Bool
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
private let sheetTitle: String?
|
|
16
|
+
private let message: String?
|
|
17
|
+
private let rows: [Row]
|
|
18
|
+
private let cancelRow: Row?
|
|
19
|
+
private let tintColor: UIColor?
|
|
20
|
+
private let cancelButtonTintColor: UIColor?
|
|
21
|
+
private let destructiveColor: UIColor?
|
|
22
|
+
/// Set by the presenter once it can resolve the sheet.
|
|
23
|
+
var onSelect: ((Int) -> Void)?
|
|
24
|
+
|
|
25
|
+
private let scrollView = UIScrollView()
|
|
26
|
+
private let stack = UIStackView()
|
|
27
|
+
|
|
28
|
+
init(
|
|
29
|
+
title: String?,
|
|
30
|
+
message: String?,
|
|
31
|
+
rows: [Row],
|
|
32
|
+
cancelRow: Row?,
|
|
33
|
+
tintColor: UIColor?,
|
|
34
|
+
cancelButtonTintColor: UIColor?,
|
|
35
|
+
destructiveColor: UIColor?
|
|
36
|
+
) {
|
|
37
|
+
self.sheetTitle = title
|
|
38
|
+
self.message = message
|
|
39
|
+
self.rows = rows
|
|
40
|
+
self.cancelRow = cancelRow
|
|
41
|
+
self.tintColor = tintColor
|
|
42
|
+
self.cancelButtonTintColor = cancelButtonTintColor
|
|
43
|
+
self.destructiveColor = destructiveColor
|
|
44
|
+
super.init(nibName: nil, bundle: nil)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@available(*, unavailable)
|
|
48
|
+
required init?(coder: NSCoder) {
|
|
49
|
+
fatalError("init(coder:) is not supported")
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
override func viewDidLoad() {
|
|
53
|
+
super.viewDidLoad()
|
|
54
|
+
|
|
55
|
+
// From iOS 26 the system draws the sheet's Liquid Glass background; an
|
|
56
|
+
// opaque color here would cover it.
|
|
57
|
+
if #available(iOS 26.0, *) {
|
|
58
|
+
view.backgroundColor = .clear
|
|
59
|
+
} else {
|
|
60
|
+
view.backgroundColor = .systemBackground
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
stack.axis = .vertical
|
|
64
|
+
stack.translatesAutoresizingMaskIntoConstraints = false
|
|
65
|
+
scrollView.translatesAutoresizingMaskIntoConstraints = false
|
|
66
|
+
scrollView.alwaysBounceVertical = false
|
|
67
|
+
scrollView.addSubview(stack)
|
|
68
|
+
view.addSubview(scrollView)
|
|
69
|
+
|
|
70
|
+
NSLayoutConstraint.activate([
|
|
71
|
+
scrollView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
|
|
72
|
+
scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
|
73
|
+
scrollView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
|
74
|
+
scrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
|
|
75
|
+
stack.topAnchor.constraint(equalTo: scrollView.contentLayoutGuide.topAnchor),
|
|
76
|
+
stack.leadingAnchor.constraint(equalTo: scrollView.contentLayoutGuide.leadingAnchor),
|
|
77
|
+
stack.trailingAnchor.constraint(equalTo: scrollView.contentLayoutGuide.trailingAnchor),
|
|
78
|
+
stack.bottomAnchor.constraint(equalTo: scrollView.contentLayoutGuide.bottomAnchor),
|
|
79
|
+
stack.widthAnchor.constraint(equalTo: scrollView.frameLayoutGuide.widthAnchor),
|
|
80
|
+
])
|
|
81
|
+
|
|
82
|
+
// The last row stays clear of the home indicator once scrolled to it.
|
|
83
|
+
scrollView.contentInsetAdjustmentBehavior = .always
|
|
84
|
+
|
|
85
|
+
buildContent()
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/// The height the content wants at the given width, for the fitted detent.
|
|
89
|
+
func fittingHeight(width: CGFloat) -> CGFloat {
|
|
90
|
+
loadViewIfNeeded()
|
|
91
|
+
|
|
92
|
+
return stack.systemLayoutSizeFitting(
|
|
93
|
+
CGSize(width: width, height: UIView.layoutFittingCompressedSize.height),
|
|
94
|
+
withHorizontalFittingPriority: .required,
|
|
95
|
+
verticalFittingPriority: .fittingSizeLevel
|
|
96
|
+
).height
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private func buildContent() {
|
|
100
|
+
// Room for the grabber, which the sheet draws over the top of the view.
|
|
101
|
+
stack.addArrangedSubview(spacer(height: 20))
|
|
102
|
+
|
|
103
|
+
if let sheetTitle {
|
|
104
|
+
stack.addArrangedSubview(header(sheetTitle, style: .subheadline, weight: .semibold))
|
|
105
|
+
}
|
|
106
|
+
if let message {
|
|
107
|
+
stack.addArrangedSubview(header(message, style: .footnote, weight: .regular))
|
|
108
|
+
}
|
|
109
|
+
if sheetTitle != nil || message != nil {
|
|
110
|
+
stack.addArrangedSubview(spacer(height: 8))
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
for row in rows {
|
|
114
|
+
stack.addArrangedSubview(button(for: row, isCancel: false))
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if let cancelRow {
|
|
118
|
+
let separator = UIView()
|
|
119
|
+
separator.backgroundColor = .separator
|
|
120
|
+
separator.heightAnchor.constraint(equalToConstant: 1 / traitCollection.displayScale).isActive = true
|
|
121
|
+
stack.addArrangedSubview(spacer(height: 8))
|
|
122
|
+
stack.addArrangedSubview(separator)
|
|
123
|
+
stack.addArrangedSubview(button(for: cancelRow, isCancel: true))
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
stack.addArrangedSubview(spacer(height: 8))
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private func header(_ text: String, style: UIFont.TextStyle, weight: UIFont.Weight) -> UIView {
|
|
130
|
+
let label = UILabel()
|
|
131
|
+
label.text = text
|
|
132
|
+
label.numberOfLines = 0
|
|
133
|
+
label.textAlignment = .center
|
|
134
|
+
label.textColor = .secondaryLabel
|
|
135
|
+
label.adjustsFontForContentSizeCategory = true
|
|
136
|
+
label.font = UIFontMetrics(forTextStyle: style).scaledFont(
|
|
137
|
+
for: .systemFont(ofSize: UIFont.preferredFont(forTextStyle: style).pointSize, weight: weight)
|
|
138
|
+
)
|
|
139
|
+
if weight == .semibold {
|
|
140
|
+
label.accessibilityTraits.insert(.header)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
let container = UIView()
|
|
144
|
+
label.translatesAutoresizingMaskIntoConstraints = false
|
|
145
|
+
container.addSubview(label)
|
|
146
|
+
NSLayoutConstraint.activate([
|
|
147
|
+
label.topAnchor.constraint(equalTo: container.topAnchor, constant: 4),
|
|
148
|
+
label.bottomAnchor.constraint(equalTo: container.bottomAnchor, constant: -4),
|
|
149
|
+
label.leadingAnchor.constraint(equalTo: container.layoutMarginsGuide.leadingAnchor),
|
|
150
|
+
label.trailingAnchor.constraint(equalTo: container.layoutMarginsGuide.trailingAnchor),
|
|
151
|
+
])
|
|
152
|
+
container.directionalLayoutMargins = NSDirectionalEdgeInsets(top: 0, leading: 20, bottom: 0, trailing: 20)
|
|
153
|
+
|
|
154
|
+
return container
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
private func button(for row: Row, isCancel: Bool) -> UIButton {
|
|
158
|
+
// Precedence matches the alert: destructive > cancel tint > tint > default.
|
|
159
|
+
let color: UIColor =
|
|
160
|
+
row.isDestructive
|
|
161
|
+
? (destructiveColor ?? .systemRed)
|
|
162
|
+
: (isCancel ? (cancelButtonTintColor ?? tintColor ?? .label) : (tintColor ?? .label))
|
|
163
|
+
|
|
164
|
+
var config = UIButton.Configuration.plain()
|
|
165
|
+
config.title = row.label
|
|
166
|
+
config.baseForegroundColor = color
|
|
167
|
+
config.contentInsets = NSDirectionalEdgeInsets(top: 16, leading: 20, bottom: 16, trailing: 20)
|
|
168
|
+
config.titleAlignment = .leading
|
|
169
|
+
config.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { attributes in
|
|
170
|
+
var attributes = attributes
|
|
171
|
+
attributes.font = UIFont.preferredFont(forTextStyle: .body).withWeight(isCancel ? .semibold : .regular)
|
|
172
|
+
|
|
173
|
+
return attributes
|
|
174
|
+
}
|
|
175
|
+
config.background.cornerRadius = 0
|
|
176
|
+
|
|
177
|
+
let button = UIButton(configuration: config)
|
|
178
|
+
button.contentHorizontalAlignment = .leading
|
|
179
|
+
button.isEnabled = row.isEnabled
|
|
180
|
+
// A full-width row highlight, as in a list, rather than a dimmed title.
|
|
181
|
+
button.configurationUpdateHandler = { button in
|
|
182
|
+
var updated = button.configuration
|
|
183
|
+
updated?.background.backgroundColor = button.isHighlighted ? .systemFill : .clear
|
|
184
|
+
updated?.baseForegroundColor = button.isEnabled ? color : .tertiaryLabel
|
|
185
|
+
button.configuration = updated
|
|
186
|
+
}
|
|
187
|
+
button.addAction(UIAction { [weak self] _ in self?.onSelect?(row.index) }, for: .touchUpInside)
|
|
188
|
+
|
|
189
|
+
return button
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
private func spacer(height: CGFloat) -> UIView {
|
|
193
|
+
let view = UIView()
|
|
194
|
+
view.heightAnchor.constraint(equalToConstant: height).isActive = true
|
|
195
|
+
|
|
196
|
+
return view
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
private extension UIFont {
|
|
201
|
+
func withWeight(_ weight: UIFont.Weight) -> UIFont {
|
|
202
|
+
let descriptor = fontDescriptor.addingAttributes([
|
|
203
|
+
.traits: [UIFontDescriptor.TraitKey.weight: weight],
|
|
204
|
+
])
|
|
205
|
+
|
|
206
|
+
return UIFont(descriptor: descriptor, size: pointSize)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
#import "UnifiedActionSheet.h"
|
|
2
2
|
|
|
3
|
+
#import <React/RCTInvalidating.h>
|
|
3
4
|
#import <RCTTypeSafety/RCTConvertHelpers.h>
|
|
4
5
|
#import <UnifiedActionSheetSpec/UnifiedActionSheetSpec.h>
|
|
5
6
|
|
|
6
7
|
#import "react_native_unified_action_sheet-Swift.h"
|
|
7
8
|
|
|
8
|
-
@interface UnifiedActionSheet () <NativeUnifiedActionSheetSpec>
|
|
9
|
+
@interface UnifiedActionSheet () <NativeUnifiedActionSheetSpec, RCTInvalidating>
|
|
9
10
|
@end
|
|
10
11
|
|
|
11
12
|
@implementation UnifiedActionSheet
|
|
@@ -17,6 +18,20 @@ RCT_EXPORT_MODULE()
|
|
|
17
18
|
return NO;
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
/// Material is an Android opt-in; iOS presents 'bottom' as the standard action
|
|
22
|
+
/// sheet with nothing to enable.
|
|
23
|
+
- (facebook::react::ModuleConstants<JS::NativeUnifiedActionSheet::Constants::Builder>)constantsToExport
|
|
24
|
+
{
|
|
25
|
+
return [self getConstants];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
- (facebook::react::ModuleConstants<JS::NativeUnifiedActionSheet::Constants::Builder>)getConstants
|
|
29
|
+
{
|
|
30
|
+
return facebook::react::typedConstants<JS::NativeUnifiedActionSheet::Constants::Builder>({
|
|
31
|
+
.isMaterialEnabled = false,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
20
35
|
/// Only the keys the iOS presentation understands are forwarded; the
|
|
21
36
|
/// Android-only keys in the shared spec are ignored here.
|
|
22
37
|
RCT_EXPORT_METHOD(showActionSheetWithOptions
|
|
@@ -120,6 +135,16 @@ RCT_EXPORT_METHOD(showPromptWithOptions
|
|
|
120
135
|
});
|
|
121
136
|
}
|
|
122
137
|
|
|
138
|
+
/// A reload (or any teardown of the JS runtime) replaces the app's root view,
|
|
139
|
+
/// but the sheets are presented over it and would otherwise stay on screen.
|
|
140
|
+
/// Android closes its dialogs in its own invalidate().
|
|
141
|
+
- (void)invalidate
|
|
142
|
+
{
|
|
143
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
144
|
+
[UnifiedActionSheetImpl.shared invalidate];
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
123
148
|
RCT_EXPORT_METHOD(dismissActionSheet)
|
|
124
149
|
{
|
|
125
150
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
@@ -2,7 +2,9 @@ import Foundation
|
|
|
2
2
|
import UIKit
|
|
3
3
|
|
|
4
4
|
@objc(UnifiedActionSheetImpl)
|
|
5
|
-
public class UnifiedActionSheetImpl: NSObject, UIPopoverPresentationControllerDelegate
|
|
5
|
+
public class UnifiedActionSheetImpl: NSObject, UIPopoverPresentationControllerDelegate,
|
|
6
|
+
UISheetPresentationControllerDelegate
|
|
7
|
+
{
|
|
6
8
|
@objc public static let shared = UnifiedActionSheetImpl()
|
|
7
9
|
|
|
8
10
|
private static let dismissedByApi = -2
|
|
@@ -31,6 +33,28 @@ public class UnifiedActionSheetImpl: NSObject, UIPopoverPresentationControllerDe
|
|
|
31
33
|
return
|
|
32
34
|
}
|
|
33
35
|
|
|
36
|
+
// 'bottom' is a real sheet on iPhone. iPad keeps the action sheet below,
|
|
37
|
+
// which presents as a popover there: a sheet on iPad is a centered form
|
|
38
|
+
// sheet, not attached to the bottom at all.
|
|
39
|
+
if options["presentationStyle"] as? String == "bottom",
|
|
40
|
+
UIDevice.current.userInterfaceIdiom != .pad
|
|
41
|
+
{
|
|
42
|
+
presentBottomSheet(
|
|
43
|
+
on: parent,
|
|
44
|
+
options: options,
|
|
45
|
+
labels: labels,
|
|
46
|
+
cancelButtonIndex: cancelButtonIndex,
|
|
47
|
+
destructiveIndices: destructiveIndices,
|
|
48
|
+
disabledIndices: disabledIndices,
|
|
49
|
+
tintColor: tintColor,
|
|
50
|
+
cancelButtonTintColor: cancelButtonTintColor,
|
|
51
|
+
destructiveColor: destructiveColor,
|
|
52
|
+
completion: completion
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
|
|
34
58
|
// 'centered' maps to UIKit's centered alert style; anything else (including
|
|
35
59
|
// absent, and 'anchored') stays .actionSheet, the iOS default — presented
|
|
36
60
|
// from the bottom on iPhone and as a popover on iPad.
|
|
@@ -191,6 +215,103 @@ public class UnifiedActionSheetImpl: NSObject, UIPopoverPresentationControllerDe
|
|
|
191
215
|
parent.present(alert, animated: true)
|
|
192
216
|
}
|
|
193
217
|
|
|
218
|
+
private func presentBottomSheet(
|
|
219
|
+
on parent: UIViewController,
|
|
220
|
+
options: NSDictionary,
|
|
221
|
+
labels: [String],
|
|
222
|
+
cancelButtonIndex: Int,
|
|
223
|
+
destructiveIndices: Set<Int>,
|
|
224
|
+
disabledIndices: Set<Int>,
|
|
225
|
+
tintColor: UIColor?,
|
|
226
|
+
cancelButtonTintColor: UIColor?,
|
|
227
|
+
destructiveColor: UIColor?,
|
|
228
|
+
completion: @escaping (Int) -> Void
|
|
229
|
+
) {
|
|
230
|
+
let rows = labels.enumerated().map { index, label in
|
|
231
|
+
BottomSheetViewController.Row(
|
|
232
|
+
index: index,
|
|
233
|
+
label: label,
|
|
234
|
+
isDestructive: destructiveIndices.contains(index),
|
|
235
|
+
isEnabled: !disabledIndices.contains(index)
|
|
236
|
+
)
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
let sheet = BottomSheetViewController(
|
|
240
|
+
title: Self.text(options["title"]),
|
|
241
|
+
message: Self.text(options["message"]),
|
|
242
|
+
rows: rows.filter { $0.index != cancelButtonIndex },
|
|
243
|
+
cancelRow: rows.first { $0.index == cancelButtonIndex },
|
|
244
|
+
tintColor: tintColor,
|
|
245
|
+
cancelButtonTintColor: cancelButtonTintColor,
|
|
246
|
+
destructiveColor: destructiveColor
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
let presentation = Presentation(
|
|
250
|
+
controller: sheet,
|
|
251
|
+
cancelButtonIndex: cancelButtonIndex,
|
|
252
|
+
completion: { index, _ in completion(index) }
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
// Weak: the presentation holds the sheet, which holds this closure.
|
|
256
|
+
sheet.onSelect = { [weak self, weak presentation] index in
|
|
257
|
+
guard let presentation else { return }
|
|
258
|
+
|
|
259
|
+
// Unlike an alert action, a row does not dismiss the sheet itself.
|
|
260
|
+
// Resolve once it is gone, as an alert does.
|
|
261
|
+
presentation.controller.dismiss(animated: true) {
|
|
262
|
+
self?.finish(presentation, index: index)
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
switch options["userInterfaceStyle"] as? String {
|
|
267
|
+
case "dark": sheet.overrideUserInterfaceStyle = .dark
|
|
268
|
+
case "light": sheet.overrideUserInterfaceStyle = .light
|
|
269
|
+
default: sheet.overrideUserInterfaceStyle = .unspecified
|
|
270
|
+
}
|
|
271
|
+
sheet.view.tintColor = tintColor
|
|
272
|
+
|
|
273
|
+
if let controller = sheet.sheetPresentationController {
|
|
274
|
+
controller.prefersGrabberVisible = true
|
|
275
|
+
controller.prefersEdgeAttachedInCompactHeight = true
|
|
276
|
+
// Swipe down resolves through presentationControllerDidDismiss.
|
|
277
|
+
controller.delegate = self
|
|
278
|
+
|
|
279
|
+
let bounds = parent.view.window?.bounds ?? parent.view.bounds
|
|
280
|
+
let fitting = sheet.fittingHeight(width: bounds.width)
|
|
281
|
+
|
|
282
|
+
// A short list opens at its own height; a long one opens at half height
|
|
283
|
+
// and drags up to expand, like the Android sheet. Fitting the content
|
|
284
|
+
// needs a custom detent, iOS 16+; iOS 15 opens at half height.
|
|
285
|
+
if #available(iOS 16.0, *), fitting <= bounds.height / 2 {
|
|
286
|
+
controller.detents = [
|
|
287
|
+
.custom(identifier: .init("unifiedActionSheet.content")) { context in
|
|
288
|
+
min(fitting, context.maximumDetentValue)
|
|
289
|
+
},
|
|
290
|
+
]
|
|
291
|
+
} else {
|
|
292
|
+
controller.detents = [.medium(), .large()]
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
presentations.append(presentation)
|
|
297
|
+
parent.present(sheet, animated: true)
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/// Interactive dismissal of a sheet: a swipe down or a tap on the dimmed
|
|
301
|
+
/// area. It resolves the cancel index, or -1 without one, like Android. A
|
|
302
|
+
/// programmatic dismiss() does not call this.
|
|
303
|
+
public func presentationControllerDidDismiss(
|
|
304
|
+
_ presentationController: UIPresentationController
|
|
305
|
+
) {
|
|
306
|
+
guard
|
|
307
|
+
let presentation = presentations.first(where: {
|
|
308
|
+
$0.controller === presentationController.presentedViewController
|
|
309
|
+
})
|
|
310
|
+
else { return }
|
|
311
|
+
|
|
312
|
+
finish(presentation, index: presentation.cancelButtonIndex)
|
|
313
|
+
}
|
|
314
|
+
|
|
194
315
|
@objc public func dismissAll() {
|
|
195
316
|
guard let bottom = presentations.first else { return }
|
|
196
317
|
|
|
@@ -211,6 +332,21 @@ public class UnifiedActionSheetImpl: NSObject, UIPopoverPresentationControllerDe
|
|
|
211
332
|
}
|
|
212
333
|
}
|
|
213
334
|
|
|
335
|
+
/// The JS runtime is going away: close every sheet, prompt and alert, but
|
|
336
|
+
/// resolve none of them. Their promises belong to the runtime being torn
|
|
337
|
+
/// down, and the list is shared, so stale entries must not outlive it.
|
|
338
|
+
@objc public func invalidate() {
|
|
339
|
+
let all = presentations
|
|
340
|
+
presentations.removeAll()
|
|
341
|
+
all.forEach { $0.discard() }
|
|
342
|
+
|
|
343
|
+
// As in dismissAll(): the lowest sheet's presenter dismisses it and
|
|
344
|
+
// everything stacked above it.
|
|
345
|
+
all.first { $0.controller.presentingViewController != nil }?
|
|
346
|
+
.controller.presentingViewController?
|
|
347
|
+
.dismiss(animated: false)
|
|
348
|
+
}
|
|
349
|
+
|
|
214
350
|
@objc public func dismiss() {
|
|
215
351
|
guard let presentation = presentations.last else { return }
|
|
216
352
|
|
|
@@ -224,10 +360,8 @@ public class UnifiedActionSheetImpl: NSObject, UIPopoverPresentationControllerDe
|
|
|
224
360
|
public func popoverPresentationControllerDidDismissPopover(
|
|
225
361
|
_ popoverPresentationController: UIPopoverPresentationController
|
|
226
362
|
) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
as? UIAlertController,
|
|
230
|
-
let presentation = presentations.first(where: { $0.controller === alert })
|
|
363
|
+
let alert = popoverPresentationController.presentedViewController
|
|
364
|
+
guard let presentation = presentations.first(where: { $0.controller === alert })
|
|
231
365
|
else { return }
|
|
232
366
|
|
|
233
367
|
finish(presentation, index: presentation.cancelButtonIndex)
|
|
@@ -241,7 +375,8 @@ public class UnifiedActionSheetImpl: NSObject, UIPopoverPresentationControllerDe
|
|
|
241
375
|
}
|
|
242
376
|
|
|
243
377
|
private final class Presentation {
|
|
244
|
-
|
|
378
|
+
/// A UIAlertController, or the bottom sheet on iPhone.
|
|
379
|
+
let controller: UIViewController
|
|
245
380
|
let cancelButtonIndex: Int
|
|
246
381
|
/// Read at resolve time, not at creation: the value that matters is
|
|
247
382
|
/// whatever is in the field when the prompt closes. Sheets pass a constant.
|
|
@@ -249,7 +384,7 @@ public class UnifiedActionSheetImpl: NSObject, UIPopoverPresentationControllerDe
|
|
|
249
384
|
private var completion: ((Int, String) -> Void)?
|
|
250
385
|
|
|
251
386
|
init(
|
|
252
|
-
controller:
|
|
387
|
+
controller: UIViewController,
|
|
253
388
|
cancelButtonIndex: Int,
|
|
254
389
|
currentText: @escaping () -> String = { "" },
|
|
255
390
|
completion: @escaping (Int, String) -> Void
|
|
@@ -260,6 +395,11 @@ public class UnifiedActionSheetImpl: NSObject, UIPopoverPresentationControllerDe
|
|
|
260
395
|
self.completion = completion
|
|
261
396
|
}
|
|
262
397
|
|
|
398
|
+
/// Drops the completion without calling it.
|
|
399
|
+
func discard() {
|
|
400
|
+
completion = nil
|
|
401
|
+
}
|
|
402
|
+
|
|
263
403
|
func resolve(_ index: Int) {
|
|
264
404
|
guard let completion else { return }
|
|
265
405
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeUnifiedActionSheet.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAqE,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeUnifiedActionSheet.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAqE,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAkDtDC,gCAAmB,CAACC,YAAY,CAAO,oBAAoB,CAAC","ignoreList":[]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -55,6 +55,18 @@ const toWireButtons = buttons => {
|
|
|
55
55
|
const showWithNativeModule = options => nativeModule().showActionSheetWithOptions(options)
|
|
56
56
|
// A programmatic dismiss resolves with no index rather than a selection.
|
|
57
57
|
.then(buttonIndex => buttonIndex === DISMISSED_BY_API ? undefined : buttonIndex).catch(() => options.cancelButtonIndex ?? -1);
|
|
58
|
+
let warnedMaterialDisabled = false;
|
|
59
|
+
|
|
60
|
+
/// 'bottom' needs Material on Android, which the app opts into at build time.
|
|
61
|
+
/// Without it the sheet falls back to a centered dialog; say so once, in
|
|
62
|
+
/// development, since the fallback alone looks like the option was ignored.
|
|
63
|
+
const warnIfBottomUnavailable = presentationStyle => {
|
|
64
|
+
if (!__DEV__ || warnedMaterialDisabled || _reactNative.Platform.OS !== 'android' || presentationStyle !== 'bottom' || nativeModule().getConstants().isMaterialEnabled) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
warnedMaterialDisabled = true;
|
|
68
|
+
console.warn("react-native-unified-action-sheet: presentationStyle 'bottom' needs Material on Android, " + 'so this sheet falls back to a centered dialog. Set unifiedActionSheet.material=true in ' + "android/gradle.properties, or add ['react-native-unified-action-sheet', { material: true }] " + 'to your Expo plugins, then rebuild the app.');
|
|
69
|
+
};
|
|
58
70
|
|
|
59
71
|
/// The anchor is measured in JS and sent across as a rect, so neither native
|
|
60
72
|
/// module has to resolve a view: a ref's own measureInWindow is the supported
|
|
@@ -88,7 +100,12 @@ const showActionSheetWithOptions = options => {
|
|
|
88
100
|
if (_reactNative.Platform.OS !== 'ios' && _reactNative.Platform.OS !== 'android') {
|
|
89
101
|
return Promise.resolve(undefined);
|
|
90
102
|
}
|
|
91
|
-
|
|
103
|
+
warnIfBottomUnavailable(options.presentationStyle);
|
|
104
|
+
|
|
105
|
+
// A bottom sheet has no anchor, so don't measure one: on iPad a rect would
|
|
106
|
+
// turn the sheet into an arrowed popover pointing at it.
|
|
107
|
+
const anchor = options.presentationStyle === 'bottom' ? undefined : options.anchor;
|
|
108
|
+
return withAnchorRect(wire, anchor).then(showWithNativeModule).then(press);
|
|
92
109
|
};
|
|
93
110
|
exports.showActionSheetWithOptions = showActionSheetWithOptions;
|
|
94
111
|
const dismissActionSheet = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","DISMISSED_BY_API","nativeModule","default","toWireOptions","options","anchor","_anchor","rest","toWireButtons","buttons","labels","destructive","disabled","cancelButtonIndex","forEach","button","index","push","label","style","length","destructiveButtonIndices","disabledButtonIndices","showWithNativeModule","showActionSheetWithOptions","then","buttonIndex","undefined","catch","withAnchorRect","wire","target","current","Promise","resolve","measureInWindow","x","y","width","height","measured","anchorRect","press","onPress","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","DISMISSED_BY_API","nativeModule","default","toWireOptions","options","anchor","_anchor","rest","toWireButtons","buttons","labels","destructive","disabled","cancelButtonIndex","forEach","button","index","push","label","style","length","destructiveButtonIndices","disabledButtonIndices","showWithNativeModule","showActionSheetWithOptions","then","buttonIndex","undefined","catch","warnedMaterialDisabled","warnIfBottomUnavailable","presentationStyle","__DEV__","Platform","OS","getConstants","isMaterialEnabled","console","warn","withAnchorRect","wire","target","current","Promise","resolve","measureInWindow","x","y","width","height","measured","anchorRect","press","onPress","exports","dismissActionSheet","dismissAllActionSheets","showPromptWithOptions","result","text"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAgCA,MAAMC,gBAAgB,GAAG,CAAC,CAAC;;AAE3B;AACA;;AASA,MAAMC,YAAY,GAAGA,CAAA,KACnBF,OAAO,CAAC,4BAA4B,CAAC,CAACG,OAAe;;AAEvD;AACA;AACA,MAAMC,aAAa,GAAGA,CAAC;EACrBC,OAAO;EACP;EACA;EACAC,MAAM,EAAEC,OAAO;EACf,GAAGC;AACwB,CAAC,MAAmB;EAC/C,GAAGA,IAAI;EACP,GAAGC,aAAa,CAACJ,OAAO;AAC1B,CAAC,CAAC;AASF;AACA;AACA,MAAMI,aAAa,GAAIC,OAA2C,IAAK;EACrE,MAAMC,MAAgB,GAAG,EAAE;EAC3B,MAAMC,WAAqB,GAAG,EAAE;EAChC,MAAMC,QAAkB,GAAG,EAAE;EAC7B,IAAIC,iBAAqC;EAEzCJ,OAAO,CAACK,OAAO,CAAC,CAACC,MAAM,EAAEC,KAAK,KAAK;IACjCN,MAAM,CAACO,IAAI,CAACF,MAAM,CAACG,KAAK,CAAC;IAEzB,IAAIH,MAAM,CAACI,KAAK,KAAK,aAAa,EAAER,WAAW,CAACM,IAAI,CAACD,KAAK,CAAC;IAC3D,IAAID,MAAM,CAACI,KAAK,KAAK,QAAQ,IAAIN,iBAAiB,IAAI,IAAI,EAAE;MAC1DA,iBAAiB,GAAGG,KAAK;IAC3B;IACA,IAAID,MAAM,CAACH,QAAQ,EAAEA,QAAQ,CAACK,IAAI,CAACD,KAAK,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E;EAAG,CAAC,CAAC,CAAC,CACtElC,IAAI,CAAEiC,MAAM,IAAK;IAChB;IACA;IACA,IAAIA,MAAM,EAAEjD,OAAO,CAACiD,MAAM,CAAChC,WAAW,CAAC,EAAE2B,OAAO,GAAGK,MAAM,CAACC,IAAI,CAAC;IAE/D,OAAOD,MAAM;EACf,CAAC,CAAC;AACN,CAAC;AAACJ,OAAA,CAAAG,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeUnifiedActionSheet.ts"],"mappings":";;AAAA,SAASA,mBAAmB,QAA0B,cAAc;
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeUnifiedActionSheet.ts"],"mappings":";;AAAA,SAASA,mBAAmB,QAA0B,cAAc;AAkDpE,eAAeA,mBAAmB,CAACC,YAAY,CAAO,oBAAoB,CAAC","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -51,6 +51,18 @@ const toWireButtons = buttons => {
|
|
|
51
51
|
const showWithNativeModule = options => nativeModule().showActionSheetWithOptions(options)
|
|
52
52
|
// A programmatic dismiss resolves with no index rather than a selection.
|
|
53
53
|
.then(buttonIndex => buttonIndex === DISMISSED_BY_API ? undefined : buttonIndex).catch(() => options.cancelButtonIndex ?? -1);
|
|
54
|
+
let warnedMaterialDisabled = false;
|
|
55
|
+
|
|
56
|
+
/// 'bottom' needs Material on Android, which the app opts into at build time.
|
|
57
|
+
/// Without it the sheet falls back to a centered dialog; say so once, in
|
|
58
|
+
/// development, since the fallback alone looks like the option was ignored.
|
|
59
|
+
const warnIfBottomUnavailable = presentationStyle => {
|
|
60
|
+
if (!__DEV__ || warnedMaterialDisabled || Platform.OS !== 'android' || presentationStyle !== 'bottom' || nativeModule().getConstants().isMaterialEnabled) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
warnedMaterialDisabled = true;
|
|
64
|
+
console.warn("react-native-unified-action-sheet: presentationStyle 'bottom' needs Material on Android, " + 'so this sheet falls back to a centered dialog. Set unifiedActionSheet.material=true in ' + "android/gradle.properties, or add ['react-native-unified-action-sheet', { material: true }] " + 'to your Expo plugins, then rebuild the app.');
|
|
65
|
+
};
|
|
54
66
|
|
|
55
67
|
/// The anchor is measured in JS and sent across as a rect, so neither native
|
|
56
68
|
/// module has to resolve a view: a ref's own measureInWindow is the supported
|
|
@@ -84,7 +96,12 @@ export const showActionSheetWithOptions = options => {
|
|
|
84
96
|
if (Platform.OS !== 'ios' && Platform.OS !== 'android') {
|
|
85
97
|
return Promise.resolve(undefined);
|
|
86
98
|
}
|
|
87
|
-
|
|
99
|
+
warnIfBottomUnavailable(options.presentationStyle);
|
|
100
|
+
|
|
101
|
+
// A bottom sheet has no anchor, so don't measure one: on iPad a rect would
|
|
102
|
+
// turn the sheet into an arrowed popover pointing at it.
|
|
103
|
+
const anchor = options.presentationStyle === 'bottom' ? undefined : options.anchor;
|
|
104
|
+
return withAnchorRect(wire, anchor).then(showWithNativeModule).then(press);
|
|
88
105
|
};
|
|
89
106
|
export const dismissActionSheet = () => {
|
|
90
107
|
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","DISMISSED_BY_API","nativeModule","require","default","toWireOptions","options","anchor","_anchor","rest","toWireButtons","buttons","labels","destructive","disabled","cancelButtonIndex","forEach","button","index","push","label","style","length","destructiveButtonIndices","disabledButtonIndices","showWithNativeModule","showActionSheetWithOptions","then","buttonIndex","undefined","catch","withAnchorRect","wire","target","current","Promise","resolve","measureInWindow","x","y","width","height","measured","anchorRect","press","onPress","
|
|
1
|
+
{"version":3,"names":["Platform","DISMISSED_BY_API","nativeModule","require","default","toWireOptions","options","anchor","_anchor","rest","toWireButtons","buttons","labels","destructive","disabled","cancelButtonIndex","forEach","button","index","push","label","style","length","destructiveButtonIndices","disabledButtonIndices","showWithNativeModule","showActionSheetWithOptions","then","buttonIndex","undefined","catch","warnedMaterialDisabled","warnIfBottomUnavailable","presentationStyle","__DEV__","OS","getConstants","isMaterialEnabled","console","warn","withAnchorRect","wire","target","current","Promise","resolve","measureInWindow","x","y","width","height","measured","anchorRect","press","onPress","dismissActionSheet","dismissAllActionSheets","showPromptWithOptions","result","text"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AAgCvC,MAAMC,gBAAgB,GAAG,CAAC,CAAC;;AAE3B;AACA;;AASA,MAAMC,YAAY,GAAGA,CAAA,KACnBC,OAAO,CAAC,4BAA4B,CAAC,CAACC,OAAe;;AAEvD;AACA;AACA,MAAMC,aAAa,GAAGA,CAAC;EACrBC,OAAO;EACP;EACA;EACAC,MAAM,EAAEC,OAAO;EACf,GAAGC;AACwB,CAAC,MAAmB;EAC/C,GAAGA,IAAI;EACP,GAAGC,aAAa,CAACJ,OAAO;AAC1B,CAAC,CAAC;AASF;AACA;AACA,MAAMI,aAAa,GAAIC,OAA2C,IAAK;EACrE,MAAMC,MAAgB,GAAG,EAAE;EAC3B,MAAMC,WAAqB,GAAG,EAAE;EAChC,MAAMC,QAAkB,GAAG,EAAE;EAC7B,IAAIC,iBAAqC;EAEzCJ,OAAO,CAACK,OAAO,CAAC,CAACC,MAAM,EAAEC,KAAK,KAAK;IACjCN,MAAM,CAACO,IAAI,CAACF,MAAM,CAACG,KAAK,CAAC;IAEzB,IAAIH,MAAM,CAACI,KAAK,KAAK,aAAa,EAAER,WAAW,CAACM,IAAI,CAACD,KAAK,CAAC;IAC3D,IAAID,MAAM,CAACI,KAAK,KAAK,QAAQ,IAAIN,iBAAiB,IAAI,IAAI,EAAE;MAC1DA,iBAAiB,GAAGG,KAAK;IAC3B;IACA,IAAID,MAAM,CAACH,QAAQ,EAAEA,QAAQ,CAACK,IAAI,CAACD,KAAK,CAAC;EAC3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7 @@ export interface ActionSheetCommonOptionsInterface extends BaseOptionsInterface
|
|
|
10
10
|
anchor?: ActionSheetAnchorInterface | {
|
|
11
11
|
current: ActionSheetAnchorInterface | null;
|
|
12
12
|
} | null;
|
|
13
|
-
presentationStyle?: 'centered' | 'anchored';
|
|
13
|
+
presentationStyle?: 'centered' | 'anchored' | 'bottom';
|
|
14
14
|
}
|
|
15
15
|
export interface ActionSheetAndroidOptionsInterface extends BaseAndroidOptionsInterface {
|
|
16
16
|
anchorAlignment?: 'start' | 'center';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-sheet-options.interface.d.ts","sourceRoot":"","sources":["../../../../src/action-sheet-options.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,0BAA2B,SAAQ,mBAAmB;IACrE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,0BAA0B;IACzC,eAAe,EAAE,CACf,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,KACpE,IAAI,CAAC;CACX;AAED,MAAM,WAAW,iCAAkC,SAAQ,oBAAoB;IAC7E,OAAO,EAAE,0BAA0B,EAAE,CAAC;IACtC,MAAM,CAAC,EACH,0BAA0B,GAC1B;QAAE,OAAO,EAAE,0BAA0B,GAAG,IAAI,CAAA;KAAE,GAC9C,IAAI,CAAC;IACT,iBAAiB,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"action-sheet-options.interface.d.ts","sourceRoot":"","sources":["../../../../src/action-sheet-options.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,4BA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