@ -1,10 +1,8 @@
import ' package:flutter/material.dart ' ;
import ' package:flutter/material.dart ' ;
import ' package:dafl_project_flutter/main.dart ' ;
import ' package:dafl_project_flutter/main.dart ' ;
import ' package:dafl_project_flutter/model/user.dart ' ;
import ' package:dafl_project_flutter/model/user.dart ' ;
import ' package:dafl_project_flutter/views/pages/main/w_messages.dart ' ;
import ' package:flutter/cupertino.dart ' ;
import ' package:dafl_project_flutter/model/message.dart ' ;
import ' package:dafl_project_flutter/model/message.dart ' ;
import ' dart:developer ' as dev ;
class ConversationPage extends StatefulWidget {
class ConversationPage extends StatefulWidget {
const ConversationPage ( { Key ? key } ) : super ( key: key ) ;
const ConversationPage ( { Key ? key } ) : super ( key: key ) ;
@ -14,41 +12,41 @@ class ConversationPage extends StatefulWidget {
}
}
class _ConversationPageState extends State < ConversationPage > {
class _ConversationPageState extends State < ConversationPage > {
User destinataire = new User ( " test1 " , ' 1234 ' ) ;
User destinataire = User ( " test1 " , ' 1234 ' ) ;
List < Widget > messages = [ ] ;
List < Widget > messages = [ ] ;
bool isNull = true ;
bool isNull = true ;
final messageTextField = TextEditingController ( ) ;
final messageTextField = TextEditingController ( ) ;
void S endMessage( String content ) {
void s endMessage( String content ) {
setState ( ( ) {
setState ( ( ) {
messages
messages
. add ( M essageWidget( Message ( MyApp . controller . currentUser , content ) ) ) ;
. add ( m essageWidget( Message ( MyApp . controller . currentUser , content ) ) ) ;
} ) ;
} ) ;
}
}
Widget M essageWidget( Message message ) {
Widget m essageWidget( Message message ) {
if ( message . sender ! = MyApp . controller . currentUser ) {
if ( message . sender ! = MyApp . controller . currentUser ) {
return Align (
return Align (
alignment: Alignment . centerLeft ,
alignment: Alignment . centerLeft ,
child: Container (
child: Container (
margin: EdgeInsets . fromLTRB ( 40 , 7 , 80 , 7 ) ,
margin: const EdgeInsets . fromLTRB ( 40 , 7 , 80 , 7 ) ,
decoration: BoxDecoration (
decoration: BoxDecoration (
borderRadius: BorderRadius . only (
borderRadius: const BorderRadius . only (
bottomRight: Radius . circular ( 20 ) ,
bottomRight: Radius . circular ( 20 ) ,
topLeft: Radius . circular ( 20 ) ,
topLeft: Radius . circular ( 20 ) ,
topRight: Radius . circular ( 20 ) ,
topRight: Radius . circular ( 20 ) ,
bottomLeft: Radius . circular ( 20 ) ,
bottomLeft: Radius . circular ( 20 ) ,
) ,
) ,
border: Border . all (
border: Border . all (
width: 1.5 , color: Color ( 0xFF9C9C9C ) . withOpacity ( 0.3 ) ) ,
width: 1.5 , color: const Color ( 0xFF9C9C9C ) . withOpacity ( 0.3 ) ) ,
color: Color ( 0xFF191919 ) ,
color: const Color ( 0xFF191919 ) ,
) ,
) ,
child: Padding (
child: Padding (
padding: EdgeInsets . fromLTRB ( 15 , 15 , 15 , 15 ) ,
padding: const EdgeInsets . fromLTRB ( 15 , 15 , 15 , 15 ) ,
child: Text (
child: Text (
message . content ,
message . content ,
style: TextStyle (
style: const TextStyle (
fontFamily: ' DMSans ' ,
fontFamily: ' DMSans ' ,
color: Colors . white ,
color: Colors . white ,
fontSize: 15 ,
fontSize: 15 ,
@ -60,8 +58,8 @@ class _ConversationPageState extends State<ConversationPage> {
return Align (
return Align (
alignment: Alignment . centerRight ,
alignment: Alignment . centerRight ,
child: Container (
child: Container (
margin: EdgeInsets . fromLTRB ( 80 , 7 , 40 , 7 ) ,
margin: const EdgeInsets . fromLTRB ( 80 , 7 , 40 , 7 ) ,
decoration: BoxDecoration (
decoration: const BoxDecoration (
borderRadius: BorderRadius . only (
borderRadius: BorderRadius . only (
bottomRight: Radius . circular ( 20 ) ,
bottomRight: Radius . circular ( 20 ) ,
bottomLeft: Radius . circular ( 20 ) ,
bottomLeft: Radius . circular ( 20 ) ,
@ -71,10 +69,10 @@ class _ConversationPageState extends State<ConversationPage> {
color: Color ( 0xFF2F2F2F ) ,
color: Color ( 0xFF2F2F2F ) ,
) ,
) ,
child: Padding (
child: Padding (
padding: EdgeInsets . all ( 15 ) ,
padding: const EdgeInsets . all ( 15 ) ,
child: Text (
child: Text (
message . content ,
message . content ,
style: TextStyle (
style: const TextStyle (
fontFamily: ' DMSans ' ,
fontFamily: ' DMSans ' ,
color: Colors . white ,
color: Colors . white ,
fontSize: 15 ,
fontSize: 15 ,
@ -90,7 +88,7 @@ class _ConversationPageState extends State<ConversationPage> {
void initState ( ) {
void initState ( ) {
super . initState ( ) ;
super . initState ( ) ;
messageTextField . addListener ( _checkIfNull ) ;
messageTextField . addListener ( _checkIfNull ) ;
print ( " INITSATE " ) ;
dev. log ( " INITSATE " ) ;
}
}
@ override
@ override
@ -100,7 +98,7 @@ class _ConversationPageState extends State<ConversationPage> {
}
}
void _checkIfNull ( ) {
void _checkIfNull ( ) {
if ( messageTextField . text . length > 0 ) {
if ( messageTextField . text . isNotEmpty ) {
setState ( ( ) {
setState ( ( ) {
isNull = false ;
isNull = false ;
} ) ;
} ) ;
@ -122,67 +120,65 @@ class _ConversationPageState extends State<ConversationPage> {
resizeToAvoidBottomInset: true ,
resizeToAvoidBottomInset: true ,
appBar: AppBar (
appBar: AppBar (
elevation: 20 ,
elevation: 20 ,
backgroundColor: Color ( 0xFF141414 ) ,
backgroundColor: const Color ( 0xFF141414 ) ,
toolbarHeight: 70 ,
toolbarHeight: 70 ,
title: Container (
title: Row (
child: Row (
children: [
children: [
Container (
Container (
padding: const EdgeInsets . fromLTRB ( 0 , 10 , 0 , 0 ) ,
padding: EdgeInsets . fromLTRB ( 0 , 10 , 0 , 0 ) ,
height: 40 ,
height: 40 ,
width: 40 ,
width: 40 ,
decoration: BoxDecoration (
decoration: BoxDecoration (
borderRadius: BorderRadius . circular ( 40 ) ,
borderRadius: BorderRadius . circular ( 40 ) ,
color: Colors . blue ,
color: Colors . blue ,
) ,
) ,
SizedBox (
width: 20 ,
) ,
) ,
Text ( " Max " ) ,
) ,
Spacer ( ) ,
const SizedBox (
IconButton (
width: 20 ,
splashColor: Colors . grey . withOpacity ( 0.2 ) ,
) ,
splashRadius: 30 ,
const Text ( " Max " ) ,
onPressed: ( ) {
const Spacer ( ) ,
showModalBottomSheet (
IconButton (
isDismissible: true ,
splashColor: Colors . grey . withOpacity ( 0.2 ) ,
useRootNavigator: true ,
splashRadius: 30 ,
isScrollControlled: true ,
onPressed: ( ) {
backgroundColor: Colors . transparent ,
showModalBottomSheet (
context: context ,
isDismissible: true ,
constraints: BoxConstraints (
useRootNavigator: true ,
maxWidth: 600 ,
isScrollControlled: true ,
maxHeight: double . infinity ,
backgroundColor: Colors . transparent ,
) ,
context: context ,
builder: ( context ) = > buildSheet ( ) ,
constraints: const BoxConstraints (
) ;
maxWidth: 600 ,
} ,
maxHeight: double . infinity ,
icon: Icon (
) ,
Icons . report_problem ,
builder: ( context ) = > buildSheet ( ) ,
color: Colors . grey . withOpacity ( 0.3 ) ,
) ;
size: 25 ,
} ,
) ,
icon: Icon (
Icons . report_problem ,
color: Colors . grey . withOpacity ( 0.3 ) ,
size: 25 ,
) ,
) ,
] ,
) ,
) ,
] ,
) ,
) ,
) ,
) ,
body: SingleChildScrollView (
body: SingleChildScrollView (
child: Container (
child: Container (
color: Color ( 0xFF141414 ) ,
color: const Color ( 0xFF141414 ) ,
height: height * 0.92 ,
height: height * 0.92 ,
width: double . infinity ,
width: double . infinity ,
child: ListView . builder (
child: ListView . builder (
controller: listScrollController ,
controller: listScrollController ,
physics: BouncingScrollPhysics ( ) ,
physics: const BouncingScrollPhysics ( ) ,
itemCount: messages . length ,
itemCount: messages . length ,
itemBuilder: ( context , index ) {
itemBuilder: ( context , index ) {
return messages [ index ] ;
return messages [ index ] ;
} ) ) ,
} ) ) ,
) ,
) ,
bottomSheet: BottomAppBar (
bottomSheet: BottomAppBar (
color: Color ( 0xFF141414 ) ,
color: const Color ( 0xFF141414 ) ,
child: Row (
child: Row (
mainAxisAlignment: MainAxisAlignment . center ,
mainAxisAlignment: MainAxisAlignment . center ,
crossAxisAlignment: CrossAxisAlignment . center ,
crossAxisAlignment: CrossAxisAlignment . center ,
@ -192,20 +188,20 @@ class _ConversationPageState extends State<ConversationPage> {
color: Colors . transparent ,
color: Colors . transparent ,
width: width * 0.9 ,
width: width * 0.9 ,
child: Container (
child: Container (
margin: EdgeInsets . fromLTRB ( 10 , 10 , 10 , 10 ) ,
margin: const EdgeInsets . fromLTRB ( 10 , 10 , 10 , 10 ) ,
decoration: BoxDecoration (
decoration: BoxDecoration (
border: Border . all (
border: Border . all (
width: 1 ,
width: 1 ,
color: Color ( 0xFF2F2F2F ) ,
color: const Color ( 0xFF2F2F2F ) ,
) ,
) ,
borderRadius: BorderRadius . circular ( 100 ) ,
borderRadius: BorderRadius . circular ( 100 ) ,
color: Color ( 0xFF141414 ) ,
color: const Color ( 0xFF141414 ) ,
) ,
) ,
child: Padding (
child: Padding (
padding: EdgeInsets . fromLTRB ( 15 , 0 , 15 , 0 ) ,
padding: const EdgeInsets . fromLTRB ( 15 , 0 , 15 , 0 ) ,
child: TextField (
child: TextField (
controller: messageTextField ,
controller: messageTextField ,
style: TextStyle ( color: Colors . white ) ,
style: const TextStyle ( color: Colors . white ) ,
decoration: InputDecoration (
decoration: InputDecoration (
hintStyle:
hintStyle:
TextStyle ( color: Colors . white . withOpacity ( 0.7 ) ) ,
TextStyle ( color: Colors . white . withOpacity ( 0.7 ) ) ,
@ -222,7 +218,7 @@ class _ConversationPageState extends State<ConversationPage> {
onTap: isNull
onTap: isNull
? null
? null
: ( ) {
: ( ) {
S endMessage( messageTextField . text ) ;
s endMessage( messageTextField . text ) ;
if ( listScrollController . hasClients ) {
if ( listScrollController . hasClients ) {
final position =
final position =
listScrollController . position . maxScrollExtent ;
listScrollController . position . maxScrollExtent ;
@ -231,24 +227,24 @@ class _ConversationPageState extends State<ConversationPage> {
messageTextField . clear ( ) ;
messageTextField . clear ( ) ;
} ,
} ,
child: isNull = = true
child: isNull = = true
? Container (
? const SizedBox (
height: 1 ,
height: 1 ,
width: 1 ,
width: 1 ,
)
)
: Container (
: Container (
width: 40 ,
width: 40 ,
height: 40 ,
height: 40 ,
margin: EdgeInsets . fromLTRB ( 0 , 0 , 0 , 0 ) ,
margin: const EdgeInsets . fromLTRB ( 0 , 0 , 0 , 0 ) ,
decoration: BoxDecoration (
decoration: BoxDecoration (
borderRadius: BorderRadius . circular ( 100 ) ,
borderRadius: BorderRadius . circular ( 100 ) ,
gradient: LinearGradient (
gradient: const LinearGradient (
colors: [ Color ( 0xff8e24a1 ) , Color ( 0xff8163ff ) ] ,
colors: [ Color ( 0xff8e24a1 ) , Color ( 0xff8163ff ) ] ,
begin: Alignment . topLeft ,
begin: Alignment . topLeft ,
end: Alignment . bottomRight ,
end: Alignment . bottomRight ,
) ) ,
) ) ,
child: Transform . rotate (
child: Transform . rotate (
angle: - 300 ,
angle: - 300 ,
child: Icon (
child: const Icon (
Icons . arrow_back ,
Icons . arrow_back ,
size: 26 ,
size: 26 ,
color: Colors . white ,
color: Colors . white ,
@ -262,8 +258,6 @@ class _ConversationPageState extends State<ConversationPage> {
}
}
Widget buildSheet ( ) {
Widget buildSheet ( ) {
String dropdownValue = list . first ;
final messageTextField = TextEditingController ( ) ;
return SingleChildScrollView (
return SingleChildScrollView (
padding:
padding:
EdgeInsets . only ( bottom: MediaQuery . of ( context ) . viewInsets . bottom ) ,
EdgeInsets . only ( bottom: MediaQuery . of ( context ) . viewInsets . bottom ) ,
@ -288,14 +282,14 @@ class _ConversationPageState extends State<ConversationPage> {
spreadRadius: 0.0 ,
spreadRadius: 0.0 ,
) , / / BoxShadow / / BoxShadow
) , / / BoxShadow / / BoxShadow
] ,
] ,
color: Color ( 0xFF232123 ) ,
color: const Color ( 0xFF232123 ) ,
borderRadius: BorderRadius . only (
borderRadius: const BorderRadius . only (
topRight: Radius . circular ( 30 ) ,
topRight: Radius . circular ( 30 ) ,
topLeft: Radius . circular ( 30 ) ,
topLeft: Radius . circular ( 30 ) ,
) ,
) ,
) ,
) ,
child: Padding (
child: Padding (
padding: EdgeInsets . fromLTRB ( 20 , 10 , 20 , 10 ) ,
padding: const EdgeInsets . fromLTRB ( 20 , 10 , 20 , 10 ) ,
child: Column (
child: Column (
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
children: [
@ -304,10 +298,10 @@ class _ConversationPageState extends State<ConversationPage> {
width: 130 ,
width: 130 ,
decoration: BoxDecoration (
decoration: BoxDecoration (
borderRadius: BorderRadius . circular ( 20 ) ,
borderRadius: BorderRadius . circular ( 20 ) ,
color: Color ( 0xFF8A8A8A ) ,
color: const Color ( 0xFF8A8A8A ) ,
) ,
) ,
) ,
) ,
Padding (
const Padding (
padding: EdgeInsets . fromLTRB ( 0 , 20 , 0 , 20 ) ,
padding: EdgeInsets . fromLTRB ( 0 , 20 , 0 , 20 ) ,
child: Text (
child: Text (
' Signaler ' ,
' Signaler ' ,
@ -318,14 +312,14 @@ class _ConversationPageState extends State<ConversationPage> {
) ,
) ,
) ,
) ,
Container (
Container (
padding: EdgeInsets . fromLTRB ( 20 , 10 , 20 , 10 ) ,
padding: const EdgeInsets . fromLTRB ( 20 , 10 , 20 , 10 ) ,
width: double . infinity ,
width: double . infinity ,
decoration: BoxDecoration (
decoration: BoxDecoration (
color: Colors . grey . shade900 ,
color: Colors . grey . shade900 ,
borderRadius: BorderRadius . circular ( 15 ) ,
borderRadius: BorderRadius . circular ( 15 ) ,
) ,
) ,
child: Column (
child: Column (
children: [
children: const [
Text (
Text (
' Vous êtes sur le point de signaler cet utilisateur. Veuillez renseigner le motif du signalement. ' ,
' Vous êtes sur le point de signaler cet utilisateur. Veuillez renseigner le motif du signalement. ' ,
style: TextStyle ( color: Colors . grey ) ,
style: TextStyle ( color: Colors . grey ) ,
@ -339,11 +333,11 @@ class _ConversationPageState extends State<ConversationPage> {
) ,
) ,
) ,
) ,
Padding (
Padding (
padding: EdgeInsets . fromLTRB ( 0 , 20 , 0 , 20 ) ,
padding: const EdgeInsets . fromLTRB ( 0 , 20 , 0 , 20 ) ,
child: Column (
child: Column (
children: [
children: [
Container (
Container (
padding: EdgeInsets . fromLTRB ( 20 , 10 , 20 , 10 ) ,
padding: const EdgeInsets . fromLTRB ( 20 , 10 , 20 , 10 ) ,
width: double . infinity ,
width: double . infinity ,
decoration: BoxDecoration (
decoration: BoxDecoration (
color: Colors . grey . withOpacity ( 0.07 ) ,
color: Colors . grey . withOpacity ( 0.07 ) ,
@ -359,7 +353,7 @@ class _ConversationPageState extends State<ConversationPage> {
fontWeight: FontWeight . w200 ) ,
fontWeight: FontWeight . w200 ) ,
maxLines: 3 ,
maxLines: 3 ,
textInputAction: TextInputAction . done ,
textInputAction: TextInputAction . done ,
decoration: InputDecoration (
decoration: const InputDecoration (
hintText: ' * Commentaires ' ,
hintText: ' * Commentaires ' ,
hintStyle: TextStyle (
hintStyle: TextStyle (
fontSize: 15 ,
fontSize: 15 ,
@ -371,18 +365,18 @@ class _ConversationPageState extends State<ConversationPage> {
) ,
) ,
] ,
] ,
) ) ,
) ) ,
Spacer ( ) ,
const Spacer ( ) ,
Padding (
Padding (
padding: EdgeInsets . fromLTRB ( 0 , 0 , 0 , 50 ) ,
padding: const EdgeInsets . fromLTRB ( 0 , 0 , 0 , 50 ) ,
child: SizedBox (
child: SizedBox (
width: double . infinity ,
width: double . infinity ,
height: 70 ,
height: 70 ,
child: ElevatedButton (
child: ElevatedButton (
onPressed: ( ) { } ,
onPressed: ( ) { } ,
style: ElevatedButton . styleFrom (
style: ElevatedButton . styleFrom (
primary : Colors . red ,
backgroundColor : Colors . red ,
textStyle:
textStyle: const TextStyle (
TextStyle ( fontSize: 20 , fontWeight: FontWeight . bold ) ,
fontSize: 20 , fontWeight: FontWeight . bold ) ,
shape: RoundedRectangleBorder (
shape: RoundedRectangleBorder (
borderRadius: BorderRadius . circular ( 17 ) ) ,
borderRadius: BorderRadius . circular ( 17 ) ) ,
) ,
) ,
@ -396,7 +390,7 @@ class _ConversationPageState extends State<ConversationPage> {
size: 100 ,
size: 100 ,
color: Colors . white . withOpacity ( 0.2 ) ,
color: Colors . white . withOpacity ( 0.2 ) ,
) ) ,
) ) ,
Center (
const Center (
child: Text ( " Envoyer le signalement " ) ,
child: Text ( " Envoyer le signalement " ) ,
) ,
) ,
] ,
] ,