Encrypted messaging app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

162 lines
8.3 KiB

  1. import 'package:flutter/material.dart';
  2. import '/models/conversations.dart';
  3. class ConversationDetail extends StatefulWidget{
  4. const ConversationDetail({Key? key}) : super(key: key);
  5. @override
  6. _ConversationDetailState createState() => _ConversationDetailState();
  7. }
  8. class _ConversationDetailState extends State<ConversationDetail> {
  9. Conversation conversation = Conversation(
  10. id: '777',
  11. friendId: 'abc',
  12. recentMessageId: '111',
  13. );
  14. List<Message> messages = [
  15. Message(
  16. id: '444',
  17. conversationId: '777',
  18. symmetricKey: '',
  19. data: 'This is a message',
  20. messageType: messageTypeSender,
  21. ),
  22. Message(
  23. id: '444',
  24. conversationId: '777',
  25. symmetricKey: '',
  26. data: 'This is a message',
  27. messageType: messageTypeReceiver,
  28. ),
  29. Message(
  30. id: '444',
  31. conversationId: '777',
  32. symmetricKey: '',
  33. data: 'This is a message',
  34. messageType: messageTypeSender
  35. ),
  36. Message(
  37. id: '444',
  38. conversationId: '777',
  39. symmetricKey: '',
  40. data: 'This is a message',
  41. messageType: messageTypeReceiver,
  42. ),
  43. ];
  44. @override
  45. Widget build(BuildContext context) {
  46. return Scaffold(
  47. appBar: AppBar(
  48. elevation: 0,
  49. automaticallyImplyLeading: false,
  50. backgroundColor: Colors.white,
  51. flexibleSpace: SafeArea(
  52. child: Container(
  53. padding: const EdgeInsets.only(right: 16),
  54. child: Row(
  55. children: <Widget>[
  56. IconButton(
  57. onPressed: (){
  58. Navigator.pop(context);
  59. },
  60. icon: const Icon(Icons.arrow_back,color: Colors.black,),
  61. ),
  62. const SizedBox(width: 2,),
  63. Expanded(
  64. child: Column(
  65. crossAxisAlignment: CrossAxisAlignment.start,
  66. mainAxisAlignment: MainAxisAlignment.center,
  67. children: const <Widget>[
  68. Text("Kriss Benwat",style: TextStyle( fontSize: 16 ,fontWeight: FontWeight.w600),),
  69. ],
  70. ),
  71. ),
  72. const Icon(Icons.settings,color: Colors.black54,),
  73. ],
  74. ),
  75. ),
  76. ),
  77. ),
  78. body: Stack(
  79. children: <Widget>[
  80. ListView.builder(
  81. itemCount: messages.length,
  82. shrinkWrap: true,
  83. padding: const EdgeInsets.only(top: 10,bottom: 10),
  84. physics: const NeverScrollableScrollPhysics(),
  85. itemBuilder: (context, index) {
  86. return Container(
  87. padding: const EdgeInsets.only(left: 14,right: 14,top: 10,bottom: 10),
  88. child: Align(
  89. alignment: (messages[index].messageType == messageTypeReceiver ? Alignment.topLeft:Alignment.topRight),
  90. child: Container(
  91. decoration: BoxDecoration(
  92. borderRadius: BorderRadius.circular(20),
  93. color: (messages[index].messageType == messageTypeReceiver ? Colors.grey.shade200:Colors.blue[200]),
  94. ),
  95. padding: const EdgeInsets.all(16),
  96. child: Text(messages[index].data, style: const TextStyle(fontSize: 15)),
  97. ),
  98. ),
  99. );
  100. },
  101. ),
  102. Align(
  103. alignment: Alignment.bottomLeft,
  104. child: ConstrainedBox(
  105. constraints: const BoxConstraints(
  106. maxHeight: 200.0,
  107. ),
  108. child: Container(
  109. padding: const EdgeInsets.only(left: 10,bottom: 10,top: 10),
  110. // height: 60,
  111. width: double.infinity,
  112. color: Colors.white,
  113. child: Row(
  114. children: <Widget>[
  115. GestureDetector(
  116. onTap: (){
  117. },
  118. child: Container(
  119. height: 30,
  120. width: 30,
  121. decoration: BoxDecoration(
  122. color: Colors.lightBlue,
  123. borderRadius: BorderRadius.circular(30),
  124. ),
  125. child: const Icon(Icons.add, color: Colors.white, size: 20, ),
  126. ),
  127. ),
  128. const SizedBox(width: 15,),
  129. const Expanded(
  130. child: TextField(
  131. decoration: InputDecoration(
  132. hintText: "Write message...",
  133. hintStyle: TextStyle(color: Colors.black54),
  134. border: InputBorder.none,
  135. ),
  136. maxLines: null,
  137. ),
  138. ),
  139. const SizedBox(width: 15,),
  140. FloatingActionButton(
  141. onPressed: () {
  142. },
  143. child: const Icon(Icons.send,color: Colors.white,size: 18,),
  144. backgroundColor: Colors.blue,
  145. elevation: 0,
  146. ),
  147. ],
  148. ),
  149. ),
  150. ),
  151. ),
  152. ],
  153. ),
  154. );
  155. }
  156. }