- lib/presentation : pages legacy (explore/network, notifications) avec BLoC - lib/shared/design_system : UnionFlow Design System v2 (tokens, components) + MD3 tokens + module_colors par feature - lib/shared/widgets : widgets transversaux (core_card, core_shimmer, error_widget, loading_widget, powered_by_lions_dev, etc.) - lib/shared/constants + utils
124 lines
3.9 KiB
Dart
124 lines
3.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../design_system/tokens/app_colors.dart';
|
|
import '../design_system/tokens/app_typography.dart';
|
|
|
|
/// UnionFlow Mobile - Composant DRY : ActionRow
|
|
/// Centralise les interactions (J'aime, Commenter, Partager, etc.) sous une barre compacte.
|
|
class ActionRow extends StatelessWidget {
|
|
final int? likesCount;
|
|
final int? commentsCount;
|
|
final VoidCallback? onLike;
|
|
final VoidCallback? onComment;
|
|
final VoidCallback? onShare;
|
|
final bool isLiked; // Permet de teinter l'icône Like
|
|
|
|
// Peut être personnalisé pour des actions spécifiques (ex: Payer)
|
|
final String? customActionLabel;
|
|
final VoidCallback? onCustomAction;
|
|
final IconData? customActionIcon;
|
|
|
|
const ActionRow({
|
|
Key? key,
|
|
this.likesCount,
|
|
this.commentsCount,
|
|
this.onLike,
|
|
this.onComment,
|
|
this.onShare,
|
|
this.isLiked = false,
|
|
this.customActionLabel,
|
|
this.onCustomAction,
|
|
this.customActionIcon,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
|
final iconColor = isDark ? AppColors.textSecondaryDark : AppColors.textSecondary;
|
|
|
|
return Padding(
|
|
padding: const EdgeInsets.only(top: 8.0),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
// Actions standards (Like/Comment/Share)
|
|
Row(
|
|
children: [
|
|
if (onLike != null)
|
|
_buildActionIcon(
|
|
icon: isLiked ? Icons.favorite : Icons.favorite_border,
|
|
color: isLiked ? AppColors.error : iconColor,
|
|
count: likesCount,
|
|
onTap: onLike!,
|
|
),
|
|
if (onLike != null && onComment != null) const SizedBox(width: 24),
|
|
if (onComment != null)
|
|
_buildActionIcon(
|
|
icon: Icons.chat_bubble_outline,
|
|
color: iconColor,
|
|
count: commentsCount,
|
|
onTap: onComment!,
|
|
),
|
|
if (onComment != null && onShare != null) const SizedBox(width: 24),
|
|
if (onShare != null)
|
|
_buildActionIcon(
|
|
icon: Icons.share_outlined,
|
|
color: iconColor,
|
|
onTap: onShare!,
|
|
),
|
|
],
|
|
),
|
|
|
|
// Action personnalisée à droite (ex: Payer la cotisation)
|
|
if (onCustomAction != null)
|
|
GestureDetector(
|
|
onTap: onCustomAction,
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.primary.withOpacity(0.1),
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
if (customActionIcon != null) ...[
|
|
Icon(customActionIcon, size: 14, color: AppColors.primary),
|
|
const SizedBox(width: 4),
|
|
],
|
|
Text(
|
|
customActionLabel ?? '',
|
|
style: AppTypography.badgeText.copyWith(color: AppColors.primary),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildActionIcon({
|
|
required IconData icon,
|
|
required Color color,
|
|
required VoidCallback onTap,
|
|
int? count,
|
|
}) {
|
|
return GestureDetector(
|
|
onTap: onTap,
|
|
behavior: HitTestBehavior.opaque,
|
|
child: Row(
|
|
children: [
|
|
Icon(icon, size: 16, color: color),
|
|
if (count != null && count > 0) ...[
|
|
const SizedBox(width: 4),
|
|
Text(
|
|
count.toString(),
|
|
style: AppTypography.subtitleSmall.copyWith(color: color),
|
|
),
|
|
]
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|