Commit b29be4f8 authored by Marek Kotewicz's avatar Marek Kotewicz
Browse files

scanner and tabbaritem

parent 37a3aa36
......@@ -13,14 +13,14 @@ import {
} from 'react-native'
import Tabs from 'react-native-tabs'
import Scanner from './scanner'
//import Camera from 'react-native-camera'
import Scanner from './src/scanner'
import TabBarItem from './src/tabbaritem'
export default class App extends Component {
constructor(props) {
super(props)
this.state = {
page: 'send'
page: 'scan'
};
}
......@@ -29,21 +29,22 @@ export default class App extends Component {
case 'send': return (<Text>Send</Text>)
case 'scan': return (<Scanner></Scanner>)
case 'accounts': return (<Text>Accounts</Text>)
default: return (<Text>Dupa {page} D</Text>)
}
}
render() {
var self = this;
var self = this
return (
<View style={styles.container}>
<Tabs selected='this.state.page' style={{backgroundColor:'white'}}
onSelect={el=>this.setState({page:el.props.name})}>
<Text name='send'>Send TX</Text>
<Text name='scan'>Scan QR</Text>
<Text name='accounts'>Accounts</Text>
onSelect={el=>this.setState({page:el.props.name})} selectedStyle={{color:'red'}}>
<TabBarItem name='send' text='Send TX' selectedItem={self.state.page}/>
<TabBarItem name='scan' text='Scan QR' selectedItem={self.state.page}/>
<TabBarItem name='accounts' text='Accounts' selectedItem={self.state.page}/>
</Tabs>
<View style={styles.scanner}>
{this.renderView(this.state.page)}
</View>
</View>
);
}
......@@ -66,4 +67,10 @@ const styles = StyleSheet.create({
color: '#333333',
marginBottom: 5,
},
scanner: {
flex: 1,
flexDirection: 'row',
marginTop: 20,
marginBottom: 50
},
});
......@@ -508,8 +508,12 @@
TargetAttributes = {
00E356ED1AD99517003FC87E = {
CreatedOnToolsVersion = 6.2;
DevelopmentTeam = T4ZYEBHX9P;
TestTargetID = 13B07F861A680F5B00A75B9A;
};
13B07F861A680F5B00A75B9A = {
DevelopmentTeam = T4ZYEBHX9P;
};
};
};
buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "NativeSigner" */;
......@@ -847,6 +851,7 @@
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
DEVELOPMENT_TEAM = T4ZYEBHX9P;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
......@@ -858,6 +863,7 @@
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = "-lc++";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NativeSigner.app/NativeSigner";
};
......@@ -868,6 +874,7 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
COPY_PHASE_STRIP = NO;
DEVELOPMENT_TEAM = T4ZYEBHX9P;
INFOPLIST_FILE = NativeSignerTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
......@@ -875,6 +882,7 @@
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = "-lc++";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NativeSigner.app/NativeSigner";
};
......@@ -886,6 +894,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = T4ZYEBHX9P;
INFOPLIST_FILE = NativeSigner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
......@@ -903,6 +912,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = T4ZYEBHX9P;
INFOPLIST_FILE = NativeSigner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
......
......@@ -80,7 +80,7 @@
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
......
......@@ -19,6 +19,8 @@
NSURL *jsCodeLocation;
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
// jsCodeLocation = [NSURL URLWithString:@"http://192.168.16.2:8081/index.ios.bundle"];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"NativeSigner"
......
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
......
......@@ -52,5 +52,7 @@
</dict>
<key>NSCameraUsageDescription</key>
<string>Your message to user when the camera is accessed for the first time</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Your message to user when the photo library is accessed for the first time</string>
</dict>
</plist>
'use strict';
import React, { Component } from 'react';
import {
Dimensions,
StyleSheet,
Text,
TouchableHighlight,
View
} from 'react-native';
import Camera from 'react-native-camera';
export default class Scanner extends Component {
render() {
return (
<View style={styles.container}>
<Camera
ref={(cam) => {
this.camera = cam;
}}
style={styles.preview}
aspect={Camera.constants.Aspect.fill}>
<Text style={styles.capture} onPress={this.takePicture.bind(this)}>[CAPTURE]</Text>
</Camera>
</View>
);
}
takePicture() {
this.camera.capture()
.then((data) => console.log(data))
.catch(err => console.error(err));
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'row',
marginTop: 20,
marginBottom: 50
},
preview: {
flex: 1,
justifyContent: 'flex-end',
alignItems: 'center',
},
capture: {
flex: 0,
backgroundColor: '#fff',
borderRadius: 5,
color: '#000',
padding: 10,
margin: 40
}
});
'use strict';
import React, { Component } from 'react'
import {
AppRegistry,
StyleSheet,
Text,
TouchableOpacity,
Vibration,
View
} from 'react-native'
import Camera from 'react-native-camera';
export default class Scanner extends Component {
_onPressCancel() {
var self = this
requestAnimationFrame(() => {
// cancel logic
})
}
_onBarCodeRead() {
var self = this
Vibration.vibrate([0, 500, 200, 500])
}
render() {
var self = this
var cancelButton = null;
this.barCodeFlag = true;
if (this.props.cancelButtonVisible) {
cancelButton = <CancelButton onPress={this._onPressCancel} title={this.props.cancelButtonTitle} />;
}
return (
<Camera onBarCodeRead={this._onBarCodeRead} style={styles.camera}>
<View style={styles.rectangleContainer}>
<View style={styles.rectangle}/>
</View>
{cancelButton}
</Camera>
)
}
}
//var QRCodeScreen = React.createClass({
//_onPressCancel: function() {
//var $this = this;
//requestAnimationFrame(function() {
//$this.props.navigator.pop();
//if ($this.props.onCancel) {
//$this.props.onCancel();
//}
//});
//},
//_onBarCodeRead: function(result) {
//var $this = this;
//if (this.barCodeFlag) {
//this.barCodeFlag = false;
//setTimeout(function() {
//VibrationIOS.vibrate();
//$this.props.navigator.pop();
//$this.props.onSucess(result.data);
//}, 1000);
//}
//},
//render: function() {
//var cancelButton = null;
//this.barCodeFlag = true;
//if (this.props.cancelButtonVisible) {
//cancelButton = <CancelButton onPress={this._onPressCancel} title={this.props.cancelButtonTitle} />;
//}
//return (
//<Camera onBarCodeRead={this._onBarCodeRead} style={styles.camera}>
//<View style={styles.rectangleContainer}>
//<View style={styles.rectangle}/>
//</View>
//{cancelButton}
//</Camera>
//);
//},
//});
var CancelButton = React.createClass({
render: function() {
return (
<View style={styles.cancelButton}>
<TouchableOpacity onPress={this.props.onPress}>
<Text style={styles.cancelButtonText}>{this.props.title}</Text>
</TouchableOpacity>
</View>
);
},
});
var styles = StyleSheet.create({
camera: {
flex: 1,
},
rectangleContainer: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'transparent',
},
rectangle: {
height: 250,
width: 250,
borderWidth: 2,
borderColor: '#00FFFF',
backgroundColor: 'transparent',
},
cancelButton: {
flexDirection: 'row',
justifyContent: 'center',
backgroundColor: 'white',
borderRadius: 3,
padding: 15,
width: 100,
bottom: 10,
},
cancelButtonText: {
fontSize: 17,
fontWeight: '500',
color: '#0097CE',
},
});
//module.exports = QRCodeScreen;
import React, { Component } from 'react'
import { View, Text, StyleSheet } from 'react-native'
export default class TabBarItem extends Component {
render() {
const {
name,
selectedItem,
text
} = this.props
const selected = selectedItem == name
return (
<View style={styles.item}>
<Text style={selected ? styles.selected : styles.normal}>{text}</Text>
</View>
)
}
}
const styles = StyleSheet.create({
item: {
alignItems: 'center',
},
normal: {
color: 'grey',
},
selected: {
color: 'red',
},
})
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment