mirror of
https://github.com/Iconica-Development/flutter_chat.git
synced 2025-05-19 10:53:51 +02:00
fix: solve several issues
This commit is contained in:
parent
3d3153d2ce
commit
7cfd8087a1
10 changed files with 38 additions and 27 deletions
|
@ -180,7 +180,7 @@ Widget _chatProfileScreenRoute(
|
||||||
configuration,
|
configuration,
|
||||||
context,
|
context,
|
||||||
chatId,
|
chatId,
|
||||||
userId,
|
user.id,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -43,6 +43,8 @@ class ChatBottom extends StatefulWidget {
|
||||||
class _ChatBottomState extends State<ChatBottom> {
|
class _ChatBottomState extends State<ChatBottom> {
|
||||||
final TextEditingController _textEditingController = TextEditingController();
|
final TextEditingController _textEditingController = TextEditingController();
|
||||||
bool _isTyping = false;
|
bool _isTyping = false;
|
||||||
|
bool _isSending = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
_textEditingController.addListener(() {
|
_textEditingController.addListener(() {
|
||||||
|
@ -78,14 +80,22 @@ class _ChatBottomState extends State<ChatBottom> {
|
||||||
IconButton(
|
IconButton(
|
||||||
disabledColor: widget.iconDisabledColor,
|
disabledColor: widget.iconDisabledColor,
|
||||||
color: widget.iconColor,
|
color: widget.iconColor,
|
||||||
onPressed: _isTyping
|
onPressed: _isTyping && !_isSending
|
||||||
? () async {
|
? () async {
|
||||||
|
setState(() {
|
||||||
|
_isSending = true;
|
||||||
|
});
|
||||||
|
|
||||||
var value = _textEditingController.text;
|
var value = _textEditingController.text;
|
||||||
|
|
||||||
if (value.isNotEmpty) {
|
if (value.isNotEmpty) {
|
||||||
await widget.onMessageSubmit(value);
|
await widget.onMessageSubmit(value);
|
||||||
_textEditingController.clear();
|
_textEditingController.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_isSending = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
|
|
|
@ -62,7 +62,7 @@ Widget _createNewChatButton(
|
||||||
padding: const EdgeInsets.fromLTRB(5, 24, 5, 24),
|
padding: const EdgeInsets.fromLTRB(5, 24, 5, 24),
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: const Color.fromRGBO(113, 198, 209, 1),
|
backgroundColor: Theme.of(context).primaryColor,
|
||||||
fixedSize: const Size(254, 44),
|
fixedSize: const Size(254, 44),
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(56),
|
borderRadius: BorderRadius.circular(56),
|
||||||
|
@ -136,6 +136,7 @@ Widget _createChatRowContainer(
|
||||||
Widget _createImagePickerContainer(
|
Widget _createImagePickerContainer(
|
||||||
VoidCallback onClose,
|
VoidCallback onClose,
|
||||||
ChatTranslations translations,
|
ChatTranslations translations,
|
||||||
|
BuildContext context,
|
||||||
) =>
|
) =>
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
@ -151,7 +152,7 @@ Widget _createImagePickerContainer(
|
||||||
),
|
),
|
||||||
customButton: ElevatedButton(
|
customButton: ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: const Color.fromRGBO(113, 198, 209, 1),
|
backgroundColor: Theme.of(context).primaryColor,
|
||||||
),
|
),
|
||||||
onPressed: onClose,
|
onPressed: onClose,
|
||||||
child: Text(
|
child: Text(
|
||||||
|
@ -240,6 +241,7 @@ typedef ContainerBuilder = Widget Function(
|
||||||
typedef ImagePickerContainerBuilder = Widget Function(
|
typedef ImagePickerContainerBuilder = Widget Function(
|
||||||
VoidCallback onClose,
|
VoidCallback onClose,
|
||||||
ChatTranslations translations,
|
ChatTranslations translations,
|
||||||
|
BuildContext context,
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef ScaffoldBuilder = Scaffold Function(
|
typedef ScaffoldBuilder = Scaffold Function(
|
||||||
|
|
|
@ -47,12 +47,12 @@ class ChatTranslations {
|
||||||
this.newChatTitle = 'Start a chat',
|
this.newChatTitle = 'Start a chat',
|
||||||
this.image = 'Image',
|
this.image = 'Image',
|
||||||
this.searchPlaceholder = 'Search...',
|
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.cancelImagePickerBtn = 'Cancel',
|
||||||
this.messagePlaceholder = 'Write your message here...',
|
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 =
|
this.writeFirstMessageInGroupChat =
|
||||||
'Write the first message in this group chat.',
|
'Write the first message in this group chat',
|
||||||
this.imageUploading = 'Image is uploading...',
|
this.imageUploading = 'Image is uploading...',
|
||||||
this.deleteChatButton = 'Delete',
|
this.deleteChatButton = 'Delete',
|
||||||
this.deleteChatModalTitle = 'Delete chat',
|
this.deleteChatModalTitle = 'Delete chat',
|
||||||
|
@ -60,8 +60,8 @@ class ChatTranslations {
|
||||||
'Are you sure you want to delete this chat?',
|
'Are you sure you want to delete this chat?',
|
||||||
this.deleteChatModalCancel = 'Cancel',
|
this.deleteChatModalCancel = 'Cancel',
|
||||||
this.deleteChatModalConfirm = 'Delete',
|
this.deleteChatModalConfirm = 'Delete',
|
||||||
this.noUsersFound = 'No users were found to start a chat with.',
|
this.noUsersFound = 'No users were found to start a chat with',
|
||||||
this.noChatsFound = 'Click on \'Start a chat\' to create a new chat.',
|
this.noChatsFound = 'Click on \'Start a chat\' to create a new chat',
|
||||||
this.anonymousUser = 'Anonymous user',
|
this.anonymousUser = 'Anonymous user',
|
||||||
this.chatCantBeDeleted = 'This chat can\'t be deleted',
|
this.chatCantBeDeleted = 'This chat can\'t be deleted',
|
||||||
this.chatProfileUsers = 'Users:',
|
this.chatProfileUsers = 'Users:',
|
||||||
|
|
|
@ -145,6 +145,7 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
|
||||||
widget.options.imagePickerContainerBuilder(
|
widget.options.imagePickerContainerBuilder(
|
||||||
() => Navigator.of(context).pop(),
|
() => Navigator.of(context).pop(),
|
||||||
widget.translations,
|
widget.translations,
|
||||||
|
context,
|
||||||
),
|
),
|
||||||
).then(
|
).then(
|
||||||
(image) async {
|
(image) async {
|
||||||
|
@ -216,10 +217,10 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
|
||||||
widget.translations.anonymousUser
|
widget.translations.anonymousUser
|
||||||
: '',
|
: '',
|
||||||
style: theme.appBarTheme.titleTextStyle ??
|
style: theme.appBarTheme.titleTextStyle ??
|
||||||
const TextStyle(
|
TextStyle(
|
||||||
fontWeight: FontWeight.w800,
|
fontWeight: FontWeight.w800,
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
color: Color(0xff71C6D1),
|
color: Theme.of(context).primaryColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -259,7 +260,7 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
controller: controller,
|
controller: controller,
|
||||||
reverse: true,
|
reverse: detailRows.isNotEmpty,
|
||||||
padding: const EdgeInsets.only(top: 24.0),
|
padding: const EdgeInsets.only(top: 24.0),
|
||||||
children: [
|
children: [
|
||||||
if (detailRows.isEmpty)
|
if (detailRows.isEmpty)
|
||||||
|
|
|
@ -124,7 +124,9 @@ class _ProfileScreenState extends State<ChatProfileScreen> {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () => widget.onTapUser.call(e),
|
onTap: () {
|
||||||
|
widget.onTapUser.call(e);
|
||||||
|
},
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
|
|
@ -82,10 +82,10 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||||
title: Text(
|
title: Text(
|
||||||
translations.chatsTitle,
|
translations.chatsTitle,
|
||||||
style: theme.appBarTheme.titleTextStyle ??
|
style: theme.appBarTheme.titleTextStyle ??
|
||||||
const TextStyle(
|
TextStyle(
|
||||||
fontWeight: FontWeight.w800,
|
fontWeight: FontWeight.w800,
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
color: Color(0xff71C6D1),
|
color: Theme.of(context).primaryColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
|
@ -230,13 +230,8 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||||
style: ElevatedButton
|
style: ElevatedButton
|
||||||
.styleFrom(
|
.styleFrom(
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
const Color
|
Theme.of(context)
|
||||||
.fromRGBO(
|
.primaryColor,
|
||||||
113,
|
|
||||||
198,
|
|
||||||
209,
|
|
||||||
1,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
Navigator.of(
|
Navigator.of(
|
||||||
|
|
|
@ -161,10 +161,10 @@ class _NewChatScreenState extends State<NewChatScreen> {
|
||||||
: Text(
|
: Text(
|
||||||
widget.translations.newChatTitle,
|
widget.translations.newChatTitle,
|
||||||
style: theme.appBarTheme.titleTextStyle ??
|
style: theme.appBarTheme.titleTextStyle ??
|
||||||
const TextStyle(
|
TextStyle(
|
||||||
fontWeight: FontWeight.w800,
|
fontWeight: FontWeight.w800,
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
color: Color(0xff71C6D1),
|
color: Theme.of(context).primaryColor,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ class _NewGroupChatOverviewScreenState
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
|
backgroundColor: Theme.of(context).primaryColor,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await widget.onPressCompleteGroupChatCreation(
|
await widget.onPressCompleteGroupChatCreation(
|
||||||
widget.users,
|
widget.users,
|
||||||
|
|
|
@ -58,7 +58,7 @@ class _NewGroupChatScreenState extends State<NewGroupChatScreen> {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
backgroundColor: const Color(0xff71C6D1),
|
backgroundColor: Theme.of(context).primaryColor,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await widget.onPressGroupChatOverview(selectedUserList);
|
await widget.onPressGroupChatOverview(selectedUserList);
|
||||||
},
|
},
|
||||||
|
@ -105,10 +105,10 @@ class _NewGroupChatScreenState extends State<NewGroupChatScreen> {
|
||||||
: Text(
|
: Text(
|
||||||
widget.translations.newGroupChatButton,
|
widget.translations.newGroupChatButton,
|
||||||
style: theme.appBarTheme.titleTextStyle ??
|
style: theme.appBarTheme.titleTextStyle ??
|
||||||
const TextStyle(
|
TextStyle(
|
||||||
fontWeight: FontWeight.w800,
|
fontWeight: FontWeight.w800,
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
color: Color(0xff71C6D1),
|
color: Theme.of(context).primaryColor,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue