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.

124 lines
3.8 KiB

  1. import 'package:Envelope/models/conversation_users.dart';
  2. import 'package:flutter/material.dart';
  3. import '/views/main/conversation_settings_user_list_item.dart';
  4. import '/models/conversations.dart';
  5. import 'package:Envelope/components/custom_circle_avatar.dart';
  6. class ConversationSettings extends StatefulWidget {
  7. final Conversation conversation;
  8. const ConversationSettings({
  9. Key? key,
  10. required this.conversation,
  11. }) : super(key: key);
  12. @override
  13. State<ConversationSettings> createState() => _ConversationSettingsState();
  14. }
  15. class _ConversationSettingsState extends State<ConversationSettings> {
  16. final _formKey = GlobalKey<FormState>();
  17. List<ConversationUser> users = [];
  18. TextEditingController nameController = TextEditingController();
  19. @override
  20. void initState() {
  21. nameController.text = widget.conversation.name;
  22. super.initState();
  23. getUsers();
  24. }
  25. Future<void> getUsers() async {
  26. users = await getConversationUsers(widget.conversation);
  27. setState(() {});
  28. }
  29. Widget conversationName() {
  30. return Row(
  31. children: <Widget> [
  32. const CustomCircleAvatar(
  33. icon: Icon(Icons.people, size: 40),
  34. imagePath: null, // TODO: Add image here
  35. radius: 30,
  36. ),
  37. const SizedBox(width: 10),
  38. Text(
  39. widget.conversation.name,
  40. style: const TextStyle(
  41. fontSize: 25,
  42. fontWeight: FontWeight.w500,
  43. ),
  44. ),
  45. ],
  46. );
  47. }
  48. Widget usersList() {
  49. return ListView.builder(
  50. itemCount: users.length,
  51. shrinkWrap: true,
  52. padding: const EdgeInsets.only(top: 16),
  53. itemBuilder: (context, i) {
  54. return ConversationSettingsUserListItem(
  55. user: users[i],
  56. isAdmin: widget.conversation.admin,
  57. );
  58. }
  59. );
  60. }
  61. @override
  62. Widget build(BuildContext context) {
  63. return Scaffold(
  64. appBar: AppBar(
  65. elevation: 0,
  66. automaticallyImplyLeading: false,
  67. flexibleSpace: SafeArea(
  68. child: Container(
  69. padding: const EdgeInsets.only(right: 16),
  70. child: Row(
  71. children: <Widget>[
  72. IconButton(
  73. onPressed: (){
  74. Navigator.pop(context);
  75. },
  76. icon: const Icon(Icons.arrow_back),
  77. ),
  78. const SizedBox(width: 2,),
  79. Expanded(
  80. child: Column(
  81. crossAxisAlignment: CrossAxisAlignment.start,
  82. mainAxisAlignment: MainAxisAlignment.center,
  83. children: <Widget>[
  84. Text(
  85. widget.conversation.name + " Settings",
  86. style: const TextStyle(
  87. fontSize: 16,
  88. fontWeight: FontWeight.w600
  89. ),
  90. ),
  91. ],
  92. ),
  93. ),
  94. ],
  95. ),
  96. ),
  97. ),
  98. ),
  99. body: Padding(
  100. padding: const EdgeInsets.all(15),
  101. child: Column(
  102. children: <Widget> [
  103. const SizedBox(height: 30),
  104. conversationName(),
  105. const SizedBox(height: 10),
  106. const Text('Users', style: TextStyle(fontSize: 20)),
  107. usersList(),
  108. ],
  109. ),
  110. ),
  111. );
  112. }
  113. }