2025-12-30 15:02:51 +05:30

118 lines
4.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:socialbuddy_mobile/core/constants/colors.dart';
class PostsScreen extends StatelessWidget {
const PostsScreen({super.key});
@override
Widget build(BuildContext context) {
// Dummy posts data
final List<Map<String, String>> posts = List.generate(10, (index) => {
'image': 'https://picsum.photos/500/500?random=$index',
'caption': 'This is a sample post caption for Social Buddy #social #marketing',
'likes': '${(index + 1) * 12}',
'comments': '${index * 3}',
'type': index % 3 == 0 ? 'VIDEO' : 'IMAGE',
});
return Scaffold(
backgroundColor: AppColors.darkBg,
body: GridView.builder(
padding: const EdgeInsets.all(16),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 0.65,
crossAxisSpacing: 16,
mainAxisSpacing: 16,
),
itemCount: posts.length,
itemBuilder: (context, index) {
final post = posts[index];
return Container(
decoration: BoxDecoration(
color: AppColors.cardBg,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: Colors.white.withOpacity(0.05)),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Stack(
children: [
ClipRRect(
borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
child: Image.network(
post['image']!,
fit: BoxFit.cover,
width: double.infinity,
height: double.infinity,
),
),
Positioned(
top: 8,
right: 8,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
decoration: BoxDecoration(
color: Colors.black54,
borderRadius: BorderRadius.circular(4),
),
child: Text(
post['type']!,
style: const TextStyle(color: Colors.white, fontSize: 8),
),
),
),
],
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
post['caption']!,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: GoogleFonts.nunito(fontSize: 12, color: Colors.white),
),
const SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
const Icon(Icons.favorite, size: 14, color: AppColors.danger),
const SizedBox(width: 4),
Text(post['likes']!, style: const TextStyle(fontSize: 10, color: Colors.white70)),
],
),
Row(
children: [
const Icon(Icons.comment, size: 14, color: Colors.blueAccent),
const SizedBox(width: 4),
Text(post['comments']!, style: const TextStyle(fontSize: 10, color: Colors.white70)),
],
),
],
),
],
),
),
],
),
);
},
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
backgroundColor: AppColors.primary,
child: const Icon(Icons.add, color: Colors.white),
),
);
}
}