Skip to content

Commit

Permalink
fix: solve several issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Gorter-dev committed Jun 4, 2024
1 parent 3d3153d commit 7cfd808
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ Widget _chatProfileScreenRoute(
configuration,
context,
chatId,
userId,
user.id,
),
),
);
Expand Down
12 changes: 11 additions & 1 deletion packages/flutter_chat_view/lib/src/components/chat_bottom.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class ChatBottom extends StatefulWidget {
class _ChatBottomState extends State<ChatBottom> {
final TextEditingController _textEditingController = TextEditingController();
bool _isTyping = false;
bool _isSending = false;

@override
Widget build(BuildContext context) {
_textEditingController.addListener(() {
Expand Down Expand Up @@ -78,14 +80,22 @@ class _ChatBottomState extends State<ChatBottom> {
IconButton(
disabledColor: widget.iconDisabledColor,
color: widget.iconColor,
onPressed: _isTyping
onPressed: _isTyping && !_isSending
? () async {
setState(() {
_isSending = true;
});

var value = _textEditingController.text;

if (value.isNotEmpty) {
await widget.onMessageSubmit(value);
_textEditingController.clear();
}

setState(() {
_isSending = false;
});
}
: null,
icon: const Icon(
Expand Down
6 changes: 4 additions & 2 deletions packages/flutter_chat_view/lib/src/config/chat_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Widget _createNewChatButton(
padding: const EdgeInsets.fromLTRB(5, 24, 5, 24),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: const Color.fromRGBO(113, 198, 209, 1),
backgroundColor: Theme.of(context).primaryColor,
fixedSize: const Size(254, 44),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(56),
Expand Down Expand Up @@ -136,6 +136,7 @@ Widget _createChatRowContainer(
Widget _createImagePickerContainer(
VoidCallback onClose,
ChatTranslations translations,
BuildContext context,
) =>
Container(
padding: const EdgeInsets.all(8.0),
Expand All @@ -151,7 +152,7 @@ Widget _createImagePickerContainer(
),
customButton: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: const Color.fromRGBO(113, 198, 209, 1),
backgroundColor: Theme.of(context).primaryColor,
),
onPressed: onClose,
child: Text(
Expand Down Expand Up @@ -240,6 +241,7 @@ typedef ContainerBuilder = Widget Function(
typedef ImagePickerContainerBuilder = Widget Function(
VoidCallback onClose,
ChatTranslations translations,
BuildContext context,
);

typedef ScaffoldBuilder = Scaffold Function(
Expand Down
10 changes: 5 additions & 5 deletions packages/flutter_chat_view/lib/src/config/chat_translations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ class ChatTranslations {
this.newChatTitle = 'Start a chat',
this.image = 'Image',
this.searchPlaceholder = 'Search...',
this.startTyping = 'Start typing to find a user to chat with.',
this.startTyping = 'Start typing to find a user to chat with',
this.cancelImagePickerBtn = 'Cancel',
this.messagePlaceholder = 'Write your message here...',
this.writeMessageToStartChat = 'Write a message to start the chat.',
this.writeMessageToStartChat = 'Write a message to start the chat',
this.writeFirstMessageInGroupChat =
'Write the first message in this group chat.',
'Write the first message in this group chat',
this.imageUploading = 'Image is uploading...',
this.deleteChatButton = 'Delete',
this.deleteChatModalTitle = 'Delete chat',
this.deleteChatModalDescription =
'Are you sure you want to delete this chat?',
this.deleteChatModalCancel = 'Cancel',
this.deleteChatModalConfirm = 'Delete',
this.noUsersFound = 'No users were found to start a chat with.',
this.noChatsFound = 'Click on \'Start a chat\' to create a new chat.',
this.noUsersFound = 'No users were found to start a chat with',
this.noChatsFound = 'Click on \'Start a chat\' to create a new chat',
this.anonymousUser = 'Anonymous user',
this.chatCantBeDeleted = 'This chat can\'t be deleted',
this.chatProfileUsers = 'Users:',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
widget.options.imagePickerContainerBuilder(
() => Navigator.of(context).pop(),
widget.translations,
context,
),
).then(
(image) async {
Expand Down Expand Up @@ -216,10 +217,10 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
widget.translations.anonymousUser
: '',
style: theme.appBarTheme.titleTextStyle ??
const TextStyle(
TextStyle(
fontWeight: FontWeight.w800,
fontSize: 24,
color: Color(0xff71C6D1),
color: Theme.of(context).primaryColor,
),
),
),
Expand Down Expand Up @@ -259,7 +260,7 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
shrinkWrap: true,
physics: const AlwaysScrollableScrollPhysics(),
controller: controller,
reverse: true,
reverse: detailRows.isNotEmpty,
padding: const EdgeInsets.only(top: 24.0),
children: [
if (detailRows.isEmpty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ class _ProfileScreenState extends State<ChatProfileScreen> {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4.0),
child: GestureDetector(
onTap: () => widget.onTapUser.call(e),
onTap: () {
widget.onTapUser.call(e);
},
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
Expand Down
13 changes: 4 additions & 9 deletions packages/flutter_chat_view/lib/src/screens/chat_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ class _ChatScreenState extends State<ChatScreen> {
title: Text(
translations.chatsTitle,
style: theme.appBarTheme.titleTextStyle ??
const TextStyle(
TextStyle(
fontWeight: FontWeight.w800,
fontSize: 24,
color: Color(0xff71C6D1),
color: Theme.of(context).primaryColor,
),
),
centerTitle: true,
Expand Down Expand Up @@ -230,13 +230,8 @@ class _ChatScreenState extends State<ChatScreen> {
style: ElevatedButton
.styleFrom(
backgroundColor:
const Color
.fromRGBO(
113,
198,
209,
1,
),
Theme.of(context)
.primaryColor,
),
onPressed: () =>
Navigator.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ class _NewChatScreenState extends State<NewChatScreen> {
: Text(
widget.translations.newChatTitle,
style: theme.appBarTheme.titleTextStyle ??
const TextStyle(
TextStyle(
fontWeight: FontWeight.w800,
fontSize: 24,
color: Color(0xff71C6D1),
color: Theme.of(context).primaryColor,
),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class _NewGroupChatOverviewScreenState
),
),
floatingActionButton: FloatingActionButton(
backgroundColor: Theme.of(context).primaryColor,
onPressed: () async {
await widget.onPressCompleteGroupChatCreation(
widget.users,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class _NewGroupChatScreenState extends State<NewGroupChatScreen> {
},
),
floatingActionButton: FloatingActionButton(
backgroundColor: const Color(0xff71C6D1),
backgroundColor: Theme.of(context).primaryColor,
onPressed: () async {
await widget.onPressGroupChatOverview(selectedUserList);
},
Expand Down Expand Up @@ -105,10 +105,10 @@ class _NewGroupChatScreenState extends State<NewGroupChatScreen> {
: Text(
widget.translations.newGroupChatButton,
style: theme.appBarTheme.titleTextStyle ??
const TextStyle(
TextStyle(
fontWeight: FontWeight.w800,
fontSize: 24,
color: Color(0xff71C6D1),
color: Theme.of(context).primaryColor,
),
);
}
Expand Down

0 comments on commit 7cfd808

Please sign in to comment.