fix performance and highlight text
This commit is contained in:
@@ -1 +1 @@
|
|||||||
bdf1751976c4ee1e2ef7638eabcfd1ea
|
bb5f9103d9045cd6244bcae1f5f343e5
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
name: example
|
name: example
|
||||||
description: A new Flutter project.
|
description: A new Flutter project.
|
||||||
version: 1.0.39+41
|
version: 1.0.40+42
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.2.2 <3.0.0"
|
sdk: ">=2.2.2 <3.0.0"
|
||||||
|
|||||||
+17
-21
@@ -7,7 +7,6 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
|
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
|
||||||
import 'package:fuzzy/fuzzy.dart';
|
|
||||||
import 'package:http_parser/http_parser.dart';
|
import 'package:http_parser/http_parser.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
import 'package:mime/mime.dart';
|
import 'package:mime/mime.dart';
|
||||||
@@ -15,6 +14,7 @@ import 'package:stream_chat/stream_chat.dart';
|
|||||||
import 'package:stream_chat_flutter/src/message_list_view.dart';
|
import 'package:stream_chat_flutter/src/message_list_view.dart';
|
||||||
import 'package:stream_chat_flutter/src/stream_chat_theme.dart';
|
import 'package:stream_chat_flutter/src/stream_chat_theme.dart';
|
||||||
import 'package:stream_chat_flutter/src/user_avatar.dart';
|
import 'package:stream_chat_flutter/src/user_avatar.dart';
|
||||||
|
import 'package:substring_highlight/substring_highlight.dart';
|
||||||
|
|
||||||
import '../stream_chat_flutter.dart';
|
import '../stream_chat_flutter.dart';
|
||||||
import 'stream_channel.dart';
|
import 'stream_channel.dart';
|
||||||
@@ -170,7 +170,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
bool _typingStarted = false;
|
bool _typingStarted = false;
|
||||||
bool _commandEnabled = false;
|
bool _commandEnabled = false;
|
||||||
OverlayEntry _commandsOverlay, _mentionsOverlay, _emojiOverlay;
|
OverlayEntry _commandsOverlay, _mentionsOverlay, _emojiOverlay;
|
||||||
Fuzzy<String> _emojiFuse;
|
Iterable<String> _emojiNames;
|
||||||
|
|
||||||
Command _chosenCommand;
|
Command _chosenCommand;
|
||||||
bool _actionsShrunk = false;
|
bool _actionsShrunk = false;
|
||||||
@@ -403,8 +403,6 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
0,
|
0,
|
||||||
textEditingController.selection.start,
|
textEditingController.selection.start,
|
||||||
)
|
)
|
||||||
.split(' ')
|
|
||||||
.last
|
|
||||||
.contains(':'))) {
|
.contains(':'))) {
|
||||||
final textToSelection = textEditingController.text
|
final textToSelection = textEditingController.text
|
||||||
.substring(0, textEditingController.value.selection.start);
|
.substring(0, textEditingController.value.selection.start);
|
||||||
@@ -676,11 +674,8 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final emojis = _emojiFuse
|
final emojis =
|
||||||
.search(query)
|
_emojiNames.where((e) => e.contains(query)).map((e) => Emoji.byName(e));
|
||||||
.map((e) => Emoji.byName(e.item))
|
|
||||||
.where((e) => e != null)
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
if (emojis.isEmpty) {
|
if (emojis.isEmpty) {
|
||||||
return null;
|
return null;
|
||||||
@@ -743,14 +738,19 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final emoji = emojis[i - 1];
|
final emoji = emojis.elementAt(i - 1);
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(
|
title: SubstringHighlight(
|
||||||
"${emoji.char} ${emoji.name.replaceAll('_', ' ')}",
|
text: "${emoji.char} ${emoji.name.replaceAll('_', ' ')}",
|
||||||
style: TextStyle(
|
term: query,
|
||||||
fontWeight: FontWeight.bold,
|
textStyleHighlight:
|
||||||
fontSize: 14.5,
|
Theme.of(context).textTheme.headline6.copyWith(
|
||||||
),
|
fontSize: 14.5,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
textStyle: Theme.of(context).textTheme.headline6.copyWith(
|
||||||
|
fontSize: 14.5,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
_chooseEmoji(splits, emoji);
|
_chooseEmoji(splits, emoji);
|
||||||
@@ -1334,11 +1334,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
_emojiFuse = Fuzzy<String>(Emoji.all().map((e) => e.name).toList(),
|
_emojiNames = Emoji.all().map((e) => e.name);
|
||||||
options: FuzzyOptions(
|
|
||||||
matchAllTokens: true,
|
|
||||||
tokenize: true,
|
|
||||||
));
|
|
||||||
|
|
||||||
if (!kIsWeb) {
|
if (!kIsWeb) {
|
||||||
_keyboardListener = KeyboardVisibility.onChange.listen((visible) {
|
_keyboardListener = KeyboardVisibility.onChange.listen((visible) {
|
||||||
|
|||||||
+1
-1
@@ -27,9 +27,9 @@ dependencies:
|
|||||||
stream_chat: ^0.2.10+1
|
stream_chat: ^0.2.10+1
|
||||||
emojis: ^0.9.3
|
emojis: ^0.9.3
|
||||||
mime: ^0.9.6+3
|
mime: ^0.9.6+3
|
||||||
fuzzy: ^0.2.3
|
|
||||||
visibility_detector: ^0.1.5
|
visibility_detector: ^0.1.5
|
||||||
http_parser: ^3.1.4
|
http_parser: ^3.1.4
|
||||||
|
substring_highlight: ^0.1.2
|
||||||
flutter_slidable: ^0.5.4
|
flutter_slidable: ^0.5.4
|
||||||
carousel_slider: ^2.2.1
|
carousel_slider: ^2.2.1
|
||||||
clipboard: ^0.1.2+8
|
clipboard: ^0.1.2+8
|
||||||
|
|||||||
Reference in New Issue
Block a user