chore(flutter_chat): various fixes and improvements

- style: use consistent font in buttons
- fix: update profile picture icon for adding a group chat to match design
- fix: align "Write your message here" placeholder text and buttons properly in the input box
- fix: ensure 'next' button is not visible when no one is selected for group chat
- fix: allow scroll to go further so the last person in the list is not hidden by the ‘next’ button
- fix: make entire name clickable when adding members to a group chat
- fix: change text from “create a groupchat” to “start a groupchat”
- fix: make 'create group chat' button inactive until a name is entered
- style: adjust image picker icon sizes, and cancel button font
This commit is contained in:
HammadAsiif 2024-08-06 09:57:16 +02:00 committed by Freek van de Ven
parent 9585ded6d5
commit ef2e594277
7 changed files with 62 additions and 41 deletions

View file

@ -15,6 +15,7 @@ class MessageModel {
required this.timestamp, required this.timestamp,
required this.senderId, required this.senderId,
}); });
/// The chat id /// The chat id
final String chatId; final String chatId;

View file

@ -56,7 +56,7 @@ class ChatTranslations {
this.chatsTitle = "Chats", this.chatsTitle = "Chats",
this.chatsUnread = "unread", this.chatsUnread = "unread",
this.newChatButton = "Start chat", this.newChatButton = "Start chat",
this.newGroupChatButton = "Create a groupchat", this.newGroupChatButton = "Start a groupchat",
this.newChatTitle = "Start a chat", this.newChatTitle = "Start a chat",
this.image = "Image", this.image = "Image",
this.searchPlaceholder = "Search...", this.searchPlaceholder = "Search...",

View file

@ -396,6 +396,7 @@ class _ChatBottomState extends State<_ChatBottom> {
context, context,
_textEditingController, _textEditingController,
Row( Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
IconButton( IconButton(
@ -435,6 +436,8 @@ class _ChatBottomState extends State<_ChatBottom> {
widget.options.translations, widget.options.translations,
) ?? ) ??
TextField( TextField(
textAlign: TextAlign.start,
textAlignVertical: TextAlignVertical.center,
style: theme.textTheme.bodySmall, style: theme.textTheme.bodySmall,
textCapitalization: TextCapitalization.sentences, textCapitalization: TextCapitalization.sentences,
controller: _textEditingController, controller: _textEditingController,

View file

@ -198,12 +198,13 @@ class _Body extends StatelessWidget {
onPressed: onPressCreateGroupChat, onPressed: onPressCreateGroupChat,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
const Icon( const Icon(
Icons.groups, Icons.groups_2,
), ),
const SizedBox( const SizedBox(
width: 4, width: 8,
), ),
Text( Text(
translations.newGroupChatButton, translations.newGroupChatButton,

View file

@ -110,6 +110,7 @@ class _Body extends StatefulWidget {
class _BodyState extends State<_Body> { class _BodyState extends State<_Body> {
final TextEditingController _chatNameController = TextEditingController(); final TextEditingController _chatNameController = TextEditingController();
final TextEditingController _bioController = TextEditingController(); final TextEditingController _bioController = TextEditingController();
final ValueNotifier<bool> isButtonEnabled = ValueNotifier<bool>(false);
Uint8List? image; Uint8List? image;
GlobalKey<FormState> formKey = GlobalKey<FormState>(); GlobalKey<FormState> formKey = GlobalKey<FormState>();
@ -121,6 +122,17 @@ class _BodyState extends State<_Body> {
void initState() { void initState() {
users = widget.users; users = widget.users;
super.initState(); super.initState();
_chatNameController.addListener(() {
isButtonEnabled.value = _chatNameController.text.isNotEmpty;
});
}
@override
void dispose() {
_chatNameController.dispose();
_bioController.dispose();
isButtonEnabled.dispose();
super.dispose();
} }
@override @override
@ -325,31 +337,34 @@ class _BodyState extends State<_Body> {
vertical: 24, vertical: 24,
horizontal: 80, horizontal: 80,
), ),
child: FilledButton( child: ValueListenableBuilder(
onPressed: users.isNotEmpty valueListenable: isButtonEnabled,
? () async { builder: (context, isEnabled, child) => FilledButton(
if (!isPressed) { onPressed: users.isNotEmpty
isPressed = true; ? () async {
if (formKey.currentState!.validate()) { if (!isPressed) {
await widget.onComplete( isPressed = true;
users, if (formKey.currentState!.validate()) {
_chatNameController.text, await widget.onComplete(
_bioController.text, users,
image, _chatNameController.text,
); _bioController.text,
image,
);
}
isPressed = false;
} }
isPressed = false;
} }
} : null,
: null, child: Row(
child: Row( mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center, children: [
children: [ Text(
Text( translations.createGroupChatButton,
translations.createGroupChatButton, style: theme.textTheme.displayLarge,
style: theme.textTheme.displayLarge, ),
), ],
], ),
), ),
), ),
), ),

View file

@ -274,20 +274,21 @@ class _NextButton extends StatelessWidget {
vertical: 24, vertical: 24,
horizontal: 80, horizontal: 80,
), ),
child: FilledButton( child: Visibility(
onPressed: selectedUsers.isNotEmpty visible: selectedUsers.isNotEmpty,
? () { child: FilledButton(
onPressGroupChatOverview(selectedUsers); onPressed: () async {
} await onPressGroupChatOverview(selectedUsers);
: null, },
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text( Text(
chatOptions.translations.next, chatOptions.translations.next,
style: theme.textTheme.displayLarge, style: theme.textTheme.displayLarge,
), ),
], ],
),
), ),
), ),
), ),

View file

@ -72,7 +72,7 @@ class _UserListState extends State<UserList> {
) )
.toList(); .toList();
return Padding( return Padding(
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 12), padding: const EdgeInsets.only(top: 8, left: 12, right: 12, bottom: 80),
child: ListView.builder( child: ListView.builder(
itemCount: filteredUsers.length, itemCount: filteredUsers.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {