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.

115 lines
6.0 KiB

  1. import 'package:flutter/material.dart';
  2. import '/models/conversations.dart';
  3. import '/views/main/conversation_list_item.dart';
  4. class ConversationList extends StatefulWidget {
  5. const ConversationList({Key? key}) : super(key: key);
  6. @override
  7. State<ConversationList> createState() => _ConversationListState();
  8. }
  9. class _ConversationListState extends State<ConversationList> {
  10. List<Message> messages = [
  11. Message(
  12. id: '123',
  13. conversationId: 'xyz',
  14. data: '',
  15. symmetricKey: '',
  16. messageType: 'reciever',
  17. ),
  18. ];
  19. List<Conversation> friends = [
  20. Conversation(
  21. id: 'xyz',
  22. friendId: 'abc',
  23. recentMessageId: '123',
  24. ),
  25. ];
  26. Widget list() {
  27. if (friends.isEmpty) {
  28. return const Center(
  29. child: Text('No Conversations'),
  30. );
  31. }
  32. return ListView.builder(
  33. itemCount: friends.length,
  34. shrinkWrap: true,
  35. padding: const EdgeInsets.only(top: 16),
  36. physics: const NeverScrollableScrollPhysics(),
  37. itemBuilder: (context, i) {
  38. return ConversationListItem(
  39. id: friends[i].id,
  40. username: 'Test',
  41. );
  42. },
  43. );
  44. }
  45. @override
  46. Widget build(BuildContext context) {
  47. return Scaffold(
  48. body: SingleChildScrollView(
  49. physics: const BouncingScrollPhysics(),
  50. child: Column(
  51. crossAxisAlignment: CrossAxisAlignment.start,
  52. children: <Widget>[
  53. SafeArea(
  54. child: Padding(
  55. padding: const EdgeInsets.only(left: 16,right: 16,top: 10),
  56. child: Row(
  57. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  58. children: <Widget>[
  59. const Text("Conversations",style: TextStyle(fontSize: 32,fontWeight: FontWeight.bold),),
  60. Container(
  61. padding: const EdgeInsets.only(left: 8,right: 8,top: 2,bottom: 2),
  62. height: 30,
  63. decoration: BoxDecoration(
  64. borderRadius: BorderRadius.circular(30),
  65. color: Colors.pink[50],
  66. ),
  67. child: Row(
  68. children: const <Widget>[
  69. Icon(Icons.add,color: Colors.pink,size: 20,),
  70. SizedBox(width: 2,),
  71. Text("Add",style: TextStyle(fontSize: 14,fontWeight: FontWeight.bold),),
  72. ],
  73. ),
  74. )
  75. ],
  76. ),
  77. ),
  78. ),
  79. Padding(
  80. padding: const EdgeInsets.only(top: 16,left: 16,right: 16),
  81. child: TextField(
  82. decoration: InputDecoration(
  83. hintText: "Search...",
  84. hintStyle: TextStyle(color: Colors.grey.shade600),
  85. prefixIcon: Icon(Icons.search,color: Colors.grey.shade600, size: 20,),
  86. filled: true,
  87. fillColor: Colors.grey.shade100,
  88. contentPadding: const EdgeInsets.all(8),
  89. enabledBorder: OutlineInputBorder(
  90. borderRadius: BorderRadius.circular(20),
  91. borderSide: BorderSide(
  92. color: Colors.grey.shade100
  93. )
  94. ),
  95. ),
  96. ),
  97. ),
  98. Padding(
  99. padding: const EdgeInsets.only(top: 16,left: 16,right: 16),
  100. child: list(),
  101. ),
  102. ],
  103. ),
  104. ),
  105. );
  106. }
  107. }