Increase jump delay when focusing textfield
This commit is contained in:
parent
f6da6e0365
commit
a7856186bc
4 changed files with 26 additions and 11 deletions
|
|
@ -34,13 +34,6 @@ class ChatBottomBar extends StatelessWidget {
|
|||
minLines: 1,
|
||||
maxLines: 5,
|
||||
enabled: chatStore.auth.isLoggedIn ? true : false,
|
||||
onTap: () {
|
||||
chatStore.assetsStore.showEmoteMenu = false;
|
||||
Future.delayed(
|
||||
const Duration(milliseconds: 200),
|
||||
() => chatStore.scrollController.jumpTo(chatStore.scrollController.position.maxScrollExtent),
|
||||
);
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
suffixIcon: IconButton(
|
||||
tooltip: 'Emote Menu',
|
||||
|
|
|
|||
|
|
@ -49,10 +49,6 @@ class ChatUserModal extends StatelessWidget {
|
|||
chatStore.textController.text = '@$username ';
|
||||
Navigator.pop(context);
|
||||
chatStore.textFieldFocusNode.requestFocus();
|
||||
Future.delayed(
|
||||
const Duration(milliseconds: 200),
|
||||
() => chatStore.scrollController.jumpTo(chatStore.scrollController.position.maxScrollExtent),
|
||||
);
|
||||
},
|
||||
child: const Text('Reply'),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -111,6 +111,20 @@ abstract class _ChatStoreBase with Store {
|
|||
if (_autoScroll == false) _autoScroll = true;
|
||||
}
|
||||
});
|
||||
|
||||
// Add a listener to the textfield that will do the following when focused:
|
||||
// 1. Hide the emote menu if it is currently shown
|
||||
// 2. Scroll to the latest message (after a brief delay)
|
||||
textFieldFocusNode.addListener(() {
|
||||
if (textFieldFocusNode.hasFocus) {
|
||||
if (assetsStore.showEmoteMenu) assetsStore.showEmoteMenu = false;
|
||||
|
||||
Future.delayed(
|
||||
const Duration(milliseconds: 500),
|
||||
() => scrollController.jumpTo(scrollController.position.maxScrollExtent),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Handle and process the provided string-representation of the IRC data.
|
||||
|
|
@ -280,6 +294,7 @@ abstract class _ChatStoreBase with Store {
|
|||
}
|
||||
|
||||
/// Sends the given string message by the logged-in user and adds it to [_messages].
|
||||
@action
|
||||
void sendMessage(String message) {
|
||||
// Do not send if the message is blank/empty.
|
||||
if (message.isEmpty) return;
|
||||
|
|
|
|||
|
|
@ -85,6 +85,17 @@ mixin _$ChatStore on _ChatStoreBase, Store {
|
|||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void sendMessage(String message) {
|
||||
final _$actionInfo = _$_ChatStoreBaseActionController.startAction(
|
||||
name: '_ChatStoreBase.sendMessage');
|
||||
try {
|
||||
return super.sendMessage(message);
|
||||
} finally {
|
||||
_$_ChatStoreBaseActionController.endAction(_$actionInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue