stack_wallet/lib/widgets/emoji_select_sheet.dart

114 lines
3.8 KiB
Dart
Raw Normal View History

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/cfcolors.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/text_styles.dart';
2022-09-21 00:46:07 +00:00
import 'package:stackwallet/utilities/theme/stack_theme.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(
decoration: const BoxDecoration(
color: CFColors.white,
borderRadius: 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(
2022-09-21 00:46:07 +00:00
color: StackTheme.instance.color.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",
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,
),
],
),
),
),
);
}
}