stack_wallet/lib/widgets/emoji_select_sheet.dart

112 lines
3.7 KiB
Dart

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';
import 'package:stackwallet/utilities/theme/stack_theme.dart';
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(
decoration: BoxDecoration(
color: StackTheme.instance.color.popupBG,
borderRadius: const BorderRadius.vertical(
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(
color: StackTheme.instance.color.textFieldDefaultBG,
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
),
width: 60,
height: 4,
),
),
const SizedBox(
height: 36,
),
Text(
"Select emoji",
style: STextStyles.pageTitleH2,
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,
),
],
),
),
),
);
}
}