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