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";
|
import "package:super_sliver_list/super_sliver_list.dart";
|
||||||
|
|
||||||
final class const EmojiPicker({
|
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,
|
required final FutureOr<void> Function(String value) onSelection,
|
||||||
|
final bool allowFreeText = false,
|
||||||
super.key,
|
super.key,
|
||||||
}) extends HookConsumerWidget {
|
}) extends HookConsumerWidget {
|
||||||
@override
|
@override
|
||||||
|
|
@ -59,7 +61,9 @@ final class const EmojiPicker({
|
||||||
.betterWhen(
|
.betterWhen(
|
||||||
data: (categories) {
|
data: (categories) {
|
||||||
final combined = useMemoized(
|
final combined = useMemoized(
|
||||||
() => categories.addAll(extraCategories),
|
() => prependCategories
|
||||||
|
.addAll(categories)
|
||||||
|
.addAll(appendCategories),
|
||||||
);
|
);
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
|
|
@ -70,16 +74,17 @@ final class const EmojiPicker({
|
||||||
leading: Icon(Icons.search),
|
leading: Icon(Icons.search),
|
||||||
onChanged: (value) => search.value = value,
|
onChanged: (value) => search.value = value,
|
||||||
trailing: [
|
trailing: [
|
||||||
IconButton(
|
if (allowFreeText)
|
||||||
onPressed: search.value.isEmpty
|
IconButton(
|
||||||
? null
|
onPressed: search.value.isEmpty
|
||||||
: () async {
|
? null
|
||||||
Navigator.of(context).pop();
|
: () async {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
|
||||||
await onSelection(search.value);
|
await onSelection(search.value);
|
||||||
},
|
},
|
||||||
icon: Icon(Icons.send),
|
icon: Icon(Icons.send),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
|
|
|
||||||
|
|
@ -247,6 +247,7 @@ final class const RoomChat({
|
||||||
onSelection: (value) => notifier
|
onSelection: (value) => notifier
|
||||||
.sendReaction(value, event)
|
.sendReaction(value, event)
|
||||||
.onError(showError),
|
.onError(showError),
|
||||||
|
allowFreeText: true,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue