-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Community section implemented with chat and video
- Loading branch information
1 parent
363839d
commit cc3baac
Showing
33 changed files
with
1,397 additions
and
238 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
import 'package:bubble/bubble.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_dialogflow/dialogflow_v2.dart'; | ||
import 'package:hackathon2/global.dart'; | ||
|
||
class MyApp extends StatefulWidget { | ||
final String drimag; | ||
|
||
const MyApp({Key key, this.drimag}) : super(key: key); | ||
|
||
@override | ||
_MyAppState createState() => _MyAppState(); | ||
} | ||
|
||
class _MyAppState extends State<MyApp> { | ||
void response(query) async { | ||
AuthGoogle authGoogle = | ||
await AuthGoogle(fileJson: "assets/pink-288804-5fbc02059449.json") | ||
.build(); | ||
Dialogflow dialogflow = | ||
Dialogflow(authGoogle: authGoogle, language: Language.english); | ||
AIResponse aiResponse = await dialogflow.detectIntent(query); | ||
setState(() { | ||
messsages.insert(0, { | ||
"data": 0, | ||
"message": aiResponse.getListMessage()[0]["text"]["text"][0].toString() | ||
}); | ||
}); | ||
} | ||
|
||
final messageInsert = TextEditingController(); | ||
List<Map> messsages = List(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
leading: IconButton( | ||
icon: Icon(Icons.arrow_back, color: Colors.black), | ||
onPressed: () { | ||
Navigator.pop(context); | ||
}), | ||
backgroundColor: Colors.white, | ||
elevation: 0, | ||
title: Center( | ||
child: Text( | ||
"CHAT", | ||
style: TextStyle( | ||
color: Colors.black, | ||
letterSpacing: 5, | ||
fontSize: 20, | ||
fontWeight: FontWeight.w400), | ||
), | ||
), | ||
), | ||
body: Container( | ||
child: Column( | ||
children: <Widget>[ | ||
Flexible( | ||
child: ListView.builder( | ||
reverse: true, | ||
itemCount: messsages.length, | ||
itemBuilder: (context, index) => chat( | ||
messsages[index]["message"].toString(), | ||
messsages[index]["data"]))), | ||
Divider( | ||
height: 5.0, | ||
color: Colors.deepOrange, | ||
), | ||
Container( | ||
padding: EdgeInsets.only(left: 15.0, right: 15.0), | ||
margin: const EdgeInsets.symmetric(horizontal: 8.0), | ||
child: Row( | ||
children: <Widget>[ | ||
Flexible( | ||
child: TextField( | ||
controller: messageInsert, | ||
decoration: InputDecoration.collapsed( | ||
hintText: "Send your message", | ||
hintStyle: TextStyle( | ||
fontWeight: FontWeight.bold, fontSize: 18.0)), | ||
)), | ||
Container( | ||
margin: EdgeInsets.symmetric(horizontal: 4.0), | ||
child: IconButton( | ||
icon: Icon( | ||
Icons.send, | ||
size: 30.0, | ||
color: Colors.black, | ||
), | ||
onPressed: () { | ||
if (messageInsert.text.isEmpty) { | ||
print("empty message"); | ||
} else { | ||
setState(() { | ||
messsages.insert(0, | ||
{"data": 1, "message": messageInsert.text}); | ||
}); | ||
response(messageInsert.text); | ||
messageInsert.clear(); | ||
} | ||
}), | ||
) | ||
], | ||
), | ||
), | ||
SizedBox( | ||
height: 15.0, | ||
) | ||
], | ||
), | ||
), | ||
); | ||
} | ||
|
||
//for better one i have use the bubble package check out the pubspec.yaml | ||
|
||
Widget chat(String message, int data) { | ||
return Padding( | ||
padding: EdgeInsets.all(10.0), | ||
child: Bubble( | ||
radius: Radius.circular(15.0), | ||
color: data == 0 ? Colors.pink[100] : Colors.pink[100], | ||
elevation: 0.0, | ||
alignment: data == 0 ? Alignment.topLeft : Alignment.topRight, | ||
nip: data == 0 ? BubbleNip.leftBottom : BubbleNip.rightTop, | ||
child: Padding( | ||
padding: EdgeInsets.all(2.0), | ||
child: Row( | ||
mainAxisSize: MainAxisSize.min, | ||
children: <Widget>[ | ||
CircleAvatar( | ||
backgroundImage: | ||
NetworkImage(data == 0 ? widget.drimag : globalimage), | ||
), | ||
SizedBox( | ||
width: 10.0, | ||
), | ||
Flexible( | ||
child: Text( | ||
message, | ||
style: TextStyle( | ||
color: Colors.white, fontWeight: FontWeight.bold), | ||
)) | ||
], | ||
), | ||
)), | ||
); | ||
} | ||
} |
Oops, something went wrong.