@synonymdev/react-native-toast 0.1.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/API.md +210 -0
- package/DEVELOPMENT.md +35 -0
- package/README.md +62 -0
- package/SynonymReactNativeToast.podspec +17 -0
- package/android/build.gradle +24 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/synonymdev/reactnativetoast/NativeToastModule.kt +332 -0
- package/android/src/main/java/com/synonymdev/reactnativetoast/NativeToastPackage.kt +15 -0
- package/ios/NativeToast.m +530 -0
- package/lib/commonjs/defaults.js +105 -0
- package/lib/commonjs/defaults.js.map +1 -0
- package/lib/commonjs/index.js +25 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/nativeModule.js +15 -0
- package/lib/commonjs/nativeModule.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/defaults.js +97 -0
- package/lib/module/defaults.js.map +1 -0
- package/lib/module/index.js +9 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/nativeModule.js +10 -0
- package/lib/module/nativeModule.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/commonjs/defaults.d.ts +9 -0
- package/lib/typescript/commonjs/defaults.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +6 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/nativeModule.d.ts +3 -0
- package/lib/typescript/commonjs/nativeModule.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/types.d.ts +57 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/module/defaults.d.ts +9 -0
- package/lib/typescript/module/defaults.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +6 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/nativeModule.d.ts +3 -0
- package/lib/typescript/module/nativeModule.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/types.d.ts +57 -0
- package/lib/typescript/module/types.d.ts.map +1 -0
- package/package.json +68 -0
- package/src/defaults.ts +110 -0
- package/src/index.ts +25 -0
- package/src/nativeModule.ts +12 -0
- package/src/types.ts +87 -0
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
2
|
+
#import <React/RCTUtils.h>
|
|
3
|
+
#import <math.h>
|
|
4
|
+
#import <objc/runtime.h>
|
|
5
|
+
#import <UIKit/UIKit.h>
|
|
6
|
+
|
|
7
|
+
@interface NativeToastPassthroughWindow : UIWindow
|
|
8
|
+
@end
|
|
9
|
+
|
|
10
|
+
@implementation NativeToastPassthroughWindow
|
|
11
|
+
|
|
12
|
+
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
|
|
13
|
+
{
|
|
14
|
+
UIView *hitView = [super hitTest:point withEvent:event];
|
|
15
|
+
return hitView == self.rootViewController.view ? nil : hitView;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@end
|
|
19
|
+
|
|
20
|
+
@interface UIBlurEffect (NativeToastPrivate)
|
|
21
|
+
- (id)effectSettings;
|
|
22
|
+
@end
|
|
23
|
+
|
|
24
|
+
@interface NativeToastBlurEffect : UIBlurEffect
|
|
25
|
+
@property (nonatomic, strong) NSNumber *blurAmount;
|
|
26
|
+
+ (instancetype)effectWithStyle:(UIBlurEffectStyle)style blurAmount:(NSNumber *)blurAmount;
|
|
27
|
+
@end
|
|
28
|
+
|
|
29
|
+
@implementation NativeToastBlurEffect
|
|
30
|
+
|
|
31
|
+
static void NativeToastSetEffectSettingValue(id settings, NSString *key, id value)
|
|
32
|
+
{
|
|
33
|
+
@try {
|
|
34
|
+
[settings setValue:value forKey:key];
|
|
35
|
+
} @catch (__unused NSException *exception) {
|
|
36
|
+
// UIKit backdrop setting keys are private and may vary between iOS versions.
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static char NativeToastBlurAmountKey;
|
|
41
|
+
|
|
42
|
+
+ (instancetype)effectWithStyle:(UIBlurEffectStyle)style blurAmount:(NSNumber *)blurAmount
|
|
43
|
+
{
|
|
44
|
+
NativeToastBlurEffect *instance = (NativeToastBlurEffect *)[super effectWithStyle:style];
|
|
45
|
+
object_setClass(instance, self);
|
|
46
|
+
[instance setBlurAmount:blurAmount];
|
|
47
|
+
return instance;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
- (void)setBlurAmount:(NSNumber *)blurAmount
|
|
51
|
+
{
|
|
52
|
+
objc_setAssociatedObject(self, &NativeToastBlurAmountKey, blurAmount, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
- (NSNumber *)blurAmount
|
|
56
|
+
{
|
|
57
|
+
return objc_getAssociatedObject(self, &NativeToastBlurAmountKey);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
- (id)effectSettings
|
|
61
|
+
{
|
|
62
|
+
id settings = [super effectSettings];
|
|
63
|
+
NSNumber *blurAmount = self.blurAmount;
|
|
64
|
+
if (blurAmount) {
|
|
65
|
+
NativeToastSetEffectSettingValue(settings, @"blurRadius", blurAmount);
|
|
66
|
+
}
|
|
67
|
+
NativeToastSetEffectSettingValue(settings, @"colorTintAlpha", @0);
|
|
68
|
+
NativeToastSetEffectSettingValue(settings, @"darkeningTintAlpha", @0);
|
|
69
|
+
NativeToastSetEffectSettingValue(settings, @"grayscaleTintAlpha", @0);
|
|
70
|
+
NativeToastSetEffectSettingValue(settings, @"saturationDeltaFactor", @1);
|
|
71
|
+
return settings;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@end
|
|
75
|
+
|
|
76
|
+
@interface NativeToast : NSObject <RCTBridgeModule>
|
|
77
|
+
@end
|
|
78
|
+
|
|
79
|
+
@implementation NativeToast
|
|
80
|
+
|
|
81
|
+
static UIWindow *NativeToastWindow = nil;
|
|
82
|
+
|
|
83
|
+
RCT_EXPORT_MODULE();
|
|
84
|
+
|
|
85
|
+
RCT_EXPORT_METHOD(show:(NSDictionary *)options)
|
|
86
|
+
{
|
|
87
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
88
|
+
NSString *title = [options[@"title"] isKindOfClass:NSString.class] ? options[@"title"] : @"";
|
|
89
|
+
NSString *description = [options[@"description"] isKindOfClass:NSString.class] ? options[@"description"] : @"";
|
|
90
|
+
NSString *variant = [options[@"type"] isKindOfClass:NSString.class] ? options[@"type"] : @"info";
|
|
91
|
+
BOOL autoHide = [options[@"autoHide"] isKindOfClass:NSNumber.class] ? [options[@"autoHide"] boolValue] : YES;
|
|
92
|
+
BOOL dismissible = [options[@"dismissible"] isKindOfClass:NSNumber.class] ? [options[@"dismissible"] boolValue] : YES;
|
|
93
|
+
BOOL haptics = [options[@"haptics"] isKindOfClass:NSNumber.class] ? [options[@"haptics"] boolValue] : NO;
|
|
94
|
+
NSNumber *durationNumber = [options[@"durationMs"] isKindOfClass:NSNumber.class] ? options[@"durationMs"] : @(4000);
|
|
95
|
+
NSDictionary *style = [options[@"style"] isKindOfClass:NSDictionary.class] ? options[@"style"] : @{};
|
|
96
|
+
NSString *animation = [style[@"animation"] isKindOfClass:NSString.class] ? style[@"animation"] : @"slide-fade";
|
|
97
|
+
NSString *iosBlurEffect = [style[@"iosBlurEffect"] isKindOfClass:NSString.class] ? style[@"iosBlurEffect"] : @"none";
|
|
98
|
+
|
|
99
|
+
if (title.length == 0 && description.length == 0) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
UIWindow *sourceWindow = RCTKeyWindow();
|
|
104
|
+
if (!sourceWindow) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
UIWindow *window = [self toastWindowForSourceWindow:sourceWindow];
|
|
109
|
+
if (!window) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
UIView *existingToast = [window viewWithTag:900413];
|
|
114
|
+
[existingToast removeFromSuperview];
|
|
115
|
+
|
|
116
|
+
CGFloat marginHorizontal = [self numberFromStyle:style key:@"marginHorizontal" fallback:16.0];
|
|
117
|
+
CGFloat topInset = sourceWindow.safeAreaInsets.top + 12.0;
|
|
118
|
+
CGFloat availableWidth = MAX(0.0, window.bounds.size.width - (marginHorizontal * 2.0));
|
|
119
|
+
CGFloat toastWidth = [self toastWidthFromStyle:style availableWidth:availableWidth];
|
|
120
|
+
CGFloat borderRadius = [self numberFromStyle:style key:@"borderRadius" fallback:12.0];
|
|
121
|
+
CGFloat borderWidth = [self numberFromStyle:style key:@"borderWidth" fallback:1.0];
|
|
122
|
+
CGFloat paddingTop = [self paddingFromStyle:style edgeKey:@"paddingTop" axisKey:@"paddingVertical" fallback:12.0];
|
|
123
|
+
CGFloat paddingRight = [self paddingFromStyle:style edgeKey:@"paddingRight" axisKey:@"paddingHorizontal" fallback:16.0];
|
|
124
|
+
CGFloat paddingBottom = [self paddingFromStyle:style edgeKey:@"paddingBottom" axisKey:@"paddingVertical" fallback:12.0];
|
|
125
|
+
CGFloat paddingLeft = [self paddingFromStyle:style edgeKey:@"paddingLeft" axisKey:@"paddingHorizontal" fallback:16.0];
|
|
126
|
+
CGFloat contentWidth = MAX(0.0, toastWidth - paddingLeft - paddingRight);
|
|
127
|
+
CGFloat blurAmount = MIN(MAX([self numberFromStyle:style key:@"iosBlurAmount" fallback:20.0], 0.0), 100.0);
|
|
128
|
+
CGFloat blurTintOpacity = MIN(MAX([self numberFromStyle:style key:@"iosBlurTintOpacity" fallback:0.72], 0.0), 1.0);
|
|
129
|
+
NSTimeInterval animationDuration = MAX(0.0, [self numberFromStyle:style key:@"animationDurationMs" fallback:200.0] / 1000.0);
|
|
130
|
+
|
|
131
|
+
UILabel *titleLabel = [[UILabel alloc] init];
|
|
132
|
+
titleLabel.numberOfLines = 2;
|
|
133
|
+
titleLabel.text = title;
|
|
134
|
+
titleLabel.textColor = [self colorFromStyle:style key:@"titleColor" fallback:UIColor.whiteColor];
|
|
135
|
+
titleLabel.font = [self fontFromStyle:style familyKey:@"titleFontFamily" sizeKey:@"titleFontSize" weightKey:@"titleFontWeight" fallbackSize:15.0 fallbackWeight:UIFontWeightSemibold];
|
|
136
|
+
titleLabel.hidden = title.length == 0;
|
|
137
|
+
|
|
138
|
+
UILabel *descriptionLabel = [[UILabel alloc] init];
|
|
139
|
+
descriptionLabel.numberOfLines = 3;
|
|
140
|
+
descriptionLabel.text = description;
|
|
141
|
+
descriptionLabel.textColor = [self colorFromStyle:style key:@"descriptionColor" fallback:[UIColor colorWithWhite:1.0 alpha:0.8]];
|
|
142
|
+
descriptionLabel.font = [self fontFromStyle:style familyKey:@"descriptionFontFamily" sizeKey:@"descriptionFontSize" weightKey:@"descriptionFontWeight" fallbackSize:13.0 fallbackWeight:UIFontWeightRegular];
|
|
143
|
+
descriptionLabel.hidden = description.length == 0;
|
|
144
|
+
|
|
145
|
+
UIStackView *stack = [[UIStackView alloc] initWithArrangedSubviews:@[titleLabel, descriptionLabel]];
|
|
146
|
+
stack.axis = UILayoutConstraintAxisVertical;
|
|
147
|
+
stack.spacing = title.length > 0 && description.length > 0 ? 2.0 : 0.0;
|
|
148
|
+
stack.alignment = UIStackViewAlignmentFill;
|
|
149
|
+
|
|
150
|
+
UIView *toast = [[UIView alloc] init];
|
|
151
|
+
toast.tag = 900413;
|
|
152
|
+
UIColor *backgroundColor = [self colorFromStyle:style key:@"backgroundColor" fallback:[UIColor colorWithWhite:0.08 alpha:0.96]];
|
|
153
|
+
UIBlurEffect *blurEffect = [self blurEffectFromStyle:iosBlurEffect blurAmount:@(blurAmount)];
|
|
154
|
+
toast.backgroundColor = blurEffect ? UIColor.clearColor : backgroundColor;
|
|
155
|
+
toast.clipsToBounds = NO;
|
|
156
|
+
toast.layer.cornerRadius = borderRadius;
|
|
157
|
+
toast.layer.borderColor = [self colorFromStyle:style key:@"borderColor" fallback:[UIColor colorWithWhite:1.0 alpha:0.12]].CGColor;
|
|
158
|
+
toast.layer.borderWidth = borderWidth;
|
|
159
|
+
toast.layer.shadowColor = [self colorFromStyle:style key:@"shadowColor" fallback:UIColor.blackColor].CGColor;
|
|
160
|
+
toast.layer.shadowOpacity = [self numberFromStyle:style key:@"shadowOpacity" fallback:0.24];
|
|
161
|
+
toast.layer.shadowRadius = [self numberFromStyle:style key:@"shadowRadius" fallback:16.0];
|
|
162
|
+
toast.layer.shadowOffset = CGSizeMake(
|
|
163
|
+
[self numberFromStyle:style key:@"shadowOffsetX" fallback:0.0],
|
|
164
|
+
[self numberFromStyle:style key:@"shadowOffsetY" fallback:8.0]
|
|
165
|
+
);
|
|
166
|
+
toast.userInteractionEnabled = dismissible;
|
|
167
|
+
if (dismissible) {
|
|
168
|
+
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handleToastPan:)];
|
|
169
|
+
[toast addGestureRecognizer:panGesture];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
UIVisualEffectView *blurView = nil;
|
|
173
|
+
UIView *backgroundTintView = nil;
|
|
174
|
+
if (blurEffect) {
|
|
175
|
+
blurView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
|
|
176
|
+
blurView.userInteractionEnabled = NO;
|
|
177
|
+
blurView.clipsToBounds = YES;
|
|
178
|
+
blurView.layer.cornerRadius = borderRadius;
|
|
179
|
+
|
|
180
|
+
backgroundTintView = [[UIView alloc] init];
|
|
181
|
+
backgroundTintView.backgroundColor = [backgroundColor colorWithAlphaComponent:blurTintOpacity];
|
|
182
|
+
backgroundTintView.userInteractionEnabled = NO;
|
|
183
|
+
[blurView.contentView addSubview:backgroundTintView];
|
|
184
|
+
[toast addSubview:blurView];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
[toast addSubview:stack];
|
|
188
|
+
[window addSubview:toast];
|
|
189
|
+
if (haptics) {
|
|
190
|
+
[self triggerHapticForVariant:variant];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
CGSize titleSize = title.length > 0 ? [titleLabel sizeThatFits:CGSizeMake(contentWidth, CGFLOAT_MAX)] : CGSizeZero;
|
|
194
|
+
CGSize descriptionSize = description.length > 0 ? [descriptionLabel sizeThatFits:CGSizeMake(contentWidth, CGFLOAT_MAX)] : CGSizeZero;
|
|
195
|
+
CGFloat stackHeight = titleSize.height + descriptionSize.height + stack.spacing;
|
|
196
|
+
CGFloat toastHeight = MAX(52.0, stackHeight + paddingTop + paddingBottom);
|
|
197
|
+
|
|
198
|
+
toast.frame = CGRectMake((window.bounds.size.width - toastWidth) / 2.0, topInset, toastWidth, toastHeight);
|
|
199
|
+
toast.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:toast.bounds cornerRadius:borderRadius].CGPath;
|
|
200
|
+
blurView.frame = toast.bounds;
|
|
201
|
+
backgroundTintView.frame = blurView.contentView.bounds;
|
|
202
|
+
stack.frame = CGRectMake(paddingLeft, paddingTop, contentWidth, toastHeight - paddingTop - paddingBottom);
|
|
203
|
+
|
|
204
|
+
NSTimeInterval duration = MAX(1.5, durationNumber.doubleValue / 1000.0);
|
|
205
|
+
CGAffineTransform dismissedTransform = [self dismissedTransformForAnimation:animation toastHeight:toastHeight topInset:topInset];
|
|
206
|
+
toast.alpha = [self animationUsesFade:animation] ? 0.0 : 1.0;
|
|
207
|
+
toast.transform = [self animationUsesSlide:animation] ? dismissedTransform : CGAffineTransformIdentity;
|
|
208
|
+
|
|
209
|
+
[UIView animateWithDuration:animationDuration delay:0.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{
|
|
210
|
+
toast.alpha = 1.0;
|
|
211
|
+
toast.transform = CGAffineTransformIdentity;
|
|
212
|
+
} completion:^(__unused BOOL finished) {
|
|
213
|
+
if (!autoHide) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
__weak UIView *weakToast = toast;
|
|
218
|
+
__weak UIWindow *weakWindow = window;
|
|
219
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(duration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
220
|
+
UIView *currentToast = weakToast;
|
|
221
|
+
UIWindow *currentWindow = weakWindow;
|
|
222
|
+
if (!currentToast || currentToast.superview != currentWindow) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
[UIView animateWithDuration:animationDuration delay:0.0 options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction animations:^{
|
|
227
|
+
currentToast.alpha = [self animationUsesFade:animation] ? 0.0 : 1.0;
|
|
228
|
+
currentToast.transform = [self animationUsesSlide:animation] ? dismissedTransform : CGAffineTransformIdentity;
|
|
229
|
+
} completion:^(__unused BOOL finished) {
|
|
230
|
+
[currentToast removeFromSuperview];
|
|
231
|
+
if ([currentWindow viewWithTag:900413] == nil) {
|
|
232
|
+
NativeToastWindow.hidden = YES;
|
|
233
|
+
NativeToastWindow.rootViewController = nil;
|
|
234
|
+
NativeToastWindow = nil;
|
|
235
|
+
}
|
|
236
|
+
}];
|
|
237
|
+
});
|
|
238
|
+
}];
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
+ (BOOL)requiresMainQueueSetup
|
|
243
|
+
{
|
|
244
|
+
return NO;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
- (CGFloat)numberFromStyle:(NSDictionary *)style key:(NSString *)key fallback:(CGFloat)fallback
|
|
248
|
+
{
|
|
249
|
+
NSNumber *number = [style[key] isKindOfClass:NSNumber.class] ? style[key] : nil;
|
|
250
|
+
return number ? number.doubleValue : fallback;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
- (CGFloat)optionalNumberFromStyle:(NSDictionary *)style key:(NSString *)key
|
|
254
|
+
{
|
|
255
|
+
NSNumber *number = [style[key] isKindOfClass:NSNumber.class] ? style[key] : nil;
|
|
256
|
+
return number ? number.doubleValue : NAN;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
- (CGFloat)toastWidthFromStyle:(NSDictionary *)style availableWidth:(CGFloat)availableWidth
|
|
260
|
+
{
|
|
261
|
+
CGFloat width = [self optionalNumberFromStyle:style key:@"width"];
|
|
262
|
+
if (!isnan(width)) {
|
|
263
|
+
return MIN(MAX(0.0, width), availableWidth);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
CGFloat maxWidth = [self optionalNumberFromStyle:style key:@"maxWidth"];
|
|
267
|
+
if (!isnan(maxWidth)) {
|
|
268
|
+
return MIN(MAX(0.0, maxWidth), availableWidth);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return availableWidth;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
- (BOOL)animationUsesFade:(NSString *)animation
|
|
275
|
+
{
|
|
276
|
+
return ![animation isEqualToString:@"none"] && ![animation isEqualToString:@"slide"];
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
- (BOOL)animationUsesSlide:(NSString *)animation
|
|
280
|
+
{
|
|
281
|
+
return [animation isEqualToString:@"slide"] || [animation isEqualToString:@"slide-fade"];
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
- (CGAffineTransform)dismissedTransformForAnimation:(NSString *)animation toastHeight:(CGFloat)toastHeight topInset:(CGFloat)topInset
|
|
285
|
+
{
|
|
286
|
+
if (![self animationUsesSlide:animation]) {
|
|
287
|
+
return CGAffineTransformIdentity;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
return CGAffineTransformMakeTranslation(0.0, -(toastHeight + topInset + 8.0));
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
- (UIWindow *)toastWindowForSourceWindow:(UIWindow *)sourceWindow
|
|
294
|
+
{
|
|
295
|
+
if (NativeToastWindow) {
|
|
296
|
+
NativeToastWindow.frame = sourceWindow.bounds;
|
|
297
|
+
NativeToastWindow.hidden = NO;
|
|
298
|
+
return NativeToastWindow;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
UIWindow *window = nil;
|
|
302
|
+
if (@available(iOS 13.0, *)) {
|
|
303
|
+
UIWindowScene *windowScene = sourceWindow.windowScene;
|
|
304
|
+
if (!windowScene) {
|
|
305
|
+
return nil;
|
|
306
|
+
}
|
|
307
|
+
window = [[NativeToastPassthroughWindow alloc] initWithWindowScene:windowScene];
|
|
308
|
+
window.frame = windowScene.coordinateSpace.bounds;
|
|
309
|
+
} else {
|
|
310
|
+
window = [[NativeToastPassthroughWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
UIViewController *viewController = [[UIViewController alloc] init];
|
|
314
|
+
viewController.view.backgroundColor = UIColor.clearColor;
|
|
315
|
+
|
|
316
|
+
window.backgroundColor = UIColor.clearColor;
|
|
317
|
+
window.rootViewController = viewController;
|
|
318
|
+
window.userInteractionEnabled = YES;
|
|
319
|
+
window.windowLevel = UIWindowLevelAlert + 1.0;
|
|
320
|
+
window.hidden = NO;
|
|
321
|
+
NativeToastWindow = window;
|
|
322
|
+
|
|
323
|
+
return window;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
- (UIBlurEffect *)blurEffectFromStyle:(NSString *)style blurAmount:(NSNumber *)blurAmount
|
|
327
|
+
{
|
|
328
|
+
if ([style isEqualToString:@"none"]) {
|
|
329
|
+
return nil;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
UIBlurEffectStyle effectStyle = UIBlurEffectStyleDark;
|
|
333
|
+
if ([style isEqualToString:@"extraLight"]) {
|
|
334
|
+
effectStyle = UIBlurEffectStyleExtraLight;
|
|
335
|
+
} else if ([style isEqualToString:@"light"]) {
|
|
336
|
+
effectStyle = UIBlurEffectStyleLight;
|
|
337
|
+
} else if ([style isEqualToString:@"dark"]) {
|
|
338
|
+
effectStyle = UIBlurEffectStyleDark;
|
|
339
|
+
} else if (@available(iOS 10.0, *)) {
|
|
340
|
+
if ([style isEqualToString:@"regular"]) {
|
|
341
|
+
effectStyle = UIBlurEffectStyleRegular;
|
|
342
|
+
} else if ([style isEqualToString:@"prominent"]) {
|
|
343
|
+
effectStyle = UIBlurEffectStyleProminent;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (@available(iOS 13.0, *)) {
|
|
348
|
+
if ([style isEqualToString:@"systemUltraThinMaterial"]) {
|
|
349
|
+
effectStyle = UIBlurEffectStyleSystemUltraThinMaterial;
|
|
350
|
+
} else if ([style isEqualToString:@"systemThinMaterial"]) {
|
|
351
|
+
effectStyle = UIBlurEffectStyleSystemThinMaterial;
|
|
352
|
+
} else if ([style isEqualToString:@"systemMaterial"]) {
|
|
353
|
+
effectStyle = UIBlurEffectStyleSystemMaterial;
|
|
354
|
+
} else if ([style isEqualToString:@"systemThickMaterial"]) {
|
|
355
|
+
effectStyle = UIBlurEffectStyleSystemThickMaterial;
|
|
356
|
+
} else if ([style isEqualToString:@"systemChromeMaterial"]) {
|
|
357
|
+
effectStyle = UIBlurEffectStyleSystemChromeMaterial;
|
|
358
|
+
} else if ([style isEqualToString:@"systemUltraThinMaterialLight"]) {
|
|
359
|
+
effectStyle = UIBlurEffectStyleSystemUltraThinMaterialLight;
|
|
360
|
+
} else if ([style isEqualToString:@"systemThinMaterialLight"]) {
|
|
361
|
+
effectStyle = UIBlurEffectStyleSystemThinMaterialLight;
|
|
362
|
+
} else if ([style isEqualToString:@"systemMaterialLight"]) {
|
|
363
|
+
effectStyle = UIBlurEffectStyleSystemMaterialLight;
|
|
364
|
+
} else if ([style isEqualToString:@"systemThickMaterialLight"]) {
|
|
365
|
+
effectStyle = UIBlurEffectStyleSystemThickMaterialLight;
|
|
366
|
+
} else if ([style isEqualToString:@"systemChromeMaterialLight"]) {
|
|
367
|
+
effectStyle = UIBlurEffectStyleSystemChromeMaterialLight;
|
|
368
|
+
} else if ([style isEqualToString:@"systemUltraThinMaterialDark"]) {
|
|
369
|
+
effectStyle = UIBlurEffectStyleSystemUltraThinMaterialDark;
|
|
370
|
+
} else if ([style isEqualToString:@"systemThinMaterialDark"]) {
|
|
371
|
+
effectStyle = UIBlurEffectStyleSystemThinMaterialDark;
|
|
372
|
+
} else if ([style isEqualToString:@"systemMaterialDark"]) {
|
|
373
|
+
effectStyle = UIBlurEffectStyleSystemMaterialDark;
|
|
374
|
+
} else if ([style isEqualToString:@"systemThickMaterialDark"]) {
|
|
375
|
+
effectStyle = UIBlurEffectStyleSystemThickMaterialDark;
|
|
376
|
+
} else if ([style isEqualToString:@"systemChromeMaterialDark"]) {
|
|
377
|
+
effectStyle = UIBlurEffectStyleSystemChromeMaterialDark;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
return [NativeToastBlurEffect effectWithStyle:effectStyle blurAmount:blurAmount];
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
- (void)triggerHapticForVariant:(NSString *)variant
|
|
385
|
+
{
|
|
386
|
+
if ([variant isEqualToString:@"success"]) {
|
|
387
|
+
UINotificationFeedbackGenerator *generator = [[UINotificationFeedbackGenerator alloc] init];
|
|
388
|
+
[generator notificationOccurred:UINotificationFeedbackTypeSuccess];
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
if ([variant isEqualToString:@"warning"]) {
|
|
393
|
+
UINotificationFeedbackGenerator *generator = [[UINotificationFeedbackGenerator alloc] init];
|
|
394
|
+
[generator notificationOccurred:UINotificationFeedbackTypeWarning];
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
if ([variant isEqualToString:@"error"]) {
|
|
399
|
+
UINotificationFeedbackGenerator *generator = [[UINotificationFeedbackGenerator alloc] init];
|
|
400
|
+
[generator notificationOccurred:UINotificationFeedbackTypeError];
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
UIImpactFeedbackGenerator *generator = [[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleLight];
|
|
405
|
+
[generator impactOccurred];
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
- (CGFloat)paddingFromStyle:(NSDictionary *)style edgeKey:(NSString *)edgeKey axisKey:(NSString *)axisKey fallback:(CGFloat)fallback
|
|
409
|
+
{
|
|
410
|
+
if ([style[edgeKey] isKindOfClass:NSNumber.class]) {
|
|
411
|
+
return [style[edgeKey] doubleValue];
|
|
412
|
+
}
|
|
413
|
+
if ([style[axisKey] isKindOfClass:NSNumber.class]) {
|
|
414
|
+
return [style[axisKey] doubleValue];
|
|
415
|
+
}
|
|
416
|
+
if ([style[@"padding"] isKindOfClass:NSNumber.class]) {
|
|
417
|
+
return [style[@"padding"] doubleValue];
|
|
418
|
+
}
|
|
419
|
+
return fallback;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
- (UIColor *)colorFromStyle:(NSDictionary *)style key:(NSString *)key fallback:(UIColor *)fallback
|
|
423
|
+
{
|
|
424
|
+
NSString *value = [style[key] isKindOfClass:NSString.class] ? style[key] : nil;
|
|
425
|
+
return [self colorFromHexString:value fallback:fallback];
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
- (UIColor *)colorFromHexString:(NSString *)value fallback:(UIColor *)fallback
|
|
429
|
+
{
|
|
430
|
+
if (value.length == 0) {
|
|
431
|
+
return fallback;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
NSString *hex = [[value stringByReplacingOccurrencesOfString:@"#" withString:@""] uppercaseString];
|
|
435
|
+
if (hex.length != 6 && hex.length != 8) {
|
|
436
|
+
return fallback;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
unsigned int raw = 0;
|
|
440
|
+
if (![[NSScanner scannerWithString:hex] scanHexInt:&raw]) {
|
|
441
|
+
return fallback;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
CGFloat alpha = hex.length == 8 ? ((raw >> 24) & 0xFF) / 255.0 : 1.0;
|
|
445
|
+
CGFloat red = hex.length == 8 ? ((raw >> 16) & 0xFF) / 255.0 : ((raw >> 16) & 0xFF) / 255.0;
|
|
446
|
+
CGFloat green = hex.length == 8 ? ((raw >> 8) & 0xFF) / 255.0 : ((raw >> 8) & 0xFF) / 255.0;
|
|
447
|
+
CGFloat blue = (raw & 0xFF) / 255.0;
|
|
448
|
+
|
|
449
|
+
return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
- (void)handleToastPan:(UIPanGestureRecognizer *)recognizer
|
|
453
|
+
{
|
|
454
|
+
UIView *toast = recognizer.view;
|
|
455
|
+
if (!toast) {
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
CGPoint translation = [recognizer translationInView:toast.superview];
|
|
460
|
+
CGFloat offsetY = MIN(0.0, translation.y);
|
|
461
|
+
|
|
462
|
+
if (recognizer.state == UIGestureRecognizerStateBegan) {
|
|
463
|
+
[toast.layer removeAllAnimations];
|
|
464
|
+
} else if (recognizer.state == UIGestureRecognizerStateChanged) {
|
|
465
|
+
toast.transform = CGAffineTransformMakeTranslation(0.0, offsetY);
|
|
466
|
+
toast.alpha = MAX(0.35, 1.0 + (offsetY / MAX(1.0, toast.bounds.size.height)));
|
|
467
|
+
} else if (recognizer.state == UIGestureRecognizerStateEnded || recognizer.state == UIGestureRecognizerStateCancelled) {
|
|
468
|
+
CGPoint velocity = [recognizer velocityInView:toast.superview];
|
|
469
|
+
BOOL shouldDismiss = offsetY < -40.0 || velocity.y < -500.0;
|
|
470
|
+
|
|
471
|
+
if (shouldDismiss) {
|
|
472
|
+
[UIView animateWithDuration:0.16 animations:^{
|
|
473
|
+
toast.alpha = 0.0;
|
|
474
|
+
toast.transform = CGAffineTransformMakeTranslation(0.0, -(toast.bounds.size.height + toast.frame.origin.y + 8.0));
|
|
475
|
+
} completion:^(__unused BOOL finished) {
|
|
476
|
+
[toast removeFromSuperview];
|
|
477
|
+
if (NativeToastWindow && [NativeToastWindow viewWithTag:900413] == nil) {
|
|
478
|
+
NativeToastWindow.hidden = YES;
|
|
479
|
+
NativeToastWindow.rootViewController = nil;
|
|
480
|
+
NativeToastWindow = nil;
|
|
481
|
+
}
|
|
482
|
+
}];
|
|
483
|
+
} else {
|
|
484
|
+
[UIView animateWithDuration:0.16 animations:^{
|
|
485
|
+
toast.alpha = 1.0;
|
|
486
|
+
toast.transform = CGAffineTransformIdentity;
|
|
487
|
+
}];
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
- (UIFont *)fontFromStyle:(NSDictionary *)style
|
|
493
|
+
familyKey:(NSString *)familyKey
|
|
494
|
+
sizeKey:(NSString *)sizeKey
|
|
495
|
+
weightKey:(NSString *)weightKey
|
|
496
|
+
fallbackSize:(CGFloat)fallbackSize
|
|
497
|
+
fallbackWeight:(UIFontWeight)fallbackWeight
|
|
498
|
+
{
|
|
499
|
+
NSString *family = [style[familyKey] isKindOfClass:NSString.class] ? style[familyKey] : nil;
|
|
500
|
+
NSString *weightName = [style[weightKey] isKindOfClass:NSString.class] ? style[weightKey] : nil;
|
|
501
|
+
CGFloat size = [self numberFromStyle:style key:sizeKey fallback:fallbackSize];
|
|
502
|
+
|
|
503
|
+
if (family.length > 0) {
|
|
504
|
+
UIFont *font = [UIFont fontWithName:family size:size];
|
|
505
|
+
if (font) {
|
|
506
|
+
return font;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
return [UIFont systemFontOfSize:size weight:[self fontWeightFromString:weightName fallback:fallbackWeight]];
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
- (UIFontWeight)fontWeightFromString:(NSString *)value fallback:(UIFontWeight)fallback
|
|
514
|
+
{
|
|
515
|
+
if ([value isEqualToString:@"bold"]) {
|
|
516
|
+
return UIFontWeightBold;
|
|
517
|
+
}
|
|
518
|
+
if ([value isEqualToString:@"semibold"]) {
|
|
519
|
+
return UIFontWeightSemibold;
|
|
520
|
+
}
|
|
521
|
+
if ([value isEqualToString:@"medium"]) {
|
|
522
|
+
return UIFontWeightMedium;
|
|
523
|
+
}
|
|
524
|
+
if ([value isEqualToString:@"normal"]) {
|
|
525
|
+
return UIFontWeightRegular;
|
|
526
|
+
}
|
|
527
|
+
return fallback;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
@end
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.resolveToastStyle = exports.resolveToastOptions = exports.resetToastConfig = exports.configureToast = void 0;
|
|
7
|
+
const defaultToastStyle = {
|
|
8
|
+
backgroundColor: '#333333',
|
|
9
|
+
borderRadius: 14,
|
|
10
|
+
borderColor: '#444444',
|
|
11
|
+
borderWidth: 1,
|
|
12
|
+
shadowColor: '#05050A',
|
|
13
|
+
shadowOpacity: 0.5,
|
|
14
|
+
shadowRadius: 15,
|
|
15
|
+
shadowOffsetX: 0,
|
|
16
|
+
shadowOffsetY: 10,
|
|
17
|
+
shadowElevation: 10,
|
|
18
|
+
animation: 'slide-fade',
|
|
19
|
+
animationDurationMs: 200,
|
|
20
|
+
marginHorizontal: 24,
|
|
21
|
+
paddingHorizontal: 20,
|
|
22
|
+
paddingVertical: 16,
|
|
23
|
+
titleColor: '#EEEEF6',
|
|
24
|
+
titleFontSize: 14,
|
|
25
|
+
titleFontWeight: 'bold',
|
|
26
|
+
descriptionColor: '#D4D4DB',
|
|
27
|
+
descriptionFontSize: 14,
|
|
28
|
+
descriptionFontWeight: 'normal'
|
|
29
|
+
};
|
|
30
|
+
const variantStyles = {
|
|
31
|
+
success: {
|
|
32
|
+
backgroundColor: '#166534',
|
|
33
|
+
borderColor: '#22C55E'
|
|
34
|
+
},
|
|
35
|
+
info: {
|
|
36
|
+
backgroundColor: '#1D4ED8',
|
|
37
|
+
borderColor: '#60A5FA'
|
|
38
|
+
},
|
|
39
|
+
warning: {
|
|
40
|
+
backgroundColor: '#B45309',
|
|
41
|
+
borderColor: '#FBBF24'
|
|
42
|
+
},
|
|
43
|
+
error: {
|
|
44
|
+
backgroundColor: '#B91C1C',
|
|
45
|
+
borderColor: '#F87171'
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
let toastConfig = {};
|
|
49
|
+
const configureToast = config => {
|
|
50
|
+
toastConfig = {
|
|
51
|
+
defaults: {
|
|
52
|
+
...toastConfig.defaults,
|
|
53
|
+
...config.defaults
|
|
54
|
+
},
|
|
55
|
+
options: {
|
|
56
|
+
...toastConfig.options,
|
|
57
|
+
...config.options
|
|
58
|
+
},
|
|
59
|
+
variants: {
|
|
60
|
+
...toastConfig.variants,
|
|
61
|
+
success: {
|
|
62
|
+
...toastConfig.variants?.success,
|
|
63
|
+
...config.variants?.success
|
|
64
|
+
},
|
|
65
|
+
info: {
|
|
66
|
+
...toastConfig.variants?.info,
|
|
67
|
+
...config.variants?.info
|
|
68
|
+
},
|
|
69
|
+
warning: {
|
|
70
|
+
...toastConfig.variants?.warning,
|
|
71
|
+
...config.variants?.warning
|
|
72
|
+
},
|
|
73
|
+
error: {
|
|
74
|
+
...toastConfig.variants?.error,
|
|
75
|
+
...config.variants?.error
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
exports.configureToast = configureToast;
|
|
81
|
+
const resetToastConfig = () => {
|
|
82
|
+
toastConfig = {};
|
|
83
|
+
};
|
|
84
|
+
exports.resetToastConfig = resetToastConfig;
|
|
85
|
+
const resolveToastStyle = ({
|
|
86
|
+
type,
|
|
87
|
+
style
|
|
88
|
+
}) => ({
|
|
89
|
+
...defaultToastStyle,
|
|
90
|
+
...toastConfig.defaults,
|
|
91
|
+
...variantStyles[type],
|
|
92
|
+
...toastConfig.variants?.[type],
|
|
93
|
+
...style
|
|
94
|
+
});
|
|
95
|
+
exports.resolveToastStyle = resolveToastStyle;
|
|
96
|
+
const resolveToastOptions = options => ({
|
|
97
|
+
...toastConfig.options,
|
|
98
|
+
...options,
|
|
99
|
+
style: resolveToastStyle({
|
|
100
|
+
type: options.type,
|
|
101
|
+
style: options.style
|
|
102
|
+
})
|
|
103
|
+
});
|
|
104
|
+
exports.resolveToastOptions = resolveToastOptions;
|
|
105
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["defaultToastStyle","backgroundColor","borderRadius","borderColor","borderWidth","shadowColor","shadowOpacity","shadowRadius","shadowOffsetX","shadowOffsetY","shadowElevation","animation","animationDurationMs","marginHorizontal","paddingHorizontal","paddingVertical","titleColor","titleFontSize","titleFontWeight","descriptionColor","descriptionFontSize","descriptionFontWeight","variantStyles","success","info","warning","error","toastConfig","configureToast","config","defaults","options","variants","exports","resetToastConfig","resolveToastStyle","type","style","resolveToastOptions"],"sourceRoot":"../../src","sources":["defaults.ts"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "configureToast", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _defaults.configureToast;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "resetToastConfig", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _defaults.resetToastConfig;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
exports.showToast = void 0;
|
|
19
|
+
var _defaults = require("./defaults.js");
|
|
20
|
+
var _nativeModule = require("./nativeModule.js");
|
|
21
|
+
const showToast = options => {
|
|
22
|
+
(0, _nativeModule.showRawNativeToast)((0, _defaults.resolveToastOptions)(options));
|
|
23
|
+
};
|
|
24
|
+
exports.showToast = showToast;
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_defaults","require","_nativeModule","showToast","options","showRawNativeToast","resolveToastOptions","exports"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAKA,IAAAC,aAAA,GAAAD,OAAA;AAiBO,MAAME,SAAS,GAAIC,OAAqB,IAAW;EACzD,IAAAC,gCAAkB,EAAC,IAAAC,6BAAmB,EAACF,OAAO,CAAC,CAAC;AACjD,CAAC;AAACG,OAAA,CAAAJ,SAAA,GAAAA,SAAA","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.showRawNativeToast = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
const {
|
|
9
|
+
NativeToast
|
|
10
|
+
} = _reactNative.NativeModules;
|
|
11
|
+
const showRawNativeToast = options => {
|
|
12
|
+
NativeToast?.show(options);
|
|
13
|
+
};
|
|
14
|
+
exports.showRawNativeToast = showRawNativeToast;
|
|
15
|
+
//# sourceMappingURL=nativeModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","NativeToast","NativeModules","showRawNativeToast","options","show","exports"],"sourceRoot":"../../src","sources":["nativeModule.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAOA,MAAM;EAAEC;AAAY,CAAC,GAAGC,0BAAoD;AAErE,MAAMC,kBAAkB,GAAIC,OAAqB,IAAW;EAClEH,WAAW,EAAEI,IAAI,CAACD,OAAO,CAAC;AAC3B,CAAC;AAACE,OAAA,CAAAH,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|