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.

140 lines
8.1 KiB

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