page conversation fonctionnelle

messagerie_lucas_test
Lucas DELANIER 2 years ago
parent 84ad3100ee
commit 8c5bdfe940

@ -27,45 +27,51 @@ class _ConversationPageState extends State<ConversationPage> {
void SendMessage(String content){ void SendMessage(String content){
setState(() { setState(() {
messages.add(MessageWidget(Message(MyApp().controller.currentUser,content))); messages.add(MessageWidget(Message(MyApp().controller.currentUser,content)));
messages.add(MessageWidget(Message(destinataire,"reponse test gyegryzgrgz zyegruhzb hvhbzy vhu ry z yrzrv ze vhv hzvh z zv zz ev")));
}); });
} }
Widget MessageWidget(Message message) { Widget MessageWidget(Message message) {
if(message.sender != MyApp().controller.currentUser){ if(message.sender != MyApp().controller.currentUser){
return Container( return Align(
margin: EdgeInsets.fromLTRB(40, 7, 80, 7), alignment: Alignment.centerLeft,
decoration: BoxDecoration( child: Container(
borderRadius: BorderRadius.only( margin: EdgeInsets.fromLTRB(40, 7, 80, 7),
bottomRight: Radius.circular(20), decoration: BoxDecoration(
topLeft: Radius.circular(20), borderRadius: BorderRadius.only(
topRight: Radius.circular(20), bottomRight: Radius.circular(20),
bottomLeft: Radius.circular(20), topLeft: Radius.circular(20),
topRight: Radius.circular(20),
bottomLeft: Radius.circular(20),
),
border: Border.all(width: 1.5,
color: Color(0xFF9C9C9C).withOpacity(0.3)),
color: Color(0xFF191919),
), ),
border: Border.all(width: 1.5, child: Padding(
color: Color(0xFF9C9C9C).withOpacity(0.3)), padding: EdgeInsets.fromLTRB(15, 15, 15, 15),
color: Color(0xFF191919), child: Text(message.content,style: TextStyle(fontFamily: 'DMSans', color: Colors.white ,fontSize: 15, fontWeight: FontWeight.w400),
)),
), ),
child: Padding(
padding: EdgeInsets.fromLTRB(15, 15, 15, 15),
child: Text(message.content,style: TextStyle(fontFamily: 'DMSans', color: Colors.white ,fontSize: 15, fontWeight: FontWeight.w400),
)),
); );
} }
else{ else{
return Container( return Align(
margin: EdgeInsets.fromLTRB(80, 7, 40, 7), alignment: Alignment.centerRight,
decoration: BoxDecoration( child: Container(
borderRadius: BorderRadius.only( margin: EdgeInsets.fromLTRB(80, 7, 40, 7),
bottomRight: Radius.circular(20), decoration: BoxDecoration(
bottomLeft: Radius.circular(20), borderRadius: BorderRadius.only(
topLeft: Radius.circular(20), bottomRight: Radius.circular(20),
topRight: Radius.circular(20), bottomLeft: Radius.circular(20),
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
),
color: Color(0xFF2F2F2F),
), ),
color: Color(0xFF2F2F2F), child: Padding(
), padding: EdgeInsets.all(15),
child: Padding( child: Text(message.content,style: TextStyle(fontFamily: 'DMSans', color: Colors.white ,fontSize: 15, fontWeight: FontWeight.w400),),
padding: EdgeInsets.fromLTRB(15, 15, 15, 15), ),),
child: Text(message.content,style: TextStyle(fontFamily: 'DMSans', color: Colors.white ,fontSize: 15, fontWeight: FontWeight.w400),
)),
); );
} }
@ -84,6 +90,7 @@ class _ConversationPageState extends State<ConversationPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
double height = MediaQuery.of(context).size.height; double height = MediaQuery.of(context).size.height;
double width = MediaQuery.of(context).size.width; double width = MediaQuery.of(context).size.width;
ScrollController listScrollController = ScrollController();
return Scaffold( return Scaffold(
@ -127,6 +134,7 @@ class _ConversationPageState extends State<ConversationPage> {
], ],
),*/ ),*/
ListView.builder( ListView.builder(
controller: listScrollController,
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
itemCount: messages.length, itemCount: messages.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
@ -177,6 +185,11 @@ class _ConversationPageState extends State<ConversationPage> {
onTap: () { onTap: () {
SendMessage(messageTextField.text); SendMessage(messageTextField.text);
if (listScrollController.hasClients) {
final position = listScrollController.position.maxScrollExtent;
listScrollController.jumpTo(position+40);
}
messageTextField.clear();
}, },
child: Container( child: Container(

Loading…
Cancel
Save