2022-08-26 08:11:35 +00:00
|
|
|
import 'package:emojis/emoji.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import 'package:stackwallet/utilities/constants.dart';
|
|
|
|
import 'package:stackwallet/utilities/text_styles.dart';
|
2022-09-22 23:48:50 +00:00
|
|
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
class EmojiSelectSheet extends ConsumerWidget {
|
|
|
|
const EmojiSelectSheet({
|
|
|
|
Key? key,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final double horizontalPadding = 24;
|
|
|
|
final double emojiSize = 24;
|
|
|
|
final double minimumEmojiSpacing = 25;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
final size = MediaQuery.of(context).size;
|
|
|
|
final double maxHeight = size.height * 0.60;
|
|
|
|
final double availableWidth = size.width - (2 * horizontalPadding);
|
|
|
|
final int emojisPerRow =
|
|
|
|
((availableWidth - emojiSize) ~/ (emojiSize + minimumEmojiSpacing)) + 1;
|
|
|
|
|
|
|
|
final itemCount = Emoji.all().length;
|
|
|
|
|
|
|
|
return Container(
|
2022-09-21 21:59:52 +00:00
|
|
|
decoration: BoxDecoration(
|
2022-09-22 23:48:50 +00:00
|
|
|
color: Theme.of(context).extension<StackColors>()!.popupBG,
|
2022-09-21 21:59:52 +00:00
|
|
|
borderRadius: const BorderRadius.vertical(
|
2022-08-26 08:11:35 +00:00
|
|
|
top: Radius.circular(20),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: LimitedBox(
|
|
|
|
maxHeight: maxHeight,
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: horizontalPadding,
|
|
|
|
right: horizontalPadding,
|
|
|
|
top: 10,
|
|
|
|
bottom: 0,
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: [
|
|
|
|
Center(
|
|
|
|
child: Container(
|
|
|
|
decoration: BoxDecoration(
|
2022-09-22 23:48:50 +00:00
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textFieldDefaultBG,
|
2022-08-26 08:11:35 +00:00
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
Constants.size.circularBorderRadius,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
width: 60,
|
|
|
|
height: 4,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 36,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"Select emoji",
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.pageTitleH2(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
textAlign: TextAlign.left,
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 16,
|
|
|
|
),
|
|
|
|
Flexible(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Flexible(
|
|
|
|
child: GridView.builder(
|
|
|
|
itemCount: itemCount,
|
|
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
crossAxisCount: emojisPerRow,
|
|
|
|
),
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
final emoji = Emoji.all()[index];
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
Navigator.of(context).pop(emoji);
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(100),
|
|
|
|
color: Colors.transparent,
|
|
|
|
),
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: Text(emoji.char),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 24,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|