Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

edi-chat

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

edi-chat - npm Package Compare versions

Comparing version 0.0.33 to 0.0.35

176

index.js

@@ -26,3 +26,3 @@ import React, { Component } from 'react';

<Text style={[styles.text, (position === 'left' ? styles.textLeft : styles.textRight)]}>
{text}
{text}
</Text>

@@ -33,8 +33,12 @@ );

var flexStyle = {};
if ( this.props.item.text.length > 40 ) {
var text = "";
if ( this.props.item && this.props.item.text && this.props.item.text.length > 40 ) {
flexStyle.flex = 1;
}
if(this.props.item && this.props.item.text){
text = this.props.item.text;
}
return (
<View style={[styles.bubble, (this.props.item.position === 'left' ? styles.bubbleLeft : styles.bubbleRight), flexStyle]}>
{this.renderText(this.props.item.text, this.props.item.position)}
{this.renderText(text, this.props.item.position)}
</View>

@@ -46,2 +50,4 @@ )

class chat extends Component {
constructor(props) {

@@ -59,7 +65,16 @@ super(props);

}
this.listHeight=0;
}
componentDidMount() {
this.scrollResponder = this.listview.getScrollResponder();
}
scrollToBottom() {
if (this.listHeight && this.footerY && this.footerY > this.listHeight) {
var scrollDistance = this.listHeight - this.footerY;
this.scrollResponder.scrollTo({
y: -scrollDistance,
});
}
}
}
setLista(lista,SetState){

@@ -72,2 +87,3 @@ if (SetState===false || !SetState) {

}
this.scrollToBottom();
}

@@ -79,3 +95,3 @@

<Text style={[styles.date]}>
{moment(rowData.date).locale('pt-br').calendar()}
{moment(rowData.date).locale('pt-br').calendar()}
</Text>

@@ -88,7 +104,11 @@ );

<View >
{this.renderDate(rowData, rowID)}
<Msg item={rowData} styles={{ backgroundColor: '#f2f2f2'}} />
{this.renderDate(rowData, rowID)}
<Msg item={rowData} styles={{ backgroundColor: '#f2f2f2'}} />
</View>
)
}
addMsg(msg){
this.state.lista.push(msg);
this.setState({lista:this.state.lista,dataSource:this.state.dataSource.cloneWithRows(this.state.lista)});
}
enviarMsg(){

@@ -105,11 +125,19 @@ var msg = {

}
var lista = this.state.lista;
lista.push(msg);
this.setState({lista:lista,dataSource:this.state.dataSource.cloneWithRows(lista),text:""});
this.state.lista.push(msg);
this.setState({lista: this.state.lista ,dataSource:this.state.dataSource.cloneWithRows( this.state.lista ),text:""});
// this.listview.scrollTo({y: this.listview.scrollHeight});
// this.setState({text:""});
this.input.setNativeProps({
text: "",
});
this.scrollToBottom();
}
setMessageStatus(tag,rowID){
}
onKeyboardWillHide(e) {
this.scrollToBottom();
this.setState({paddingBottom:0});

@@ -119,2 +147,3 @@ }

onKeyboardWillShow(e) {
this.scrollToBottom();
var h_key = (e.endCoordinates ? e.endCoordinates.height : e.end.height);

@@ -128,2 +157,3 @@ if(!h_key || h_key < 10){

onKeyboardDidShow(e) {
this.scrollToBottom();
if(Platform.OS === 'ios') {

@@ -134,2 +164,3 @@ this.onKeyboardWillShow(e);

onKeyboardDidHide(e) {
this.scrollToBottom();
if(Platform.OS === 'ios') {

@@ -155,67 +186,82 @@ this.onKeyboardWillHide(e);

}
// alert(this.state.lista.length);
//value={this.state.text}
// initialListSize={10}
// pageSize={this.props.itens.length}
return (
<View style={container}>
<ListView
onKeyboardWillShow={(e)=>{
this.onKeyboardWillShow(e);
}}
onKeyboardDidShow={(e)=>{
this.onKeyboardWillShow(e);
}}
onKeyboardWillHide={(e)=>{
this.onKeyboardDidHide(e);
}}
onKeyboardDidHide={(e)=>{
this.onKeyboardDidHide(e);
}}
initialListSize={10}
pageSize={this.props.itens.length}
style={styles.listview}
enableEmptySections={true}
ref={(v)=>this.listview=v}
dataSource={this.state.dataSource}
renderRow={ (rowData , sectionID, rowID)=>this.row(rowData , sectionID, rowID) } >
</ListView>
<ListView
onLayout={(event) => {
var layout = event.nativeEvent.layout;
this.listHeight = layout.height;
}}
<View style={styles.textInputContainer}>
renderFooter={() => {
return (<View onLayout={(event)=>{
var layout = event.nativeEvent.layout;
this.footerY = layout.y;
this.scrollToBottom();
}}></View>)
}}
pageSize={this.state.lista.length}
onKeyboardWillShow={(e)=>{
this.onKeyboardWillShow(e);
}}
onKeyboardDidShow={(e)=>{
this.onKeyboardWillShow(e);
}}
onKeyboardWillHide={(e)=>{
this.onKeyboardDidHide(e);
}}
onKeyboardDidHide={(e)=>{
this.onKeyboardDidHide(e);
}}
<TextInput
style={styles.textInput}
placeholder={"Digite aqui..."}
ref='textInput'
onChangeText={(text)=>{
if(this.state.text.length=0 && text.length>1){
this.setState({text:text[text.length-1]});
return;
}
this.setState({text:text});
}}
value={this.state.text}
autoFocus={true}
returnKeyType={this.props.submitOnReturn ? 'send' : 'default'}
onSubmitEditing={()=>{
this.enviarMsg();
}}
style={styles.listview}
enableEmptySections={true}
ref={(v)=>this.listview=v}
dataSource={this.state.dataSource}
renderRow={ (rowData , sectionID, rowID)=>this.row(rowData , sectionID, rowID) } >
</ListView>
enablesReturnKeyAutomatically={true}
<View style={styles.textInputContainer}>
blurOnSubmit={false}
/>
<TextInput
style={styles.textInput}
placeholder={"Digite aqui..."}
ref={(v)=>this.input=v}
onChangeText={(text)=>{
// if(this.state.text.length=0 && text.length>1){
// this.setState({text:text[text.length-1]});
// return;
// }
this.setState({text:text});
}}
autoFocus={true}
returnKeyType={this.props.submitOnReturn ? 'send' : 'default'}
<TouchableOpacity style={styles.sendButton}
underlayColor ='rgba(220,220,220,1)' onPress = {()=>{
this.enviarMsg();
}} >
<Text style={styles.sendButtonText} >
{"Enviar"}
</Text>
</TouchableOpacity>
onSubmitEditing={()=>{
this.enviarMsg();
}}
enablesReturnKeyAutomatically={true}
blurOnSubmit={false}
/>
</View>
<TouchableOpacity style={styles.sendButton}
underlayColor ='rgba(220,220,220,1)' onPress = {()=>{
this.enviarMsg();
}} >
<Text style={styles.sendButtonText} >
{"Enviar"}
</Text>
</TouchableOpacity>
</View>
</View>

@@ -222,0 +268,0 @@ );

{
"name": "edi-chat",
"version": "0.0.33",
"version": "0.0.35",
"main": "index.js",

@@ -5,0 +5,0 @@ "scripts": {},

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc