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