added new overlays and docs

This commit is contained in:
Deven Joshi
2021-09-07 14:31:48 +05:30
parent ae2e8b740f
commit 0af7b1a0e6
2 changed files with 80 additions and 46 deletions
@@ -475,7 +475,7 @@ class MessageInputState extends State<MessageInput> {
_emojiOverlay != null ||
_mentionsOverlay != null,
overlayBuilder: (context, offset) {
late Widget child;
late Widget? child;
if (_commandsOverlay != null) {
child = _buildCommandsOverlayEntry();
@@ -487,7 +487,7 @@ class MessageInputState extends State<MessageInput> {
return CenterAbout(
position: Offset(offset.dx, offset.dy),
child: child,
child: child ?? const SizedBox(),
);
},
child: child,
@@ -922,7 +922,7 @@ class MessageInputState extends State<MessageInput> {
}
}
Widget _buildCommandsOverlayEntry() {
Widget? _buildCommandsOverlayEntry() {
final text = textEditingController.text.trimLeft();
final commands = StreamChannel.of(context)
.channel
@@ -931,6 +931,11 @@ class MessageInputState extends State<MessageInput> {
.where((c) => c.name.contains(text.replaceFirst('/', '')))
.toList() ??
[];
if (commands.isEmpty) {
return null;
}
final size = MediaQuery.of(context).size;
return Padding(
@@ -1312,7 +1317,7 @@ class MessageInputState extends State<MessageInput> {
}
}
Widget _buildMentionsOverlayEntry() {
Widget? _buildMentionsOverlayEntry() {
final splits = textEditingController.text
.substring(0, textEditingController.value.selection.start)
.split('@');
@@ -1332,6 +1337,10 @@ class MessageInputState extends State<MessageInput> {
.toList() ??
[];
if (members.isEmpty) {
return null;
}
// ignore: cast_nullable_to_non_nullable
final renderBox = context.findRenderObject() as RenderBox;
final size = renderBox.size;
@@ -1410,7 +1419,7 @@ class MessageInputState extends State<MessageInput> {
);
}
Widget _buildEmojiOverlay() {
Widget? _buildEmojiOverlay() {
final splits = textEditingController.text
.substring(0, textEditingController.value.selection.start)
.split(':');
@@ -1421,6 +1430,10 @@ class MessageInputState extends State<MessageInput> {
.map(Emoji.byName)
.where((e) => e != null);
if (emojis.isEmpty) {
return null;
}
// ignore: cast_nullable_to_non_nullable
final renderBox = context.findRenderObject() as RenderBox;
final size = renderBox.size;