Skip to content

Update with wix's code #1

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

Merged
merged 29 commits into from
Aug 31, 2016
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1ccaedc
initial commit: implement a top notification view which is displayed …
artald May 25, 2016
f678e25
added autoresizing-mask (support rotation)
artald Jun 7, 2016
7b21360
added auto-resizing mask to support rotation (
artald Jun 7, 2016
1c58bd4
support showing a bottom notification
artald Jun 7, 2016
20c7142
added simple animation preset
artald Jun 7, 2016
20f1773
if necessary, add a view with the same color to cover the gap if ther…
artald Jun 7, 2016
d98ad47
Bug fix: in case there is a interactivePopGestureRecognizer, it preve…
artald Jun 29, 2016
9b9a5a6
merge from master
artald Jul 3, 2016
61891e4
Merge branch 'RCCNotification'
artald Jul 3, 2016
5818177
added notification native files to project (removed on merge)
artald Jul 3, 2016
c86f28c
version bump
artald Jul 3, 2016
bb354aa
notification: fixed animation damping not taken into account
artald Jul 4, 2016
e4ff1be
support NewRelic custom interaction name
artald Jul 5, 2016
1e48603
fixed view leaking and component unmount not called
DanielZlotin Jul 12, 2016
fe011d6
2.0.9
DanielZlotin Jul 12, 2016
0e7b5f1
added launchOptions to RCCManager
Jul 18, 2016
de32064
Merge pull request #73 from wix/add-launch-options
DanielZlotin Jul 19, 2016
96d2a3a
2.0.10
DanielZlotin Jul 19, 2016
09fb25b
Fixed a bug with dismissAllModalPresenters that caused a leak in RCT…
artald Jul 20, 2016
d76944e
feat(tab item): set accessibilityIdentifier property for e2e tests
ofirdagan Aug 4, 2016
c7636c6
Merge pull request #83 from ofirdagan/master
artald Aug 7, 2016
d2fc428
version bump
artald Aug 7, 2016
b90c77a
Update README.md
drorbiran Aug 15, 2016
620b07c
support RN31:
artald Aug 24, 2016
fff138c
if we don't have any modals shown - don't show the dismiss animation …
artald Aug 25, 2016
f34930e
version bump
artald Aug 25, 2016
efee40e
When the drawer pan gesture starts - cancel react touches so the touc…
artald Aug 25, 2016
32570ca
version bump
artald Aug 25, 2016
ff31832
update package.json
DanielZlotin Aug 28, 2016
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
38 changes: 37 additions & 1 deletion example/MovieListScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ var {
} = ReactNative;

require('./LightBox');
require('./Notification');

var Controllers = require('react-native-controllers');
var {
Modal,
ControllerRegistry,
Constants
Constants,
Notification
} = Controllers;

var MovieListScreen = React.createClass({
Expand Down Expand Up @@ -56,6 +58,20 @@ var MovieListScreen = React.createClass({
});
},

onShowNotificationClick: function(animationParams, shadowRadius, position) {
Notification.show({
component: 'NotificationExample',
passProps: {
greeting: 'This is a Notification!'
},
position: position,
animation: animationParams,
dismissWithSwipe: true,
autoDismissTimerSec: 5,
shadowRadius: shadowRadius
});
},

onShowModalVcClick: async function() {
// defaults: Modal.showController('ModalScreenTester');
// this example shows animation type and passProps
Expand Down Expand Up @@ -143,6 +159,26 @@ var MovieListScreen = React.createClass({
<Text style={styles.button}>Replace root animated</Text>
</TouchableOpacity>

<TouchableOpacity onPress={ this.onShowNotificationClick.bind(this, Notification.AnimationPresets.default, 0, 'top') }>
<Text style={styles.button}>Show Default Notification</Text>
</TouchableOpacity>

<TouchableOpacity onPress={ this.onShowNotificationClick.bind(this, Notification.AnimationPresets.simple, 0, 'top') }>
<Text style={styles.button}>Show Simple Notification</Text>
</TouchableOpacity>

<TouchableOpacity onPress={ this.onShowNotificationClick.bind(this, Notification.AnimationPresets.default, 10, 'top') }>
<Text style={styles.button}>Show Notification With Shadow</Text>
</TouchableOpacity>

<TouchableOpacity onPress={ this.onShowNotificationClick.bind(this, Notification.AnimationPresets.swing, 0, 'top') }>
<Text style={styles.button}>Show Swing Notification</Text>
</TouchableOpacity>

<TouchableOpacity onPress={ this.onShowNotificationClick.bind(this, Notification.AnimationPresets.default, 0, 'bottom') }>
<Text style={styles.button}>Show Bottom Notification</Text>
</TouchableOpacity>

</ScrollView>
);
},
Expand Down
64 changes: 64 additions & 0 deletions example/Notification.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

'use strict';

var React = require('react');
var ReactNative = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
TouchableOpacity,
Dimensions
} = ReactNative;

var Controllers = require('react-native-controllers');
var {
Notification,
} = Controllers;

var NotificationExample = React.createClass({
_onButtonClick: function() {
Notification.dismiss();
},

render: function() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
{this.props.greeting}
</Text>
<TouchableOpacity onPress={ this._onButtonClick }>
<Text style={styles.button}>Dismiss</Text>
</TouchableOpacity>
</View>
);
}
});

