Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update RNBlurModalView.m (added "tap anywhere to close" feature) #29

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions RNBlurModalView.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
extern NSString * const kRNBlurDidShowNotification;
extern NSString * const kRNBlurDidHidewNotification;

@interface RNBlurModalView : UIView
@interface RNBlurModalView : UIView <UIGestureRecognizerDelegate>

@property (assign, readonly) BOOL isVisible;

Expand All @@ -52,7 +52,7 @@ extern NSString * const kRNBlurDidHidewNotification;
- (void)hide;
- (void)hideWithDuration:(CGFloat)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options completion:(void (^)(void))completion;

-(void)hideCloseButton:(BOOL)hide;
- (void)hideCloseButton:(BOOL)hide;
- (void)tapAnywhereToClose:(BOOL)tap;


@end
@end
17 changes: 15 additions & 2 deletions RNBlurModalView.m
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ @implementation RNBlurModalView {
RNCloseButton *_dismissButton;
RNBlurView *_blurView;
RNBlurCompletion _completion;
UITapGestureRecognizer *_tapGesture;
}

+ (UIView*)generateModalViewWithTitle:(NSString*)title message:(NSString*)message {
Expand Down Expand Up @@ -158,6 +159,9 @@ - (id)initWithFrame:(CGRect)frame {
UIViewAutoresizingFlexibleTopMargin);

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationDidChangeNotification:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];

_tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hide)];

}
return self;
}
Expand Down Expand Up @@ -189,7 +193,7 @@ - (id)initWithViewController:(UIViewController*)viewController title:(NSString*)
return self;
}

- (id)initWithParentView:(UIView*)parentView view:(UIView*)view {
- (id)initWithParentView:(UIView*)parentView view:(UIView*)view {
if (self = [self initWithFrame:CGRectMake(0, 0, parentView.width, parentView.height)]) {
[self addSubview:view];
_contentView = view;
Expand All @@ -199,6 +203,7 @@ - (id)initWithParentView:(UIView*)parentView view:(UIView*)view {
_contentView.clipsToBounds = YES;
_contentView.layer.masksToBounds = YES;


_dismissButton.center = CGPointMake(view.left, view.top);
[self addSubview:_dismissButton];
}
Expand Down Expand Up @@ -379,10 +384,18 @@ - (void)hideWithDuration:(CGFloat)duration delay:(NSTimeInterval)delay options:(
}
}

-(void)hideCloseButton:(BOOL)hide {
- (void)hideCloseButton:(BOOL)hide {
[_dismissButton setHidden:hide];
}

- (void)tapAnywhereToClose:(BOOL)tap {
if (tap) {
[_contentView.superview addGestureRecognizer:_tapGesture];
} else {
[_contentView.superview removeGestureRecognizer:_tapGesture];
}
}

@end

#pragma mark - RNBlurView
Expand Down