This file contains hidden or 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
| void onSendMessage(String content, int type) { | |
| // type: 0 = text, 1 = image, 2 = sticker | |
| if (content.trim() != '') { | |
| textEditingController.clear(); | |
| var documentReference = Firestore.instance | |
| .collection('messages') | |
| .document(groupChatId) | |
| .collection(groupChatId) | |
| .document(DateTime.now().millisecondsSinceEpoch.toString()); |
This file contains hidden or 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
| document['type'] == 0 | |
| // Text | |
| ? Container( | |
| child: Text( | |
| document['content'], | |
| style: TextStyle(color: primaryColor), | |
| ), | |
| padding: EdgeInsets.fromLTRB(15.0, 10.0, 15.0, 10.0), | |
| width: 200.0, | |
| decoration: BoxDecoration(color: greyColor2, borderRadius: BorderRadius.circular(8.0)), |
This file contains hidden or 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
| if (currentId.hashCode <= peerId.hashCode) { | |
| groupChatId = '$currentId-$peerId'; | |
| } else { | |
| groupChatId = '$peerId-$currentId'; | |
| } |
This file contains hidden or 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) { | |
| super(props) | |
| this.state = { | |
| isKeyboardShow: false, | |
| keyboardHeight: 0, | |
| } | |
| } | |
| componentWillMount() { | |
| this.keyboardDidShowListener = Keyboard.addListener( |
This file contains hidden or 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 firebase from 'firebase' | |
| const config = { | |
| apiKey: 'AIzaSyAC9ZSyvTxU2o5W0jcL0hDvzS4utLuicE8', | |
| authDomain: 'flutterchatdemo.firebaseapp.com', | |
| databaseURL: 'https://flutterchatdemo.firebaseio.com', | |
| projectId: 'flutterchatdemo', | |
| storageBucket: 'flutterchatdemo.appspot.com', | |
| messagingSenderId: '347976604232' | |
| } |
This file contains hidden or 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() { | |
| return ( | |
| <BrowserRouter> | |
| <div> | |
| <ToastContainer | |
| autoClose={2000} | |
| hideProgressBar={true} | |
| position={toast.POSITION.BOTTOM_RIGHT} | |
| /> | |
| <Switch> |
This file contains hidden or 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
| myFirebase | |
| .auth() | |
| .signInWithPopup(new firebase.auth.GoogleAuthProvider()) | |
| .then(async result => {}) | |
| .catch(err => {}) |
This file contains hidden or 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
| componentDidMount() { | |
| this.checkLogin() | |
| } | |
| checkLogin = () => { | |
| if (!localStorage.getItem(AppString.ID)) { | |
| this.setState({ | |
| isLoading: false | |
| }, () => { | |
| this.props.history.push('/') |
This file contains hidden or 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
| renderListUser = () => { | |
| if (this.listUser.length > 0) { | |
| let viewListUser = [] | |
| this.listUser.forEach((item, index) => { | |
| if (item.data().id !== this.currentUserId) { | |
| viewListUser.push( | |
| <button | |
| key={index} | |
| className={ | |
| this.state.currentPeerUser && |
This file contains hidden or 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
| getListHistory = () => { | |
| if (this.removeListener) { | |
| this.removeListener() | |
| } | |
| this.listMessage.length = 0 | |
| this.setState({ | |
| isLoading: true | |
| }) | |
| if ( | |
| this.hashString(this.currentUserId) <= |