Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vonovak/react-native-simple-toast
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.0.1
Choose a base ref
...
head repository: vonovak/react-native-simple-toast
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.0.2
Choose a head ref
  • 3 commits
  • 6 files changed
  • 2 contributors

Commits on Aug 23, 2023

  1. docs: new arch requirement

    vonovak authored Aug 23, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    de95e06 View commit details

Commits on Oct 8, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    81edc30 View commit details
  2. chore: release 3.0.2

    vonovak committed Oct 8, 2023
    Copy the full SHA
    e7cfd8b View commit details
Showing with 27 additions and 39 deletions.
  1. +1 −1 README.md
  2. +2 −2 example/ios/Podfile.lock
  3. +18 −20 ios/RNSimpleToast.mm
  4. +4 −2 ios/RNToastViewController.h
  5. +1 −13 ios/RNToastViewController.m
  6. +1 −1 package.json
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ React Native Toast component for both Android and iOS. It just lets iOS users ha

## Summary

✅ supports both old and new architecture
✅ supports both old and new architecture (RN >= 0.71 is required for new arch)

✅ extremely simple fire-and-forget api, same as `ToastAndroid`

4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -266,7 +266,7 @@ PODS:
- React-jsinspector (0.71.12)
- React-logger (0.71.12):
- glog
- react-native-simple-toast (2.0.1):
- react-native-simple-toast (3.0.1):
- React-Core
- Toast (~> 4)
- React-perflogger (0.71.12)
@@ -496,7 +496,7 @@ SPEC CHECKSUMS:
React-jsiexecutor: 509cd947c28834614808ce056ee8eb700a0662aa
React-jsinspector: ec4dcbfb1f4e72f04f826a0301eceee5fa7ca540
React-logger: 35538accacf2583693fbc3ee8b53e69a1776fcee
react-native-simple-toast: ba0299fee44a1b52fcf9669ff11d4a2278c9c9ab
react-native-simple-toast: 0c7d14bcad288b5b83ae4b0eea65651b4ca829b0
React-perflogger: 75b0e25075c67565a830985f3c373e2eae5389e0
React-RCTActionSheet: a0c3e916b327e297d124d9ebe8b0c721840ee04d
React-RCTAnimation: 3da7025801d7bf0f8cfd94574d6278d5b82a8b88
38 changes: 18 additions & 20 deletions ios/RNSimpleToast.mm
Original file line number Diff line number Diff line change
@@ -107,24 +107,22 @@ - (void)_show:(NSString *)msg
NSString *positionString = RNToastPositionMap[@(position)] ?: CSToastPositionBottom;
dispatch_async(dispatch_get_main_queue(), ^{
RNToastViewController *controller = [RNToastViewController new];
[controller show:^() {
UIView *view = [self getToastView:controller];
UIView __weak *weakView = view;
RNToastViewController __weak *weakController = controller;

UIView *toast = [view toastViewForMessage:msg title:nil image:nil style:style];

void (^completion)(BOOL) = ^(BOOL didTap) {
[weakView removeFromSuperview];
[weakController hide];
};
if (!CGPointEqualToPoint(offset, CGPointZero)) {
CGPoint centerWithOffset = [self getCenterWithOffset:offset view:view toast:toast position:positionString];
[view showToast:toast duration:duration position:[NSValue valueWithCGPoint:centerWithOffset] completion:completion];
} else {
[view showToast:toast duration:duration position:positionString completion:completion];
}
}];
[controller show];
UIView *view = [self getToastView:controller];
UIView __weak *weakView = view;

UIView *toast = [view toastViewForMessage:msg title:nil image:nil style:style];

void (^completion)(BOOL) = ^(BOOL didTap) {
[weakView removeFromSuperview];
[controller hide];
};
if (!CGPointEqualToPoint(offset, CGPointZero)) {
CGPoint centerWithOffset = [self getCenterWithOffset:offset view:view toast:toast position:positionString];
[view showToast:toast duration:duration position:[NSValue valueWithCGPoint:centerWithOffset] completion:completion];
} else {
[view showToast:toast duration:duration position:positionString completion:completion];
}
});
}

@@ -160,8 +158,8 @@ - (CGPoint)rnToast_centerPointForPosition:(NSString *)gravity withToast:(UIView
return CGPointMake(view.bounds.size.width / 2.0, (view.bounds.size.height - (toast.frame.size.height / 2.0)) - bottomPadding);
}

- (UIView *)getToastView:(UIViewController *)ctrl {
UIView *rootView = ctrl.view;
- (UIView *)getToastView:(RNToastViewController *)ctrl {
UIView *rootView = ctrl.toastWindow;
CGRect bounds = rootView.bounds;
bounds.size.height -= _kbdHeight;

6 changes: 4 additions & 2 deletions ios/RNToastViewController.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#import <UIKit/UIKit.h>

@interface RNToastViewController : UIViewController
@interface RNToastViewController : NSObject

- (void)show:(void (^)(void))completion;
@property(nonatomic, strong) UIWindow *toastWindow;

- (void)show;
- (void)hide;

@end
14 changes: 1 addition & 13 deletions ios/RNToastViewController.m
Original file line number Diff line number Diff line change
@@ -2,17 +2,8 @@
#import "RNToastViewController.h"
#import <React/RCTUtils.h>

@interface RNToastViewController ()

@property(nonatomic, strong) UIWindow *toastWindow;

@end

@implementation RNToastViewController

// presenting directly from RCTSharedApplication().keyWindow won't work for Alerts
// which is why we have our own VC

- (UIWindow *)toastWindow
{
if (_toastWindow == nil) {
@@ -29,7 +20,6 @@ - (UIWindow *)toastWindow
}

if (_toastWindow) {
_toastWindow.rootViewController = [UIViewController new];
_toastWindow.windowLevel = UIWindowLevelAlert + 1;
_toastWindow.userInteractionEnabled = NO;
}
@@ -38,10 +28,8 @@ - (UIWindow *)toastWindow
return _toastWindow;
}

- (void)show:(void (^)(void))completion {
self.modalPresentationStyle = UIModalPresentationOverCurrentContext;
- (void)show {
[self.toastWindow setHidden:NO];
[self.toastWindow.rootViewController presentViewController:self animated:NO completion:completion];
}

- (void)hide {
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-simple-toast",
"version": "3.0.1",
"version": "3.0.2",
"description": "test",
"main": "lib/commonjs/index",
"module": "lib/module/index",