sojorn/sojorn_app/lib/widgets/chain_quote_widget.dart
Patrick Britton 3c4680bdd7 Initial commit: Complete threaded conversation system with inline replies
**Major Features Added:**
- **Inline Reply System**: Replace compose screen with inline reply boxes
- **Thread Navigation**: Parent/child navigation with jump functionality
- **Chain Flow UI**: Reply counts, expand/collapse animations, visual hierarchy
- **Enhanced Animations**: Smooth transitions, hover effects, micro-interactions

 **Frontend Changes:**
- **ThreadedCommentWidget**: Complete rewrite with animations and navigation
- **ThreadNode Model**: Added parent references and descendant counting
- **ThreadedConversationScreen**: Integrated navigation handlers
- **PostDetailScreen**: Replaced with threaded conversation view
- **ComposeScreen**: Added reply indicators and context
- **PostActions**: Fixed visibility checks for chain buttons

 **Backend Changes:**
- **API Route**: Added /posts/:id/thread endpoint
- **Post Repository**: Include allow_chain and visibility fields in feed
- **Thread Handler**: Support for fetching post chains

 **UI/UX Improvements:**
- **Reply Context**: Clear indication when replying to specific posts
- **Character Counting**: 500 character limit with live counter
- **Visual Hierarchy**: Depth-based indentation and styling
- **Smooth Animations**: SizeTransition, FadeTransition, hover states
- **Chain Navigation**: Parent/child buttons with visual feedback

 **Technical Enhancements:**
- **Animation Controllers**: Proper lifecycle management
- **State Management**: Clean separation of concerns
- **Navigation Callbacks**: Reusable navigation system
- **Error Handling**: Graceful fallbacks and user feedback

This creates a Reddit-style threaded conversation experience with smooth
animations, inline replies, and intuitive navigation between posts in a chain.
2026-01-30 07:40:19 -06:00

159 lines
5.4 KiB
Dart

import 'package:flutter/material.dart';
import '../models/post.dart';
import '../theme/app_theme.dart';
import 'media/signed_media_image.dart';
class ChainQuoteWidget extends StatelessWidget {
final PostPreview parent;
final VoidCallback? onTap;
const ChainQuoteWidget({
super.key,
required this.parent,
this.onTap,
});
@override
Widget build(BuildContext context) {
final handle = parent.author?.handle ?? 'unknown';
final displayName = parent.author?.displayName ?? 'Unknown';
final avatarUrl = parent.author?.avatarUrl;
final createdAt = _formatTime(parent.createdAt);
final avatarColor = _getAvatarColor(handle);
return Padding(
padding: const EdgeInsets.only(
bottom: AppTheme.spacingSm,
left: AppTheme.spacingMd,
right: AppTheme.spacingMd,
),
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
child: Container(
// Flat design - NO box, NO background, NO border
// Looks exactly like a regular post
padding: const EdgeInsets.all(AppTheme.spacingMd),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
// 1. Header Row (Avatar + Names)
Row(
children: [
// Micro-Avatar
Container(
width: 20,
height: 20,
decoration: BoxDecoration(
color: avatarColor,
borderRadius: BorderRadius.circular(6),
),
child: avatarUrl != null && avatarUrl.isNotEmpty
? ClipRRect(
borderRadius: BorderRadius.circular(5.5),
child: SignedMediaImage(
url: avatarUrl,
width: 20,
height: 20,
fit: BoxFit.cover,
),
)
: Center(
child: Text(
handle.isNotEmpty
? handle[0].toUpperCase()
: '?',
style: const TextStyle(
color: Colors.white,
fontSize: 10,
fontWeight: FontWeight.bold,
),
),
),
),
const SizedBox(width: 8),
// Display Name (Bold, Official)
Flexible(
child: Text(
displayName,
overflow: TextOverflow.ellipsis,
style: AppTheme.labelMedium.copyWith(
color: AppTheme.textPrimary,
fontWeight: FontWeight.w700, // Punchier
),
),
),
const SizedBox(width: 4),
// Handle (Muted)
Text(
'@$handle',
style: AppTheme.labelSmall.copyWith(
color: AppTheme.textTertiary,
fontWeight: FontWeight.w400,
),
),
// Separator dot
Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Text(
'·',
style: AppTheme.labelSmall.copyWith(
color: AppTheme.textTertiary,
),
),
),
// Time
Text(
createdAt,
style: AppTheme.labelSmall.copyWith(
color: AppTheme.textTertiary,
),
),
],
),
const SizedBox(height: 8),
// 2. Body Text - Neutral color for content
Text(
parent.body,
maxLines: 3,
overflow: TextOverflow.ellipsis,
style: AppTheme.bodyMedium.copyWith(
fontSize: 15,
height: 1.5,
color: AppTheme.postContentLight,
),
),
],
),
),
),
),
);
}
// Consistent Avatar Coloring
Color _getAvatarColor(String handle) {
if (handle.isEmpty) return AppTheme.textDisabled;
final hash = handle.hashCode;
final hue = (hash % 360).toDouble();
return HSLColor.fromAHSL(1.0, hue, 0.45, 0.55).toColor();
}
static String _formatTime(DateTime time) {
final now = DateTime.now();
final diff = now.difference(time);
if (diff.inMinutes < 60) return '${diff.inMinutes}m';
if (diff.inHours < 24) return '${diff.inHours}h';
return '${diff.inDays}d';
}
}