var styles = StyleSheet.create({
container: {
flex: 1,
width: Dimensions.get('window').width,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#d6e7ad'
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
paddingTop: 20
},
button: {
textAlign: 'center',
fontSize: 18,
marginBottom: 10,
marginTop:10,
color: '#4692ad'
}
});

AppRegistry.registerComponent('NotificationExample', () => NotificationExample);

module.exports = NotificationExample;
35 changes: 35 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,41 @@ var Controllers = {
}
},

Notification: {
show: async function(params = {}) {
await RCCManager.showNotification(params);
},
dismiss: async function(params = {}) {
await RCCManager.dismissNotification(params);
},
AnimationPresets: {
default: {
animated: true,
duration: 0.5,
damping: 0.65,
type: 'slide-down',
fade: true
},
simple: {
animated: true,
duration: 0.3,
type: 'slide-down',
fade: true
},
swing: {
animated: true,
duration: 0.65,
damping: 0.6,
type: 'swing'
},
fade: {
animated: true,
duration: 0.3,
fade: true
}
}
},

NavigationToolBarIOS: OriginalReactNative.requireNativeComponent('RCCToolBar', null),

Constants: Constants
Expand Down
17 changes: 17 additions & 0 deletions ios/RCCLightBox.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#import "RCTRootView.h"
#import "RCTRootViewDelegate.h"
#import "RCTConvert.h"
#import "RCTHelpers.h"
#import <objc/runtime.h>

const NSInteger kLightBoxTag = 0x101010;
Expand All @@ -12,6 +13,7 @@ @interface RCCLightBoxView : UIView
@property (nonatomic, strong) UIVisualEffectView *visualEffectView;
@property (nonatomic, strong) UIView *overlayColorView;
@property (nonatomic, strong) NSDictionary *params;
@property (nonatomic) BOOL yellowBoxRemoved;
@end

@implementation RCCLightBoxView
Expand All @@ -21,7 +23,10 @@ -(instancetype)initWithFrame:(CGRect)frame params:(NSDictionary*)params
self = [super initWithFrame:frame];
if (self)
{
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

self.params = params;
self.yellowBoxRemoved = NO;

NSDictionary *passProps = self.params[@"passProps"];

Expand All @@ -32,6 +37,7 @@ -(instancetype)initWithFrame:(CGRect)frame params:(NSDictionary*)params
if (style[@"backgroundBlur"] != nil && ![style[@"backgroundBlur"] isEqualToString:@"none"])
{
self.visualEffectView = [[UIVisualEffectView alloc] init];
self.visualEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.visualEffectView.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
[self addSubview:self.visualEffectView];
}
Expand All @@ -50,6 +56,7 @@ -(instancetype)initWithFrame:(CGRect)frame params:(NSDictionary*)params
}

self.reactView = [[RCTRootView alloc] initWithBridge:[[RCCManager sharedInstance] getBridge] moduleName:self.params[@"component"] initialProperties:passProps];
self.reactView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
self.reactView.backgroundColor = [UIColor clearColor];
self.reactView.sizeFlexibility = RCTRootViewSizeFlexibilityWidthAndHeight;
self.reactView.center = self.center;
Expand All @@ -63,6 +70,16 @@ -(instancetype)initWithFrame:(CGRect)frame params:(NSDictionary*)params
return self;
}

-(void)layoutSubviews
{
[super layoutSubviews];

if(!self.yellowBoxRemoved)
{
self.yellowBoxRemoved = [RCTHelpers removeYellowBox:self.reactView];
}
}

-(void)removeAllObservers
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
Expand Down
1 change: 1 addition & 0 deletions ios/RCCManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

-(void)initBridgeWithBundleURL:(NSURL *)bundleURL;
-(RCTBridge*)getBridge;
-(UIWindow*)getAppWindow;

-(void)registerController:(UIViewController*)controller componentId:(NSString*)componentId componentType:(NSString*)componentType;
-(id)getControllerWithId:(NSString*)componentId componentType:(NSString*)componentType;
Expand Down
7 changes: 7 additions & 0 deletions ios/RCCManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ -(RCTBridge*)getBridge
return self.sharedBridge;
}

-(UIWindow*)getAppWindow
{
UIApplication *app = [UIApplication sharedApplication];
UIWindow *window = (app.keyWindow != nil) ? app.keyWindow : app.windows[0];
return window;
}

#pragma mark - RCTBridgeDelegate methods

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
Expand Down
14 changes: 13 additions & 1 deletion ios/RCCManagerModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import "RCTConvert.h"
#import "RCCTabBarController.h"
#import "RCCTheSideBarManagerViewController.h"

#import "RCCNotification.h"

#define kSlideDownAnimationDuration 0.35

Expand Down Expand Up @@ -310,4 +310,16 @@ -(BOOL)viewControllerIsModal:(UIViewController*)viewController
}
}

RCT_EXPORT_METHOD(
showNotification:(NSDictionary*)params resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
{
[RCCNotification showWithParams:params resolver:resolve rejecter:reject];
}

RCT_EXPORT_METHOD(
dismissNotification:(NSDictionary*)params resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
{
[RCCNotification dismissWithParams:params resolver:resolve rejecter:reject];
}

@end
8 changes: 8 additions & 0 deletions ios/RCCNotification.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

#import <Foundation/Foundation.h>
#import "RCCManager.h"

@interface RCCNotification : NSObject
+(void)showWithParams:(NSDictionary*)params resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject;
+(void)dismissWithParams:(NSDictionary*)params resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject;
@end
Loading