fix performance issues with new emoji picker
This commit is contained in:
parent
a0fa30e036
commit
3af38e615e
1 changed files with 100 additions and 104 deletions
|
|
@ -14,17 +14,7 @@ final class const EmojiPicker({
|
|||
super.key,
|
||||
}) extends HookConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) => Container(
|
||||
padding: .symmetric(horizontal: 16),
|
||||
constraints: .loose(.new(500, 700)),
|
||||
child: ref
|
||||
.watch(EmojiController.provider)
|
||||
.betterWhen(
|
||||
data: (categories) {
|
||||
final combined = categories.addAll(extraCategories);
|
||||
|
||||
return HookBuilder(
|
||||
builder: (context) {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final selectedCategory = useState<int?>(null);
|
||||
final scrollController = useScrollController();
|
||||
final listController = useMemoized(ListController.new);
|
||||
|
|
@ -46,6 +36,15 @@ final class const EmojiPicker({
|
|||
return () => listController.removeListener(onChange);
|
||||
}, [listController]);
|
||||
|
||||
return Container(
|
||||
padding: .symmetric(horizontal: 16),
|
||||
constraints: .loose(.new(500, 700)),
|
||||
child: ref
|
||||
.watch(EmojiController.provider)
|
||||
.betterWhen(
|
||||
data: (categories) {
|
||||
final combined = categories.addAll(extraCategories);
|
||||
|
||||
return Column(
|
||||
spacing: 4,
|
||||
children: [
|
||||
|
|
@ -98,24 +97,22 @@ final class const EmojiPicker({
|
|||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
DividerText(category.name),
|
||||
DefaultTextStyle(
|
||||
style: TextStyle(fontSize: 24),
|
||||
child: GridView(
|
||||
gridDelegate:
|
||||
const SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: 52,
|
||||
mainAxisExtent: 52,
|
||||
),
|
||||
Wrap(
|
||||
children: category.emojis
|
||||
.map(
|
||||
(emoji) => IconButton(
|
||||
onPressed: () {},
|
||||
icon: emoji.widget,
|
||||
icon: SizedBox.square(
|
||||
dimension: 36,
|
||||
child: FittedBox(
|
||||
fit: .contain,
|
||||
child: emoji.widget,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
|
|
@ -124,8 +121,7 @@ final class const EmojiPicker({
|
|||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue