make picker a little more generic
This commit is contained in:
parent
f8d1b78282
commit
ddc83c4a4b
2 changed files with 17 additions and 11 deletions
|
|
@ -12,8 +12,10 @@ import "package:nexus/widgets/divider_text.dart";
|
|||
import "package:super_sliver_list/super_sliver_list.dart";
|
||||
|
||||
final class const EmojiPicker({
|
||||
final IList<EmojiCategory> extraCategories = const IList.empty(),
|
||||
final IList<EmojiCategory> prependCategories = const IList.empty(),
|
||||
final IList<EmojiCategory> appendCategories = const IList.empty(),
|
||||
required final FutureOr<void> Function(String value) onSelection,
|
||||
final bool allowFreeText = false,
|
||||
super.key,
|
||||
}) extends HookConsumerWidget {
|
||||
@override
|
||||
|
|
@ -59,7 +61,9 @@ final class const EmojiPicker({
|
|||
.betterWhen(
|
||||
data: (categories) {
|
||||
final combined = useMemoized(
|
||||
() => categories.addAll(extraCategories),
|
||||
() => prependCategories
|
||||
.addAll(categories)
|
||||
.addAll(appendCategories),
|
||||
);
|
||||
|
||||
return Column(
|
||||
|
|
@ -70,16 +74,17 @@ final class const EmojiPicker({
|
|||
leading: Icon(Icons.search),
|
||||
onChanged: (value) => search.value = value,
|
||||
trailing: [
|
||||
IconButton(
|
||||
onPressed: search.value.isEmpty
|
||||
? null
|
||||
: () async {
|
||||
Navigator.of(context).pop();
|
||||
if (allowFreeText)
|
||||
IconButton(
|
||||
onPressed: search.value.isEmpty
|
||||
? null
|
||||
: () async {
|
||||
Navigator.of(context).pop();
|
||||
|
||||
await onSelection(search.value);
|
||||
},
|
||||
icon: Icon(Icons.send),
|
||||
),
|
||||
await onSelection(search.value);
|
||||
},
|
||||
icon: Icon(Icons.send),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
|
|
|
|||
|
|
@ -247,6 +247,7 @@ final class const RoomChat({
|
|||
onSelection: (value) => notifier
|
||||
.sendReaction(value, event)
|
||||
.onError(showError),
|
||||
allowFreeText: true,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue