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
createCount(){ | |
AsyncStorage.getItem('count', (err,result) => { | |
if(!result){ | |
AsyncStorage.setItem('count', JSON.stringify({}), (err,resultt) => {}); | |
} | |
}); | |
} |
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
createNewKey(name,backgroundColor){ | |
return new Promise((resolve,reject)=>{ | |
this.getItems().then((data)=>{ | |
let tempKey = new Date().getTime(); | |
data[tempKey] = { | |
name, //Count Name | |
count:0, | |
backgroundColor, // Count Background Color | |
counts:[] // counts | |
}; |
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
setItemWithKey(key,obj){ | |
return new Promise((resolve,reject)=>{ | |
// count object example | |
// obj = { | |
// action : 1 || 0, | |
// time, | |
// } | |
this.getItems().then((data)=>{ | |
if(obj.action === 1){ | |
data[key].count++; |
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
import { NativeModules } from 'react-native' | |
var InAppUtils = require('NativeModules').InAppUtils; | |
class inApp { | |
myProductIds = [ | |
'inApp.product.id' | |
] | |
loadProdcts(){ |
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
constructor(props){ | |
this.socket = SocketIOClient('http://192.168.1.183:3000'); //Local ip'niz yada http://locahost:3000 olmalı | |
this.socket.on('messages', this.onReceivedMessage); | |
this.socket.on('userId', this.getUserId); | |
} |
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
onReceivedMessage(mes){ | |
const arrMes = [{...mes.messages}]; | |
this.setState((previousState) => ({ | |
messages: GiftedChat.append(previousState.messages, arrMes), | |
})); | |
} | |
onSend(messages){ | |
const mes = messages[0]; | |
const { username } = this.state; |
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
render() { | |
const { userId, isReady } = this.state; | |
if(!isReady){ | |
return this.renderUsernameView(); | |
} | |
return ( | |
<GiftedChat | |
messages={this.state.messages} | |
onSend={this.onSend} | |
onPressAvatar={ (user)=> alert(user.name)} |
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
renderUsernameView(){ | |
return( | |
<View style={ styles.container }> | |
<View style={ styles.textInputContainer }> | |
<TextInput | |
style={styles.textInput} | |
placeholder={'Username'} | |
onChangeText={(username) => this.setState({username})} | |
underlineColorAndroid={'transparent'} | |
value={this.state.text} |
OlderNewer