feat: Fixed commands (removed giphy hardcode)
This commit is contained in:
+17
-18
@@ -166,9 +166,11 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
bool _inputEnabled = true;
|
bool _inputEnabled = true;
|
||||||
bool _messageIsPresent = false;
|
bool _messageIsPresent = false;
|
||||||
bool _typingStarted = false;
|
bool _typingStarted = false;
|
||||||
bool _giphyEnabled = false;
|
bool _commandEnabled = false;
|
||||||
OverlayEntry _commandsOverlay, _mentionsOverlay;
|
OverlayEntry _commandsOverlay, _mentionsOverlay;
|
||||||
|
|
||||||
|
Command chosenCommand;
|
||||||
|
|
||||||
/// The editing controller passed to the input TextField
|
/// The editing controller passed to the input TextField
|
||||||
TextEditingController textEditingController;
|
TextEditingController textEditingController;
|
||||||
|
|
||||||
@@ -200,7 +202,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
direction: Axis.horizontal,
|
direction: Axis.horizontal,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (!_giphyEnabled)
|
if (!_commandEnabled)
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
@@ -285,18 +287,18 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
textAlignVertical: TextAlignVertical.center,
|
textAlignVertical: TextAlignVertical.center,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: 'Write a message',
|
hintText: 'Write a message',
|
||||||
prefixText: _giphyEnabled ? null : ' ',
|
prefixText: _commandEnabled ? null : ' ',
|
||||||
border: OutlineInputBorder(
|
border: OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(32),
|
borderRadius: BorderRadius.circular(32),
|
||||||
),
|
),
|
||||||
contentPadding: EdgeInsets.all(4),
|
contentPadding: EdgeInsets.all(8),
|
||||||
prefixIcon: _giphyEnabled
|
prefixIcon: _commandEnabled
|
||||||
? Padding(
|
? Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||||
child: Chip(
|
child: Chip(
|
||||||
backgroundColor: StreamChatTheme.of(context).accentColor,
|
backgroundColor: StreamChatTheme.of(context).accentColor,
|
||||||
label: Text(
|
label: Text(
|
||||||
'GIPHY',
|
chosenCommand?.name ?? "",
|
||||||
style: TextStyle(color: Colors.white),
|
style: TextStyle(color: Colors.white),
|
||||||
),
|
),
|
||||||
avatar: Icon(
|
avatar: Icon(
|
||||||
@@ -306,12 +308,12 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
suffixIcon: _giphyEnabled
|
suffixIcon: _commandEnabled
|
||||||
? IconButton(
|
? IconButton(
|
||||||
icon: Icon(Icons.cancel_outlined),
|
icon: Icon(Icons.cancel_outlined),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_giphyEnabled = false;
|
_commandEnabled = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -517,12 +519,9 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _setCommand(Command c) {
|
void _setCommand(Command c) {
|
||||||
textEditingController.value = TextEditingValue(
|
setState(() {
|
||||||
text: '/${c.name} ',
|
chosenCommand = c;
|
||||||
selection: TextSelection.collapsed(
|
});
|
||||||
offset: c.name.length + 2,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
_commandsOverlay?.remove();
|
_commandsOverlay?.remove();
|
||||||
_commandsOverlay = null;
|
_commandsOverlay = null;
|
||||||
}
|
}
|
||||||
@@ -655,7 +654,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_giphyEnabled = true;
|
_commandEnabled = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -940,8 +939,8 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_giphyEnabled) {
|
if(_commandEnabled) {
|
||||||
text = '/giphy ' + text;
|
text = '/${chosenCommand.args} ' + text;
|
||||||
}
|
}
|
||||||
|
|
||||||
final attachments = List<_SendingAttachment>.from(_attachments);
|
final attachments = List<_SendingAttachment>.from(_attachments);
|
||||||
@@ -952,7 +951,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_messageIsPresent = false;
|
_messageIsPresent = false;
|
||||||
_typingStarted = false;
|
_typingStarted = false;
|
||||||
_giphyEnabled = false;
|
_commandEnabled = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
_commandsOverlay?.remove();
|
_commandsOverlay?.remove();
|
||||||
|
|||||||
Reference in New Issue
Block a user