···
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
-
import 'package:flutter/services.dart';
-
import 'package:provider/provider.dart';
import '../constants/app_colors.dart';
import '../models/post.dart';
-
import '../providers/auth_provider.dart';
-
import '../providers/vote_provider.dart';
import '../utils/date_time_utils.dart';
-
import 'icons/animated_heart_icon.dart';
-
import 'icons/reply_icon.dart';
-
import 'icons/share_icon.dart';
-
import 'sign_in_dialog.dart';
/// Post card widget for displaying feed posts
···
// Community and author info
-
// Community avatar placeholder
-
decoration: BoxDecoration(
-
color: AppColors.primary,
-
borderRadius: BorderRadius.circular(4),
-
post.post.community.name[0].toUpperCase(),
-
style: const TextStyle(
-
color: AppColors.textPrimary,
-
fontWeight: FontWeight.bold,
const SizedBox(width: 8),
···
// Reduced spacing before action buttons
const SizedBox(height: 4),
-
mainAxisAlignment: MainAxisAlignment.end,
-
// TODO: Handle share interaction with backend
-
debugPrint('Share button tapped for post');
-
// Increased padding for better touch targets
-
padding: const EdgeInsets.symmetric(
-
color: AppColors.textPrimary.withValues(alpha: 0.6),
-
const SizedBox(width: 8),
-
// TODO: Navigate to post detail/comments screen
-
debugPrint('Comment button tapped for post');
-
// Increased padding for better touch targets
-
padding: const EdgeInsets.symmetric(
-
mainAxisSize: MainAxisSize.min,
-
color: AppColors.textPrimary.withValues(alpha: 0.6),
-
const SizedBox(width: 5),
-
DateTimeUtils.formatCount(
-
post.post.stats.commentCount,
-
color: AppColors.textPrimary.withValues(alpha: 0.6),
-
const SizedBox(width: 8),
-
Consumer<VoteProvider>(
-
builder: (context, voteProvider, child) {
-
final isLiked = voteProvider.isLiked(post.post.uri);
-
final adjustedScore = voteProvider.getAdjustedScore(
-
// Check authentication
-
final authProvider = context.read<AuthProvider>();
-
if (!authProvider.isAuthenticated) {
-
final shouldSignIn = await SignInDialog.show(
-
message: 'You need to sign in to like posts.',
-
if ((shouldSignIn ?? false) && context.mounted) {
-
// TODO: Navigate to sign-in screen
-
debugPrint('Navigate to sign-in screen');
-
// Light haptic feedback on both like and unlike
-
await HapticFeedback.lightImpact();
-
// Toggle vote with optimistic update
-
await voteProvider.toggleVote(
-
postUri: post.post.uri,
-
postCid: post.post.cid,
-
} on Exception catch (e) {
-
debugPrint('Failed to toggle vote: $e');
-
// TODO: Show error snackbar
-
// Increased padding for better touch targets
-
padding: const EdgeInsets.symmetric(
-
mainAxisSize: MainAxisSize.min,
-
color: AppColors.textPrimary
-
.withValues(alpha: 0.6),
-
likedColor: const Color(0xFFFF0033),
-
const SizedBox(width: 5),
-
DateTimeUtils.formatCount(adjustedScore),
-
color: AppColors.textPrimary
-
.withValues(alpha: 0.6),
···
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import '../constants/app_colors.dart';
import '../models/post.dart';
import '../utils/date_time_utils.dart';
+
import 'external_link_bar.dart';
+
import 'post_card_actions.dart';
/// Post card widget for displaying feed posts
···
// Community and author info
+
_buildCommunityAvatar(post.post.community),
const SizedBox(width: 8),
···
+
// External link (if present)
+
if (post.post.embed?.external != null) ...[
+
const SizedBox(height: 8),
+
ExternalLinkBar(embed: post.post.embed!.external!),
// Reduced spacing before action buttons
const SizedBox(height: 4),
+
PostCardActions(post: post),
+
/// Builds the community avatar widget
+
Widget _buildCommunityAvatar(CommunityRef community) {
+
if (community.avatar != null && community.avatar!.isNotEmpty) {
+
// Show real community avatar
+
borderRadius: BorderRadius.circular(4),
+
child: CachedNetworkImage(
+
imageUrl: community.avatar!,
+
placeholder: (context, url) => _buildFallbackAvatar(community),
+
errorWidget: (context, url, error) => _buildFallbackAvatar(community),
+
// Fallback to letter placeholder
+
return _buildFallbackAvatar(community);
+
/// Builds a fallback avatar with the first letter of community name
+
Widget _buildFallbackAvatar(CommunityRef community) {
+
decoration: BoxDecoration(
+
color: AppColors.primary,
+
borderRadius: BorderRadius.circular(4),
+
community.name[0].toUpperCase(),
+
style: const TextStyle(
+
color: AppColors.textPrimary,
+
fontWeight: FontWeight.bold,