- Create ReactionPicker component with 24 common emoji options - Show emoji grid in dialog with proper styling - Update PostActions to show picker instead of default heart - Add _showReactionPicker method with showDialog - Update ReactionStrip onAdd callback to use picker - Maintain full reaction functionality with user choice - Add proper styling with borders and shadows to picker
126 lines
3.9 KiB
Dart
126 lines
3.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import '../../theme/app_theme.dart';
|
|
|
|
class ReactionPicker extends StatefulWidget {
|
|
final Function(String) onReactionSelected;
|
|
final VoidCallback? onClosed;
|
|
|
|
const ReactionPicker({
|
|
super.key,
|
|
required this.onReactionSelected,
|
|
this.onClosed,
|
|
});
|
|
|
|
@override
|
|
State<ReactionPicker> createState() => _ReactionPickerState();
|
|
}
|
|
|
|
class _ReactionPickerState extends State<ReactionPicker> {
|
|
static const List<String> _commonReactions = [
|
|
'❤️', '👍', '😂', '😮', '😢', '😡',
|
|
'🎉', '🔥', '👏', '🙏', '💯', '🤔',
|
|
'😍', '🤣', '😊', '👌', '🙌', '💪',
|
|
'🎯', '⭐', '✨', '🌟', '💫', '☀️',
|
|
];
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Dialog(
|
|
backgroundColor: Colors.transparent,
|
|
child: Container(
|
|
padding: const EdgeInsets.all(20),
|
|
decoration: BoxDecoration(
|
|
color: AppTheme.cardSurface,
|
|
borderRadius: BorderRadius.circular(20),
|
|
border: Border.all(
|
|
color: AppTheme.navyBlue.withValues(alpha: 0.2),
|
|
width: 1,
|
|
),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withValues(alpha: 0.2),
|
|
blurRadius: 20,
|
|
offset: const Offset(0, 10),
|
|
),
|
|
],
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
// Header
|
|
Row(
|
|
children: [
|
|
Text(
|
|
'Add Reaction',
|
|
style: GoogleFonts.inter(
|
|
color: AppTheme.navyBlue,
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
const Spacer(),
|
|
IconButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
widget.onClosed?.call();
|
|
},
|
|
icon: Icon(
|
|
Icons.close,
|
|
color: AppTheme.textSecondary,
|
|
size: 20,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 16),
|
|
|
|
// Emoji grid
|
|
GridView.builder(
|
|
shrinkWrap: true,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 6,
|
|
crossAxisSpacing: 8,
|
|
mainAxisSpacing: 8,
|
|
childAspectRatio: 1,
|
|
),
|
|
itemCount: _commonReactions.length,
|
|
itemBuilder: (context, index) {
|
|
final emoji = _commonReactions[index];
|
|
return Material(
|
|
color: Colors.transparent,
|
|
child: InkWell(
|
|
onTap: () {
|
|
Navigator.of(context).pop();
|
|
widget.onReactionSelected(emoji);
|
|
},
|
|
borderRadius: BorderRadius.circular(12),
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: AppTheme.navyBlue.withValues(alpha: 0.05),
|
|
borderRadius: BorderRadius.circular(12),
|
|
border: Border.all(
|
|
color: AppTheme.navyBlue.withValues(alpha: 0.1),
|
|
width: 1,
|
|
),
|
|
),
|
|
child: Center(
|
|
child: Text(
|
|
emoji,
|
|
style: const TextStyle(fontSize: 24),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
const SizedBox(height: 16),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|