1import 'package:flutter/material.dart'; 2 3import '../constants/app_colors.dart'; 4import '../models/post.dart'; 5import '../utils/date_time_utils.dart'; 6import 'icons/animated_heart_icon.dart'; 7 8/// Post Action Bar 9/// 10/// Bottom bar with comment input and action buttons (vote, save, comment count). 11/// Displays: 12/// - Comment input field 13/// - Heart icon with vote count 14/// - Star icon with save count 15/// - Comment bubble icon with comment count 16class PostActionBar extends StatelessWidget { 17 const PostActionBar({ 18 required this.post, 19 this.onCommentTap, 20 this.onVoteTap, 21 this.onSaveTap, 22 this.isVoted = false, 23 this.isSaved = false, 24 super.key, 25 }); 26 27 final FeedViewPost post; 28 final VoidCallback? onCommentTap; 29 final VoidCallback? onVoteTap; 30 final VoidCallback? onSaveTap; 31 final bool isVoted; 32 final bool isSaved; 33 34 @override 35 Widget build(BuildContext context) { 36 return Container( 37 decoration: BoxDecoration( 38 color: AppColors.background, 39 border: Border( 40 top: BorderSide( 41 color: AppColors.backgroundSecondary, 42 width: 1, 43 ), 44 ), 45 ), 46 padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), 47 child: SafeArea( 48 top: false, 49 child: Row( 50 children: [ 51 // Comment input field 52 Expanded( 53 child: GestureDetector( 54 onTap: onCommentTap, 55 child: Container( 56 height: 40, 57 padding: const EdgeInsets.symmetric(horizontal: 12), 58 decoration: const BoxDecoration( 59 color: AppColors.backgroundSecondary, 60 borderRadius: BorderRadius.all(Radius.circular(20)), 61 ), 62 child: Row( 63 children: [ 64 Icon( 65 Icons.edit_outlined, 66 size: 16, 67 color: AppColors.textPrimary.withValues(alpha: 0.5), 68 ), 69 const SizedBox(width: 8), 70 Text( 71 'Comment', 72 style: TextStyle( 73 color: AppColors.textPrimary.withValues(alpha: 0.5), 74 fontSize: 14, 75 ), 76 ), 77 ], 78 ), 79 ), 80 ), 81 ), 82 const SizedBox(width: 16), 83 84 // Vote button with animated heart icon 85 GestureDetector( 86 onTap: onVoteTap, 87 child: Row( 88 mainAxisSize: MainAxisSize.min, 89 children: [ 90 AnimatedHeartIcon( 91 isLiked: isVoted, 92 color: AppColors.textPrimary.withValues(alpha: 0.7), 93 likedColor: const Color(0xFFFF0033), 94 size: 24, 95 ), 96 const SizedBox(width: 4), 97 Text( 98 DateTimeUtils.formatCount(post.post.stats.score), 99 style: TextStyle( 100 color: 101 isVoted 102 ? const Color(0xFFFF0033) 103 : AppColors.textPrimary.withValues(alpha: 0.7), 104 fontSize: 13, 105 fontWeight: FontWeight.w500, 106 ), 107 ), 108 ], 109 ), 110 ), 111 const SizedBox(width: 16), 112 113 // Save button with count (placeholder for now) 114 _ActionButton( 115 icon: isSaved ? Icons.bookmark : Icons.bookmark_border, 116 count: 0, // TODO: Add save count when backend supports it 117 color: isSaved ? AppColors.primary : null, 118 onTap: onSaveTap, 119 ), 120 const SizedBox(width: 16), 121 122 // Comment count button 123 _ActionButton( 124 icon: Icons.chat_bubble_outline, 125 count: post.post.stats.commentCount, 126 onTap: onCommentTap, 127 ), 128 ], 129 ), 130 ), 131 ); 132 } 133} 134 135/// Action button with icon and count 136class _ActionButton extends StatelessWidget { 137 const _ActionButton({ 138 required this.icon, 139 required this.count, 140 this.color, 141 this.onTap, 142 }); 143 144 final IconData icon; 145 final int count; 146 final Color? color; 147 final VoidCallback? onTap; 148 149 @override 150 Widget build(BuildContext context) { 151 final effectiveColor = 152 color ?? AppColors.textPrimary.withValues(alpha: 0.7); 153 154 return GestureDetector( 155 onTap: onTap, 156 child: Row( 157 mainAxisSize: MainAxisSize.min, 158 children: [ 159 Icon(icon, size: 24, color: effectiveColor), 160 const SizedBox(width: 4), 161 Text( 162 DateTimeUtils.formatCount(count), 163 style: TextStyle( 164 color: effectiveColor, 165 fontSize: 13, 166 fontWeight: FontWeight.w500, 167 ), 168 ), 169 ], 170 ), 171 ); 172 } 173}