import 'package:flutter/material.dart'; import '/components/custom_circle_avatar.dart'; import '/views/main/conversation_create_add_users.dart'; import '/models/friends.dart'; import '/models/conversations.dart'; class ConversationEditDetails extends StatefulWidget { final Conversation? conversation; final List? friends; const ConversationEditDetails({ Key? key, this.conversation, this.friends, }) : super(key: key); @override State createState() => _ConversationEditDetails(); } class _ConversationEditDetails extends State { final _formKey = GlobalKey(); List conversations = []; TextEditingController conversationNameController = TextEditingController(); @override Widget build(BuildContext context) { const TextStyle inputTextStyle = TextStyle( fontSize: 25, ); final OutlineInputBorder inputBorderStyle = OutlineInputBorder( borderRadius: BorderRadius.circular(5), borderSide: const BorderSide( color: Colors.transparent, ) ); final ButtonStyle buttonStyle = ElevatedButton.styleFrom( padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 10), textStyle: TextStyle( fontSize: 15, fontWeight: FontWeight.bold, color: Theme.of(context).colorScheme.error, ), ); return Scaffold( appBar: AppBar( elevation: 0, automaticallyImplyLeading: false, flexibleSpace: SafeArea( child: Container( padding: const EdgeInsets.only(right: 16), child: Row( children: [ IconButton( onPressed: (){ Navigator.pop(context); }, icon: const Icon(Icons.arrow_back), ), const SizedBox(width: 2,), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ Text( widget.conversation != null ? widget.conversation!.name + " Settings" : 'Add Conversation', style: const TextStyle( fontSize: 16, fontWeight: FontWeight.w600 ), ), ], ), ), ], ), ), ), ), body: Center( child: Padding( padding: const EdgeInsets.only( top: 50, left: 25, right: 25, ), child: Form( key: _formKey, child: Column( children: [ CustomCircleAvatar( icon: widget.conversation != null ? null : // TODO: Add icon here const Icon(Icons.people, size: 60), imagePath: null, radius: 50, ), const SizedBox(height: 30), TextFormField( controller: conversationNameController, textAlign: TextAlign.center, decoration: InputDecoration( hintText: 'Title', enabledBorder: inputBorderStyle, focusedBorder: inputBorderStyle, ), style: inputTextStyle, // The validator receives the text that the user has entered. validator: (value) { if (value == null || value.isEmpty) { return 'Add a title'; } return null; }, ), const SizedBox(height: 30), ElevatedButton( style: buttonStyle, onPressed: () { if (_formKey.currentState!.validate()) { Navigator.of(context).push( MaterialPageRoute(builder: (context) => ConversationAddFriendsList( friends: widget.friends!, title: conversationNameController.text, ) ) ); } }, child: const Text('Save'), ), ], ), ), ), ), ); } }