This repository was archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
298 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React, {TouchableNativeFeedback} from 'react-native'; | ||
|
||
export default (props) => { | ||
return <TouchableNativeFeedback {...props}>{props.children}</TouchableNativeFeedback> | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React, {TouchableHighlight} from 'react-native'; | ||
|
||
export default (props) => { | ||
return <TouchableHighlight underlayColor="#007AFF" {...props}>{props.children}</TouchableHighlight> | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,15 @@ | ||
/** | ||
* Sample React Native App | ||
* https://github.com/facebook/react-native | ||
*/ | ||
'use strict'; | ||
import React, { | ||
AppRegistry, | ||
Component, | ||
StyleSheet, | ||
Text, | ||
View | ||
Component | ||
} from 'react-native'; | ||
import App from './components/App'; | ||
|
||
class koandeck extends Component { | ||
render() { | ||
render(){ | ||
return ( | ||
<View style={styles.container}> | ||
<Text style={styles.welcome}> | ||
Welcome to React Native! | ||
</Text> | ||
<Text style={styles.instructions}> | ||
To get started, edit index.ios.js | ||
</Text> | ||
<Text style={styles.instructions}> | ||
Press Cmd+R to reload,{'\n'} | ||
Cmd+D or shake for dev menu | ||
</Text> | ||
</View> | ||
<App /> | ||
); | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
backgroundColor: '#F5FCFF', | ||
}, | ||
welcome: { | ||
fontSize: 20, | ||
textAlign: 'center', | ||
margin: 10, | ||
}, | ||
instructions: { | ||
textAlign: 'center', | ||
color: '#333333', | ||
marginBottom: 5, | ||
}, | ||
}); | ||
|
||
AppRegistry.registerComponent('koandeck', () => koandeck); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// Orientation.h | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <UIKit/UIKit.h> | ||
#import "RCTBridgeModule.h" | ||
#import "RCTBridge.h" | ||
#import "RCTEventDispatcher.h" | ||
#import "AppDelegate.h" | ||
|
||
@interface Orientation : NSObject <RCTBridgeModule> | ||
+ (void)setOrientation: (UIInterfaceOrientationMask)orientation; | ||
+ (UIInterfaceOrientationMask)getOrientation; | ||
@end | ||
|
||
@interface AppDelegate (Orientation) | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
// | ||
// Orientation.m | ||
// | ||
|
||
#import "Orientation.h" | ||
#import "AppDelegate.h" | ||
|
||
|
||
@implementation AppDelegate (Orientation) | ||
|
||
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { | ||
return [Orientation getOrientation]; | ||
} | ||
|
||
@end | ||
|
||
|
||
@implementation Orientation | ||
|
||
@synthesize bridge = _bridge; | ||
|
||
static UIInterfaceOrientationMask _orientation = UIInterfaceOrientationMaskAllButUpsideDown; | ||
+ (void)setOrientation: (UIInterfaceOrientationMask)orientation { | ||
_orientation = orientation; | ||
} | ||
+ (UIInterfaceOrientationMask)getOrientation { | ||
return _orientation; | ||
} | ||
|
||
- (instancetype)init | ||
{ | ||
if ((self = [super init])) { | ||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange:) name:@"UIDeviceOrientationDidChangeNotification" object:nil]; | ||
} | ||
return self; | ||
|
||
} | ||
|
||
- (void)dealloc | ||
{ | ||
[[NSNotificationCenter defaultCenter] removeObserver:self]; | ||
} | ||
|
||
- (void)deviceOrientationDidChange:(NSNotification *)notification | ||
{ | ||
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; | ||
[_bridge.eventDispatcher sendDeviceEventWithName:@"specificOrientationDidChange" | ||
body:@{@"specificOrientation": [self getSpecificOrientationStr:orientation]}]; | ||
|
||
[_bridge.eventDispatcher sendDeviceEventWithName:@"orientationDidChange" | ||
body:@{@"orientation": [self getOrientationStr:orientation]}]; | ||
|
||
} | ||
|
||
- (NSString *)getOrientationStr: (UIDeviceOrientation)orientation { | ||
NSString *orientationStr; | ||
switch (orientation) { | ||
case UIDeviceOrientationPortrait: | ||
orientationStr = @"PORTRAIT"; | ||
break; | ||
case UIDeviceOrientationLandscapeLeft: | ||
case UIDeviceOrientationLandscapeRight: | ||
|
||
orientationStr = @"LANDSCAPE"; | ||
break; | ||
|
||
case UIDeviceOrientationPortraitUpsideDown: | ||
orientationStr = @"PORTRAITUPSIDEDOWN"; | ||
break; | ||
|
||
default: | ||
orientationStr = @"UNKNOWN"; | ||
break; | ||
} | ||
return orientationStr; | ||
} | ||
|
||
- (NSString *)getSpecificOrientationStr: (UIDeviceOrientation)orientation { | ||
NSString *orientationStr; | ||
switch (orientation) { | ||
case UIDeviceOrientationPortrait: | ||
orientationStr = @"PORTRAIT"; | ||
break; | ||
|
||
case UIDeviceOrientationLandscapeLeft: | ||
orientationStr = @"LANDSCAPE-LEFT"; | ||
break; | ||
|
||
case UIDeviceOrientationLandscapeRight: | ||
orientationStr = @"LANDSCAPE-RIGHT"; | ||
break; | ||
|
||
case UIDeviceOrientationPortraitUpsideDown: | ||
orientationStr = @"PORTRAITUPSIDEDOWN"; | ||
break; | ||
|
||
default: | ||
orientationStr = @"UNKNOWN"; | ||
break; | ||
} | ||
return orientationStr; | ||
} | ||
|
||
RCT_EXPORT_MODULE(); | ||
|
||
RCT_EXPORT_METHOD(getOrientation:(RCTResponseSenderBlock)callback) | ||
{ | ||
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; | ||
NSString *orientationStr = [self getOrientationStr:orientation]; | ||
callback(@[[NSNull null], orientationStr]); | ||
} | ||
|
||
RCT_EXPORT_METHOD(getSpecificOrientation:(RCTResponseSenderBlock)callback) | ||
{ | ||
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; | ||
NSString *orientationStr = [self getSpecificOrientationStr:orientation]; | ||
callback(@[[NSNull null], orientationStr]); | ||
} | ||
|
||
RCT_EXPORT_METHOD(lockToPortrait) | ||
{ | ||
#if DEBUG | ||
NSLog(@"Locked to Portrait"); | ||
#endif | ||
[Orientation setOrientation:UIInterfaceOrientationMaskPortrait]; | ||
[[NSOperationQueue mainQueue] addOperationWithBlock:^ { | ||
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger: UIInterfaceOrientationPortrait] forKey:@"orientation"]; | ||
}]; | ||
|
||
} | ||
|
||
RCT_EXPORT_METHOD(lockToLandscape) | ||
{ | ||
#if DEBUG | ||
NSLog(@"Locked to Landscape"); | ||
#endif | ||
[Orientation setOrientation:UIInterfaceOrientationMaskLandscape]; | ||
[[NSOperationQueue mainQueue] addOperationWithBlock:^ { | ||
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger: UIInterfaceOrientationLandscapeLeft] forKey:@"orientation"]; | ||
}]; | ||
|
||
} | ||
|
||
RCT_EXPORT_METHOD(lockToLandscapeRight) | ||
{ | ||
#if DEBUG | ||
NSLog(@"Locked to Landscape Right"); | ||
#endif | ||
[Orientation setOrientation:UIInterfaceOrientationMaskLandscapeLeft]; | ||
[[NSOperationQueue mainQueue] addOperationWithBlock:^ { | ||
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger: UIInterfaceOrientationLandscapeLeft] forKey:@"orientation"]; | ||
}]; | ||
|
||
} | ||
|
||
RCT_EXPORT_METHOD(lockToLandscapeLeft) | ||
{ | ||
#if DEBUG | ||
NSLog(@"Locked to Landscape Left"); | ||
#endif | ||
[Orientation setOrientation:UIInterfaceOrientationMaskLandscapeRight]; | ||
[[NSOperationQueue mainQueue] addOperationWithBlock:^ { | ||
// this seems counter intuitive | ||
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger: UIInterfaceOrientationLandscapeRight] forKey:@"orientation"]; | ||
}]; | ||
|
||
} | ||
|
||
RCT_EXPORT_METHOD(unlockAllOrientations) | ||
{ | ||
#if DEBUG | ||
NSLog(@"Unlock All Orientations"); | ||
#endif | ||
[Orientation setOrientation:UIInterfaceOrientationMaskAllButUpsideDown]; | ||
// AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; | ||
// delegate.orientation = 3; | ||
} | ||
|
||
- (NSDictionary *)constantsToExport | ||
{ | ||
|
||
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; | ||
NSString *orientationStr = [self getOrientationStr:orientation]; | ||
|
||
return @{ | ||
@"initialOrientation": orientationStr | ||
}; | ||
} | ||
|
||
@end | ||
|
Oops, something went wrong.