|
|
import 'package:flutter/material.dart'; import 'package:repositories/app_api_domain/models/post_model.dart'; import 'package:sonnat/core/extensions/context_extension.dart'; import 'package:sonnat/core/utils/app_constants.dart';
class PostItemWidget extends StatelessWidget { final PostModel post;
const PostItemWidget({super.key, required this.post});
@override Widget build(BuildContext context) { final String? thumbnail = post.thumbnail; return Container( padding: EdgeInsets.symmetric( horizontal: context.width * 11 / AppConstants.instance.appWidth, vertical: context.width * 11 / AppConstants.instance.appWidth, ), decoration: BoxDecoration( color: const Color(0xffffffff), borderRadius: BorderRadius.circular(16), ), margin: EdgeInsets.only( left: context.width * 26 / AppConstants.instance.appWidth, right: context.width * 26 / AppConstants.instance.appWidth, bottom: context.height * 21 / AppConstants.instance.appHeight, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( height: context.height * 174 / AppConstants.instance.appHeight, decoration: const BoxDecoration( borderRadius: BorderRadius.only( topLeft: Radius.circular(16), topRight: Radius.circular(16), ), ), child: thumbnail == null ? Center( child: Icon( Icons.image_search, color: Colors.grey.withOpacity(0.5), size: 150, ), ) : Image.network( thumbnail, fit: BoxFit.cover, errorBuilder: (context, error, stackTrace) { return Center( child: Icon( Icons.image_search, color: Colors.grey.withOpacity(0.5), size: 150, ), ); }, ), ), SizedBox(height: context.height * 14 / AppConstants.instance.appHeight), Text( post.title, style: const TextStyle( color: Color(0xff222D4E), fontSize: 16, fontWeight: FontWeight.bold, ), ), SizedBox(height: context.height * 8 / AppConstants.instance.appHeight), Text( post.summary, style: const TextStyle( color: Color(0xff8990A1), fontSize: 13, ), textAlign: TextAlign.justify, ), SizedBox(height: context.height * 30 / AppConstants.instance.appHeight), Align( alignment: AlignmentDirectional.centerEnd, child: Text( post.publishDate, style: const TextStyle( color: Color(0xff8D95AB), fontSize: 11, fontWeight: FontWeight.bold, ), ), ), SizedBox(height: context.height * 7 / AppConstants.instance.appHeight), ], ), ); } }
|