Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @override
- void initState() {
- super.initState();
- idroom = "${widget.idroom}";
- roomName = "${widget.namaroom}";
- tglroom = "${widget.tgl}";
- roomPass = "${widget.pass}";
- status_member = "${widget.status_member}";
- tipe = int.parse("${widget.tiperoom}");
- roomOpen = "${widget.roomOpen}" == "true" ? true : false;
- QuerySnapshot querySnapshot;
- MenuPage.status_member = status_member;
- getAllChatRoom().then((results) {
- showDialog(
- context: context,
- builder: (BuildContext context){
- return Center(
- child: CircularProgressIndicator(
- valueColor: AlwaysStoppedAnimation<Color>(Colors.black),
- strokeWidth: 5.0,
- backgroundColor: Colors.transparent,
- ),
- );
- }
- );
- setState(() {
- querySnapshot = results;
- urutan = querySnapshot.documents.length-1;
- for(var i = 0; i < querySnapshot.documents.length ; i++)
- {
- RoomChatPage message = new RoomChatPage(mode : querySnapshot.documents[i].data['mode'],text: querySnapshot.documents[i].data['message'], iduser : querySnapshot.documents[i].data['id'], username : querySnapshot.documents[i].data['name'], ppicture : querySnapshot.documents[i].data['ppicture'],idlagu : querySnapshot.documents[i].data['idlagu']);
- setState(() {
- _messages.insert(0, message);
- });
- }
- Navigator.of(context).pop();
- });
- });
- }
- getAllChatRoom() async {
- return await Firestore.instance
- .document('chat/' + idroom)
- .collection('messages').orderBy("urutan")
- .getDocuments();
- }
- void _handleSubmit(String text) {
- _chatController.clear();
- if(modeChat == "lagu")
- {
- idlagu = text.split("|")[0];
- text = text.split("|")[1];
- }
- else
- {
- idlagu = "";
- text = text;
- }
- RoomChatPage message = new RoomChatPage(mode:modeChat,text: text, iduser : LoginPage.iduser, username : LoginPage.username, ppicture : LoginPage.ppicture,idlagu:idlagu);
- setState(() {
- _messages.insert(0, message);
- Firestore.instance
- .document('chat/' + idroom)
- .collection('messages')
- .document()
- .setData({'mode': modeChat,'urutan':urutan,'id': LoginPage.iduser,'name': LoginPage.username, 'message': text, 'ppicture': LoginPage.ppicture, 'idlagu' : idlagu});
- });
- urutan++;
- }
- Widget _chatEnvironment() {
- return IconTheme(
- data: new IconThemeData(color: Colors.blue),
- child: new Container(
- child: new Row(
- children: <Widget>[
- new IconButton(
- icon: new Icon(
- Icons.queue_music,
- color: Colors.black,
- ),
- tooltip: 'Add Music to Chat',
- onPressed: (){
- showDialog(
- context: context,
- builder: (BuildContext context){
- return AlertDialog(
- contentPadding: MediaQuery.of(context).viewInsets,
- content: ListView(
- children: <Widget>[
- AppBar(
- automaticallyImplyLeading: false,
- backgroundColor: Colors.black,
- title: new Text("Find Music"),
- actions: <Widget>[
- new IconButton(
- onPressed: () {
- _showMaterialSearch(context);
- },
- tooltip: 'Search',
- icon: new Icon(Icons.search),
- ),
- ],
- ),
- SizedBox(
- height: MediaQuery.of(context).size.height,
- child:
- ListView.builder
- (
- itemCount: _musicData.length,
- itemBuilder: (BuildContext ctxt, int index) {
- return new ListTile(
- title:Row(
- children: <Widget>[
- Image(image: NetworkImage('http://groovey.xyz/music/'+_data["result"][index]["thumbnail_link"]),width: 60.0,),
- Expanded(
- child:
- new Container(
- child:Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Text(" "+_data["result"][index]["title"], style: TextStyle(fontSize:18.0),overflow: TextOverflow.ellipsis,),
- Text(" "+_data["result"][index]["artist"],style: TextStyle(fontSize:11.0), overflow: TextOverflow.ellipsis,),
- ]
- ),
- ),
- ),
- Icon(Icons.add)
- ],
- ),
- onTap: (){
- modeChat="lagu";
- String textLagu =_data["result"][index]["ID"]+"|"+ _data["result"][index]["title"]+"\n "+_data["result"][index]["artist"];
- _handleSubmit(textLagu);
- Navigator.pop(context);
- },
- );
- }
- ),
- ),
- ],
- ),
- );
- }
- );
- }
- ),
- new Flexible(
- child: new TextField(
- decoration:
- new InputDecoration.collapsed(hintText: "Start typing ..."),
- controller: _chatController,
- onSubmitted: _handleSubmit,
- ),
- ),
- new IconButton(
- icon: new Icon(
- Icons.send,
- color: Colors.black,
- ),
- onPressed: () {
- modeChat="biasa";
- _handleSubmit(_chatController.text);
- }
- ),
- ],
- ),
- ),
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement