@@ -107,24 +107,22 @@ - (void)_show:(NSString *)msg
107
107
NSString *positionString = RNToastPositionMap[@(position)] ?: CSToastPositionBottom;
108
108
dispatch_async (dispatch_get_main_queue (), ^{
109
109
RNToastViewController *controller = [RNToastViewController new ];
110
- [controller show: ^() {
111
- UIView *view = [self getToastView: controller];
112
- UIView __weak *weakView = view;
113
- RNToastViewController __weak *weakController = controller;
114
-
115
- UIView *toast = [view toastViewForMessage: msg title: nil image: nil style: style];
116
-
117
- void (^completion)(BOOL ) = ^(BOOL didTap) {
118
- [weakView removeFromSuperview ];
119
- [weakController hide ];
120
- };
121
- if (!CGPointEqualToPoint (offset, CGPointZero )) {
122
- CGPoint centerWithOffset = [self getCenterWithOffset: offset view: view toast: toast position: positionString];
123
- [view showToast: toast duration: duration position: [NSValue valueWithCGPoint: centerWithOffset] completion: completion];
124
- } else {
125
- [view showToast: toast duration: duration position: positionString completion: completion];
126
- }
127
- }];
110
+ [controller show ];
111
+ UIView *view = [self getToastView: controller];
112
+ UIView __weak *weakView = view;
113
+
114
+ UIView *toast = [view toastViewForMessage: msg title: nil image: nil style: style];
115
+
116
+ void (^completion)(BOOL ) = ^(BOOL didTap) {
117
+ [weakView removeFromSuperview ];
118
+ [controller hide ];
119
+ };
120
+ if (!CGPointEqualToPoint (offset, CGPointZero )) {
121
+ CGPoint centerWithOffset = [self getCenterWithOffset: offset view: view toast: toast position: positionString];
122
+ [view showToast: toast duration: duration position: [NSValue valueWithCGPoint: centerWithOffset] completion: completion];
123
+ } else {
124
+ [view showToast: toast duration: duration position: positionString completion: completion];
125
+ }
128
126
});
129
127
}
130
128
@@ -160,8 +158,8 @@ - (CGPoint)rnToast_centerPointForPosition:(NSString *)gravity withToast:(UIView
160
158
return CGPointMake (view.bounds .size .width / 2.0 , (view.bounds .size .height - (toast.frame .size .height / 2.0 )) - bottomPadding);
161
159
}
162
160
163
- - (UIView *)getToastView : (UIViewController *)ctrl {
164
- UIView *rootView = ctrl.view ;
161
+ - (UIView *)getToastView : (RNToastViewController *)ctrl {
162
+ UIView *rootView = ctrl.toastWindow ;
165
163
CGRect bounds = rootView.bounds ;
166
164
bounds.size .height -= _kbdHeight;
167
165
0 commit comments