forked from Nexus/nexus
WIP: New Emoji Picker
This commit is contained in:
parent
49b94a2e34
commit
941e1c0e69
7 changed files with 543 additions and 140 deletions
|
|
@ -14,8 +14,8 @@ import "package:nexus/models/event.dart";
|
|||
import "package:nexus/models/relation_type.dart";
|
||||
import "package:nexus/widgets/composer/mention_overlay.dart";
|
||||
import "package:nexus/widgets/composer/relation_preview.dart";
|
||||
import "package:nexus/widgets/emoji_picker_button.dart";
|
||||
import "package:nexus/main.dart";
|
||||
import "package:nexus/widgets/emote_picker.dart";
|
||||
|
||||
class Composer extends HookConsumerWidget {
|
||||
final String roomId;
|
||||
|
|
@ -123,10 +123,35 @@ class Composer extends HookConsumerWidget {
|
|||
),
|
||||
)
|
||||
? [
|
||||
EmojiPickerButton(
|
||||
context: context,
|
||||
onSelection: (_) => node?.requestFocus(),
|
||||
controller: controller.value,
|
||||
IconButton(
|
||||
icon: Icon(Icons.emoji_emotions),
|
||||
tooltip: "Insert emoji",
|
||||
onPressed: () {
|
||||
showEmotePickerBottomSheet(
|
||||
context: context,
|
||||
roomId: roomId,
|
||||
onSelect: (emojiId) {
|
||||
final textController = controller.value;
|
||||
final selection = textController.selection;
|
||||
final newText = textController.text
|
||||
.replaceRange(
|
||||
selection.start,
|
||||
selection.end,
|
||||
emojiId,
|
||||
);
|
||||
|
||||
textController.value = TextEditingValue(
|
||||
text: newText,
|
||||
selection: TextSelection.collapsed(
|
||||
offset:
|
||||
selection.start + emojiId.length,
|
||||
),
|
||||
);
|
||||
|
||||
node?.requestFocus();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
PopupMenuButton(
|
||||
tooltip: "Add media",
|
||||
|
|
|
|||
Loading…
Reference in a new issue