Sonnat Project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
3.3 KiB

1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
  1. import 'package:flutter/material.dart';
  2. import 'package:repositories/app_api_domain/models/post_model.dart';
  3. import 'package:sonnat/core/extensions/context_extension.dart';
  4. import 'package:sonnat/core/utils/app_constants.dart';
  5. class PostItemWidget extends StatelessWidget {
  6. final PostModel post;
  7. const PostItemWidget({super.key, required this.post});
  8. @override
  9. Widget build(BuildContext context) {
  10. final String? thumbnail = post.thumbnail;
  11. return Container(
  12. padding: EdgeInsets.symmetric(
  13. horizontal: context.width * 11 / AppConstants.instance.appWidth,
  14. vertical: context.width * 11 / AppConstants.instance.appWidth,
  15. ),
  16. decoration: BoxDecoration(
  17. color: const Color(0xffffffff),
  18. borderRadius: BorderRadius.circular(16),
  19. ),
  20. margin: EdgeInsets.only(
  21. left: context.width * 26 / AppConstants.instance.appWidth,
  22. right: context.width * 26 / AppConstants.instance.appWidth,
  23. bottom: context.height * 21 / AppConstants.instance.appHeight,
  24. ),
  25. child: Column(
  26. crossAxisAlignment: CrossAxisAlignment.start,
  27. children: [
  28. Container(
  29. height: context.height * 174 / AppConstants.instance.appHeight,
  30. decoration: const BoxDecoration(
  31. borderRadius: BorderRadius.only(
  32. topLeft: Radius.circular(16),
  33. topRight: Radius.circular(16),
  34. ),
  35. ),
  36. child: thumbnail == null
  37. ? Center(
  38. child: Icon(
  39. Icons.image_search,
  40. color: Colors.grey.withOpacity(0.5),
  41. size: 150,
  42. ),
  43. )
  44. : Image.network(
  45. thumbnail,
  46. fit: BoxFit.cover,
  47. errorBuilder: (context, error, stackTrace) {
  48. return Center(
  49. child: Icon(
  50. Icons.image_search,
  51. color: Colors.grey.withOpacity(0.5),
  52. size: 150,
  53. ),
  54. );
  55. },
  56. ),
  57. ),
  58. SizedBox(height: context.height * 14 / AppConstants.instance.appHeight),
  59. Text(
  60. post.title,
  61. style: const TextStyle(
  62. color: Color(0xff222D4E),
  63. fontSize: 16,
  64. fontWeight: FontWeight.bold,
  65. ),
  66. ),
  67. SizedBox(height: context.height * 8 / AppConstants.instance.appHeight),
  68. Text(
  69. post.summary,
  70. style: const TextStyle(
  71. color: Color(0xff8990A1),
  72. fontSize: 13,
  73. ),
  74. textAlign: TextAlign.justify,
  75. ),
  76. SizedBox(height: context.height * 30 / AppConstants.instance.appHeight),
  77. Align(
  78. alignment: AlignmentDirectional.centerEnd,
  79. child: Text(
  80. post.publishDate,
  81. style: const TextStyle(
  82. color: Color(0xff8D95AB),
  83. fontSize: 11,
  84. fontWeight: FontWeight.bold,
  85. ),
  86. ),
  87. ),
  88. SizedBox(height: context.height * 7 / AppConstants.instance.appHeight),
  89. ],
  90. ),
  91. );
  92. }
  93. }