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.

147 lines
5.6 KiB

  1. import 'package:flutter/material.dart';
  2. import '/components/custom_circle_avatar.dart';
  3. import '/models/conversations.dart';
  4. import '/models/friends.dart';
  5. import '/views/main/conversation/create_add_users.dart';
  6. class ConversationEditDetails extends StatefulWidget {
  7. final Conversation? conversation;
  8. final List<Friend>? friends;
  9. const ConversationEditDetails({
  10. Key? key,
  11. this.conversation,
  12. this.friends,
  13. }) : super(key: key);
  14. @override
  15. State<ConversationEditDetails> createState() => _ConversationEditDetails();
  16. }
  17. class _ConversationEditDetails extends State<ConversationEditDetails> {
  18. final _formKey = GlobalKey<FormState>();
  19. List<Conversation> conversations = [];
  20. TextEditingController conversationNameController = TextEditingController();
  21. @override
  22. Widget build(BuildContext context) {
  23. const TextStyle inputTextStyle = TextStyle(
  24. fontSize: 25,
  25. );
  26. final OutlineInputBorder inputBorderStyle = OutlineInputBorder(
  27. borderRadius: BorderRadius.circular(5),
  28. borderSide: const BorderSide(
  29. color: Colors.transparent,
  30. )
  31. );
  32. final ButtonStyle buttonStyle = ElevatedButton.styleFrom(
  33. padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 10),
  34. textStyle: TextStyle(
  35. fontSize: 15,
  36. fontWeight: FontWeight.bold,
  37. color: Theme.of(context).colorScheme.error,
  38. ),
  39. );
  40. return Scaffold(
  41. appBar: AppBar(
  42. elevation: 0,
  43. automaticallyImplyLeading: false,
  44. flexibleSpace: SafeArea(
  45. child: Container(
  46. padding: const EdgeInsets.only(right: 16),
  47. child: Row(
  48. children: <Widget>[
  49. IconButton(
  50. onPressed: (){
  51. Navigator.pop(context);
  52. },
  53. icon: const Icon(Icons.arrow_back),
  54. ),
  55. const SizedBox(width: 2,),
  56. Expanded(
  57. child: Column(
  58. crossAxisAlignment: CrossAxisAlignment.start,
  59. mainAxisAlignment: MainAxisAlignment.center,
  60. children: <Widget>[
  61. Text(
  62. widget.conversation != null ?
  63. widget.conversation!.name + " Settings" :
  64. 'Add Conversation',
  65. style: const TextStyle(
  66. fontSize: 16,
  67. fontWeight: FontWeight.w600
  68. ),
  69. ),
  70. ],
  71. ),
  72. ),
  73. ],
  74. ),
  75. ),
  76. ),
  77. ),
  78. body: Center(
  79. child: Padding(
  80. padding: const EdgeInsets.only(
  81. top: 50,
  82. left: 25,
  83. right: 25,
  84. ),
  85. child: Form(
  86. key: _formKey,
  87. child: Column(
  88. children: [
  89. CustomCircleAvatar(
  90. icon: widget.conversation != null ?
  91. null : // TODO: Add icon here
  92. const Icon(Icons.people, size: 60),
  93. imagePath: null,
  94. radius: 50,
  95. ),
  96. const SizedBox(height: 30),
  97. TextFormField(
  98. controller: conversationNameController,
  99. textAlign: TextAlign.center,
  100. decoration: InputDecoration(
  101. hintText: 'Title',
  102. enabledBorder: inputBorderStyle,
  103. focusedBorder: inputBorderStyle,
  104. ),
  105. style: inputTextStyle,
  106. // The validator receives the text that the user has entered.
  107. validator: (value) {
  108. if (value == null || value.isEmpty) {
  109. return 'Add a title';
  110. }
  111. return null;
  112. },
  113. ),
  114. const SizedBox(height: 30),
  115. ElevatedButton(
  116. style: buttonStyle,
  117. onPressed: () {
  118. if (_formKey.currentState!.validate()) {
  119. Navigator.of(context).push(
  120. MaterialPageRoute(builder: (context) => ConversationAddFriendsList(
  121. friends: widget.friends!,
  122. title: conversationNameController.text,
  123. )
  124. )
  125. );
  126. }
  127. },
  128. child: const Text('Save'),
  129. ),
  130. ],
  131. ),
  132. ),
  133. ),
  134. ),
  135. );
  136. }
  137. }