feat: Shrink actions on type
This commit is contained in:
+33
-12
@@ -169,7 +169,8 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
bool _commandEnabled = false;
|
bool _commandEnabled = false;
|
||||||
OverlayEntry _commandsOverlay, _mentionsOverlay;
|
OverlayEntry _commandsOverlay, _mentionsOverlay;
|
||||||
|
|
||||||
Command chosenCommand;
|
Command _chosenCommand;
|
||||||
|
bool _actionsShrunk = false;
|
||||||
|
|
||||||
/// The editing controller passed to the input TextField
|
/// The editing controller passed to the input TextField
|
||||||
TextEditingController textEditingController;
|
TextEditingController textEditingController;
|
||||||
@@ -202,14 +203,8 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
direction: Axis.horizontal,
|
direction: Axis.horizontal,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (!_commandEnabled)
|
if(!_commandEnabled)
|
||||||
Row(
|
_buildExpandActionsButton(),
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
|
||||||
if (!widget.disableAttachments) _buildAttachmentButton(),
|
|
||||||
if (widget.editMessage == null) _buildCommandButton(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
if (widget.actionsLocation == ActionsLocation.left)
|
if (widget.actionsLocation == ActionsLocation.left)
|
||||||
...widget.actions ?? [],
|
...widget.actions ?? [],
|
||||||
_buildTextInput(context),
|
_buildTextInput(context),
|
||||||
@@ -233,6 +228,31 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildExpandActionsButton() {
|
||||||
|
return AnimatedCrossFade(
|
||||||
|
crossFadeState: _actionsShrunk
|
||||||
|
? CrossFadeState.showFirst
|
||||||
|
: CrossFadeState.showSecond,
|
||||||
|
firstChild: IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
_actionsShrunk = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
icon: Icon(StreamIcons.arrow_right, color: StreamChatTheme.of(context).accentColor,),
|
||||||
|
),
|
||||||
|
secondChild: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
children: [
|
||||||
|
if (!widget.disableAttachments) _buildAttachmentButton(),
|
||||||
|
if (widget.editMessage == null) _buildCommandButton(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
duration: Duration(milliseconds: 300),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Expanded _buildTextInput(BuildContext context) {
|
Expanded _buildTextInput(BuildContext context) {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: Center(
|
child: Center(
|
||||||
@@ -254,6 +274,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_messageIsPresent = s.trim().isNotEmpty;
|
_messageIsPresent = s.trim().isNotEmpty;
|
||||||
|
_actionsShrunk = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
_commandsOverlay?.remove();
|
_commandsOverlay?.remove();
|
||||||
@@ -298,7 +319,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
child: Chip(
|
child: Chip(
|
||||||
backgroundColor: StreamChatTheme.of(context).accentColor,
|
backgroundColor: StreamChatTheme.of(context).accentColor,
|
||||||
label: Text(
|
label: Text(
|
||||||
chosenCommand?.name ?? "",
|
_chosenCommand?.name ?? "",
|
||||||
style: TextStyle(color: Colors.white),
|
style: TextStyle(color: Colors.white),
|
||||||
),
|
),
|
||||||
avatar: Icon(
|
avatar: Icon(
|
||||||
@@ -521,7 +542,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
void _setCommand(Command c) {
|
void _setCommand(Command c) {
|
||||||
textEditingController.clear();
|
textEditingController.clear();
|
||||||
setState(() {
|
setState(() {
|
||||||
chosenCommand = c;
|
_chosenCommand = c;
|
||||||
_commandEnabled = true;
|
_commandEnabled = true;
|
||||||
});
|
});
|
||||||
_commandsOverlay?.remove();
|
_commandsOverlay?.remove();
|
||||||
@@ -946,7 +967,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(_commandEnabled) {
|
if(_commandEnabled) {
|
||||||
text = '/${chosenCommand.name} ' + text;
|
text = '/${_chosenCommand.name} ' + text;
|
||||||
}
|
}
|
||||||
|
|
||||||
final attachments = List<_SendingAttachment>.from(_attachments);
|
final attachments = List<_SendingAttachment>.from(_attachments);
|
||||||
|
|||||||
Reference in New Issue
Block a user