@ -6,7 +6,6 @@ import 'package:flutter/cupertino.dart';
import ' package:dafl_project_flutter/model/message.dart ' ;
class ConversationPage extends StatefulWidget {
const ConversationPage ( { Key ? key } ) : super ( key: key ) ;
@ -15,22 +14,21 @@ class ConversationPage extends StatefulWidget {
}
class _ConversationPageState extends State < ConversationPage > {
User destinataire = new User ( " test1 " , ' 1234 ' ) ;
List < Widget > messages = [ ] ;
List < Widget > messages = [ ] ;
bool isNull = true ;
final messageTextField = TextEditingController ( ) ;
void SendMessage ( String content ) {
void SendMessage ( String content ) {
setState ( ( ) {
messages . add ( MessageWidget ( Message ( MyApp ( ) . controller . currentUser , content ) ) ) ;
messages
. add ( MessageWidget ( Message ( MyApp . controller . currentUser , content ) ) ) ;
} ) ;
}
Widget MessageWidget ( Message message ) {
if ( message . sender ! = MyApp () .controller . currentUser ) {
if ( message . sender ! = MyApp .controller . currentUser ) {
return Align (
alignment: Alignment . centerLeft ,
child: Container (
@ -42,18 +40,23 @@ class _ConversationPageState extends State<ConversationPage> {
topRight: Radius . circular ( 20 ) ,
bottomLeft: Radius . circular ( 20 ) ,
) ,
border: Border . all ( width: 1.5 ,
color: Color ( 0xFF9C9C9C ) . withOpacity ( 0.3 ) ) ,
border: Border . all (
width: 1.5 , color: Color ( 0xFF9C9C9C ) . withOpacity ( 0.3 ) ) ,
color: Color ( 0xFF191919 ) ,
) ,
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 ) ,
child: Text (
message . content ,
style: TextStyle (
fontFamily: ' DMSans ' ,
color: Colors . white ,
fontSize: 15 ,
fontWeight: FontWeight . w400 ) ,
) ) ,
) ,
) ;
}
else {
} else {
return Align (
alignment: Alignment . centerRight ,
child: Container (
@ -69,17 +72,22 @@ class _ConversationPageState extends State<ConversationPage> {
) ,
child: Padding (
padding: EdgeInsets . all ( 15 ) ,
child: Text ( message . content , style: TextStyle ( fontFamily: ' DMSans ' , color: Colors . white , fontSize: 15 , fontWeight: FontWeight . w400 ) , ) ,
) , ) ,
child: Text (
message . content ,
style: TextStyle (
fontFamily: ' DMSans ' ,
color: Colors . white ,
fontSize: 15 ,
fontWeight: FontWeight . w400 ) ,
) ,
) ,
) ,
) ;
}
}
@ override
void initState ( ) {
super . initState ( ) ;
messageTextField . addListener ( _checkIfNull ) ;
print ( " INITSATE " ) ;
@ -91,13 +99,12 @@ class _ConversationPageState extends State<ConversationPage> {
super . dispose ( ) ;
}
void _checkIfNull ( ) {
if ( messageTextField . text . length > 0 ) {
void _checkIfNull ( ) {
if ( messageTextField . text . length > 0 ) {
setState ( ( ) {
isNull = false ;
} ) ;
}
else {
} else {
setState ( ( ) {
isNull = true ;
} ) ;
@ -110,7 +117,6 @@ class _ConversationPageState extends State<ConversationPage> {
double width = MediaQuery . of ( context ) . size . width ;
ScrollController listScrollController = ScrollController ( ) ;
return Scaffold (
extendBodyBehindAppBar: true ,
resizeToAvoidBottomInset: true ,
@ -130,12 +136,14 @@ class _ConversationPageState extends State<ConversationPage> {
color: Colors . blue ,
) ,
) ,
SizedBox ( width: 20 , ) ,
SizedBox (
width: 20 ,
) ,
Text ( " Max " ) ,
Spacer ( ) ,
IconButton (
splashColor: Colors . grey . withOpacity ( 0.2 ) ,
splashRadius: 30 ,
IconButton (
splashColor: Colors . grey . withOpacity ( 0.2 ) ,
splashRadius: 30 ,
onPressed: ( ) {
showModalBottomSheet (
isDismissible: true ,
@ -144,34 +152,34 @@ class _ConversationPageState extends State<ConversationPage> {
backgroundColor: Colors . transparent ,
context: context ,
constraints: BoxConstraints (
maxWidth: 600 ,
maxWidth: 600 ,
maxHeight: double . infinity ,
) ,
builder: ( context ) = > buildSheet ( ) , ) ;
builder: ( context ) = > buildSheet ( ) ,
) ;
} ,
icon: Icon ( Icons . report_problem , color: Colors . grey . withOpacity ( 0.3 ) , size: 25 , ) ,
icon: Icon (
Icons . report_problem ,
color: Colors . grey . withOpacity ( 0.3 ) ,
size: 25 ,
) ,
) ,
] ,
) ,
) ,
) ,
body: SingleChildScrollView (
child:
Container (
color: Color ( 0xFF141414 ) ,
height: height * 0.92 ,
width: double . infinity ,
child: ListView . builder (
child: Container (
color: Color ( 0xFF141414 ) ,
height: height * 0.92 ,
width: double . infinity ,
child: ListView . builder (
controller: listScrollController ,
physics: BouncingScrollPhysics ( ) ,
itemCount: messages . length ,
itemBuilder: ( context , index ) {
return messages [ index ] ;
} )
) ,
physics: BouncingScrollPhysics ( ) ,
itemCount: messages . length ,
itemBuilder: ( context , index ) {
return messages [ index ] ;
} ) ) ,
) ,
bottomSheet: BottomAppBar (
color: Color ( 0xFF141414 ) ,
@ -180,9 +188,9 @@ class _ConversationPageState extends State<ConversationPage> {
crossAxisAlignment: CrossAxisAlignment . center ,
children: [
Container (
height: height * 0.08 ,
height: height * 0.08 ,
color: Colors . transparent ,
width: width * 0.9 ,
width: width * 0.9 ,
child: Container (
margin: EdgeInsets . fromLTRB ( 10 , 10 , 10 , 10 ) ,
decoration: BoxDecoration (
@ -192,7 +200,6 @@ class _ConversationPageState extends State<ConversationPage> {
) ,
borderRadius: BorderRadius . circular ( 100 ) ,
color: Color ( 0xFF141414 ) ,
) ,
child: Padding (
padding: EdgeInsets . fromLTRB ( 15 , 0 , 15 , 0 ) ,
@ -200,9 +207,10 @@ class _ConversationPageState extends State<ConversationPage> {
controller: messageTextField ,
style: TextStyle ( color: Colors . white ) ,
decoration: InputDecoration (
hintStyle: TextStyle ( color: Colors . white . withOpacity ( 0.7 ) ) ,
border: InputBorder . none ,
hintText: " Votre message... " ,
hintStyle:
TextStyle ( color: Colors . white . withOpacity ( 0.7 ) ) ,
border: InputBorder . none ,
hintText: " Votre message... " ,
) ,
cursorColor: Colors . purple ,
textAlign: TextAlign . left ,
@ -211,58 +219,55 @@ class _ConversationPageState extends State<ConversationPage> {
) ,
) ,
GestureDetector (
onTap: isNull ?
null :
( ) {
SendMessage ( messageTextField . text ) ;
if ( listScrollController . hasClients ) {
final position = listScrollController . position . maxScrollExtent ;
listScrollController . jumpTo ( position ) ;
}
messageTextField . clear ( ) ;
} ,
child: isNull = = true ?
Container (
height: 1 ,
width: 1 ,
) :
Container (
width: 40 ,
height: 40 ,
margin: EdgeInsets . fromLTRB ( 0 , 0 , 0 , 0 ) ,
decoration: BoxDecoration (
borderRadius: BorderRadius . circular ( 100 ) ,
gradient: LinearGradient (
colors: [ Color ( 0xff8e24a1 ) , Color ( 0xff8163ff ) ] ,
begin: Alignment . topLeft ,
end: Alignment . bottomRight ,
)
) ,
child: Transform . rotate ( angle: - 300 ,
child: Icon ( Icons . arrow_back , size: 26 , color: Colors . white , ) , )
) ,
onTap: isNull
? null
: ( ) {
SendMessage ( messageTextField . text ) ;
if ( listScrollController . hasClients ) {
final position =
listScrollController . position . maxScrollExtent ;
listScrollController . jumpTo ( position ) ;
}
messageTextField . clear ( ) ;
} ,
child: isNull = = true
? Container (
height: 1 ,
width: 1 ,
)
: Container (
width: 40 ,
height: 40 ,
margin: EdgeInsets . fromLTRB ( 0 , 0 , 0 , 0 ) ,
decoration: BoxDecoration (
borderRadius: BorderRadius . circular ( 100 ) ,
gradient: LinearGradient (
colors: [ Color ( 0xff8e24a1 ) , Color ( 0xff8163ff ) ] ,
begin: Alignment . topLeft ,
end: Alignment . bottomRight ,
) ) ,
child: Transform . rotate (
angle: - 300 ,
child: Icon (
Icons . arrow_back ,
size: 26 ,
color: Colors . white ,
) ,
) ) ,
)
] ,
) ,
) ,
) ;
}
Widget buildSheet ( ) {
Widget buildSheet ( ) {
String dropdownValue = list . first ;
final messageTextField = TextEditingController ( ) ;
return SingleChildScrollView (
padding:
EdgeInsets . only ( bottom: MediaQuery . of ( context ) . viewInsets . bottom ) ,
child: Container (
EdgeInsets . only ( bottom: MediaQuery . of ( context ) . viewInsets . bottom ) ,
child: Container (
height: 500 ,
width: double . infinity ,
decoration: BoxDecoration (
@ -281,7 +286,7 @@ class _ConversationPageState extends State<ConversationPage> {
offset: const Offset ( 0.0 , 0.0 ) ,
blurRadius: 0.0 ,
spreadRadius: 0.0 ,
) , / / BoxShadow / / BoxShadow
) , / / BoxShadow / / BoxShadow
] ,
color: Color ( 0xFF232123 ) ,
borderRadius: BorderRadius . only (
@ -294,7 +299,6 @@ class _ConversationPageState extends State<ConversationPage> {
child: Column (
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
Container (
height: 5 ,
width: 130 ,
@ -303,8 +307,16 @@ class _ConversationPageState extends State<ConversationPage> {
color: Color ( 0xFF8A8A8A ) ,
) ,
) ,
Padding ( padding: EdgeInsets . fromLTRB ( 0 , 20 , 0 , 20 ) ,
child: Text ( ' Signaler ' , style: TextStyle ( color: Colors . white , fontSize: 20 , fontWeight: FontWeight . w500 ) , ) , ) ,
Padding (
padding: EdgeInsets . fromLTRB ( 0 , 20 , 0 , 20 ) ,
child: Text (
' Signaler ' ,
style: TextStyle (
color: Colors . white ,
fontSize: 20 ,
fontWeight: FontWeight . w500 ) ,
) ,
) ,
Container (
padding: EdgeInsets . fromLTRB ( 20 , 10 , 20 , 10 ) ,
width: double . infinity ,
@ -314,12 +326,20 @@ class _ConversationPageState extends State<ConversationPage> {
) ,
child: Column (
children: [
Text ( ' Vous êtes sur le point de signaler cet utilisateur. Veuillez renseigner le motif du signalement. ' , style: TextStyle ( color: Colors . grey ) , textAlign: TextAlign . center , ) ,
Padding ( padding: EdgeInsets . fromLTRB ( 0 , 20 , 0 , 10 ) ,
child: DropdownButtonReason ( ) , ) ,
Text (
' Vous êtes sur le point de signaler cet utilisateur. Veuillez renseigner le motif du signalement. ' ,
style: TextStyle ( color: Colors . grey ) ,
textAlign: TextAlign . center ,
) ,
Padding (
padding: EdgeInsets . fromLTRB ( 0 , 20 , 0 , 10 ) ,
child: DropdownButtonReason ( ) ,
) ,
] ,
) , ) ,
Padding ( padding: EdgeInsets . fromLTRB ( 0 , 20 , 0 , 20 ) ,
) ,
) ,
Padding (
padding: EdgeInsets . fromLTRB ( 0 , 20 , 0 , 20 ) ,
child: Column (
children: [
Container (
@ -331,9 +351,12 @@ class _ConversationPageState extends State<ConversationPage> {
) ,
child: TextField (
keyboardAppearance: Brightness . dark ,
onTap: ( ) {
} ,
style: TextStyle ( fontFamily: ' DMSans ' , color: Colors . white . withOpacity ( 1 ) , fontSize: 17 , fontWeight: FontWeight . w200 ) ,
onTap: ( ) { } ,
style: TextStyle (
fontFamily: ' DMSans ' ,
color: Colors . white . withOpacity ( 1 ) ,
fontSize: 17 ,
fontWeight: FontWeight . w200 ) ,
maxLines: 3 ,
textInputAction: TextInputAction . done ,
decoration: InputDecoration (
@ -344,44 +367,49 @@ class _ConversationPageState extends State<ConversationPage> {
) ,
border: InputBorder . none ,
) ,
) , ) ,
) ,
) ,
] ,
) ) ,
Spacer ( ) ,
Padding ( padding: EdgeInsets . fromLTRB ( 0 , 0 , 0 , 50 ) ,
Padding (
padding: EdgeInsets . fromLTRB ( 0 , 0 , 0 , 50 ) ,
child: SizedBox (
width: double . infinity ,
height: 70 ,
child: ElevatedButton (
onPressed: ( ) {
} ,
onPressed: ( ) { } ,
style: ElevatedButton . styleFrom (
primary: Colors . red ,
textStyle: TextStyle (
fontSize: 20 ,
fontWeight: FontWeight . bold ) ,
textStyle:
TextStyle ( fontSize: 20 , fontWeight: FontWeight . bold ) ,
shape: RoundedRectangleBorder (
borderRadius: BorderRadius . circular ( 17 )
) ,
borderRadius: BorderRadius . circular ( 17 ) ) ,
) ,
child: Stack (
children: [
Positioned (
top: - 10 ,
right: 0 ,
child: Icon ( Icons . report , size: 100 , color: Colors . white . withOpacity ( 0.2 ) , ) ) ,
Center ( child: Text ( " Envoyer le signalement " ) , ) ,
child: Icon (
Icons . report ,
size: 100 ,
color: Colors . white . withOpacity ( 0.2 ) ,
) ) ,
Center (
child: Text ( " Envoyer le signalement " ) ,
) ,
] ,
) ,
) ,
) , ) ,
) ,
) ,
] ,
) ,
) ,
) , ) ;
}
) ,
) ;
}
}
class DropdownButtonReason extends StatefulWidget {
@ -391,7 +419,12 @@ class DropdownButtonReason extends StatefulWidget {
State < DropdownButtonReason > createState ( ) = > _DropdownButtonReasonState ( ) ;
}
const List < String > list = < String > [ ' Insulte ' , ' Racisme ' , ' Messages inappropriés ' , " Usurpation d'identité " ] ;
const List < String > list = < String > [
' Insulte ' ,
' Racisme ' ,
' Messages inappropriés ' ,
" Usurpation d'identité "
] ;
class _DropdownButtonReasonState extends State < DropdownButtonReason > {
String dropdownValue = list . first ;
@ -401,7 +434,10 @@ class _DropdownButtonReasonState extends State<DropdownButtonReason> {
return DropdownButton < String > (
dropdownColor: Colors . grey . shade900 . withOpacity ( 1 ) ,
value: dropdownValue ,
icon: const Icon ( Icons . arrow_downward , color: Colors . grey , ) ,
icon: const Icon (
Icons . arrow_downward ,
color: Colors . grey ,
) ,
elevation: 16 ,
style: const TextStyle ( color: Colors . white ) ,
underline: Container (