react-native-db-models
react-native-db-models copied to clipboard
Android react version 0.19
Hi. I'm trying to use db-models and can't seem to get it working on genymotion android win10 computer. Seems that I can't run chrome debugger with this version of react so not sure where to look. Perhaps I can see the db in a directory of the emulator? Thanks, John
'use strict';
var React = require('react-native');
var Icon = require('react-native-vector-icons/Ionicons');
var styles = require('../Styles/style');
var login = require('../Styles/login');
var ButtonRounded = require('./Widgets/ButtonRounded');
var AppDispatcher = require('./../Dispatcher/AppDispatcher');
var StatusBarAndroid = require('react-native-android-statusbar');
var darker = require('../Styles/variable').darker;
var GLOBAL = require('./Widgets/Globals');
var DB = require('./DB.js');
// DB Emitter Initialized
var DBEvents = require('react-native-db-models').DBEvents ;
//, AsyncStorage,
var {
View,
Text,
TextInput,
Image,
StatusBarIOS,
TouchableOpacity,
AppRegistry
} = React;
StatusBarAndroid.setHexColor(darker);
// StatusBarIOS.setStyle('light-content');
// Only "all" event emitter is available
DBEvents.on("all", function(){
console.log("Database changed");
})
var Login = React.createClass({
get_users: function(){
DB.users.get_all(function(result){
console.log(result);
})
return
},
getInitialState: function() {
// DB.users.add({first_name: GLOBAL.loginuser, password: 123}, function(added_data){
DB.users.add({first_name: 'bsullivan', password: 123}, function(added_data){
console.log(added_data);
})
return {value: GLOBAL.loginuser};//[email protected]'};
},
handleChange: function(event) {
GLOBAL.loginuser=event.target.value;
this.setState({value: event.target.value});
},
login(){
DB.users.add({first_name: 'bsullivan', password: 123}, function(added_data){
console.log(added_data);
})
var Home = require('./Home');
if ((this.state.value ==='aamore' ||this.state.value ==='bsullivan' )&&(this.state.pass ==='123')){
// 11832
AppDispatcher.dispatch({
actionType: 'Navigate',
component: Home,
passProps: {username: this.state.value}
});
}
},
signup(){
var Signup = require('./Signup');
AppDispatcher.dispatch({
actionType: 'Navigate',
component: Signup
});
},
render: function() {
return (
<View style={login.color}>
<Image source={require('../img/glow2.png')} style={login.container}>
<Image source={require('../img/bb-phone1.png')} style={login.shadow}>
<View style={login.abg}>
<View >
<Text >GLOBAL.loginuser {GLOBAL.loginuser} </Text>
</View>
<View>
<Text onPress={this.get_users}> Hello </Text>
</View>
<View style={{position:'relative',borderColor: 'white', borderWidth: 0.8, borderTopWidth: 0, borderRightWidth: 0, borderLeftWidth: 0, margin: 15, marginTop: 5,}}>
<TextInput
style={login.textInput}
placeholder={'EMAIL'}
placeholderTextColor={'rgba(255, 255, 255, 0.7'}
onChangeText={(value) => this.setState({value})}
value={this.state.value} />
<Icon name="person" size={27} color="rgba(255,255,255,0.8)" style={{position:'absolute',top:6, left: 6}}/>
</View>
<View style={{position:'relative',borderColor: 'white', borderWidth: 0.8, borderTopWidth: 0, borderRightWidth: 0, borderLeftWidth: 0, margin: 15, marginTop: 5,}}>
<TextInput
style={login.textInput}
placeholder={'PASSWORD'}
secureTextEntry={true}
placeholderTextColor={'rgba(255, 255, 255, 0.7'}
onChangeText={(pass) => this.setState({pass})}
pass={this.state.pass} />
<Icon name="ios-unlocked-outline" size={27} color="rgba(255,255,255,0.8)" style={{position:'absolute',top:6, left: 6}}/>
</View>
<ButtonRounded
onPress={this.login}
text="Login" />
<TouchableOpacity onPress={this.signuep} style={{alignSelf: 'flex-end', marginRight: 15, marginTop: 10}}>
<Text style={login.registerLink}>
Forgot Password
</Text>
</TouchableOpacity>
</View>
</Image>
</Image>
</View>
);
}
});
module.exports = Login;
Hey @johntom
I haven't used it on an Android before so I wouldn't know what the problem is. Just to clarify, is the DB not behaving the way it should?