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.

153 lines
5.5 KiB

  1. import 'package:cached_network_image/cached_network_image.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:shimmer/shimmer.dart';
  4. import 'package:sonnat/core/extensions/context_extension.dart';
  5. import 'package:sonnat/core/html/html_viewer.dart';
  6. import 'package:sonnat/core/language/translator.dart';
  7. import 'package:sonnat/core/utils/app_constants.dart';
  8. import 'package:sonnat/features/single_post/view_models/post.dart';
  9. class SinglePostScreen extends StatefulWidget {
  10. final Post post;
  11. const SinglePostScreen({super.key, required this.post});
  12. @override
  13. State<SinglePostScreen> createState() => _SinglePostScreenState();
  14. }
  15. class _SinglePostScreenState extends State<SinglePostScreen> {
  16. @override
  17. Widget build(BuildContext context) {
  18. return Scaffold(
  19. body: SafeArea(
  20. child: Column(
  21. children: [
  22. Stack(
  23. fit: StackFit.expand,
  24. children: [
  25. CachedNetworkImage(
  26. imageUrl: widget.post.thumbnail?.lg ?? '',
  27. fit: BoxFit.cover,
  28. errorWidget: (context, url, error) {
  29. return const Icon(
  30. Icons.wifi_off,
  31. size: 80,
  32. color: Colors.black54,
  33. );
  34. },
  35. placeholder: (context, url) => Shimmer.fromColors(
  36. baseColor: Colors.grey.shade300,
  37. highlightColor: Colors.grey.shade100,
  38. child: Container(color: Colors.white),
  39. ),
  40. ),
  41. const Positioned(
  42. top: 0,
  43. left: 8,
  44. right: 8,
  45. child: Row(
  46. children: <Widget>[
  47. BackButton(color: Colors.white),
  48. ],
  49. ),
  50. ),
  51. Positioned(
  52. bottom: 0,
  53. left: 0,
  54. right: 0,
  55. child: Container(
  56. height: 150,
  57. width: 1,
  58. decoration: BoxDecoration(
  59. gradient: LinearGradient(
  60. begin: Alignment.bottomCenter,
  61. end: Alignment.topCenter,
  62. colors: [
  63. Colors.black.withOpacity(0.7),
  64. Colors.black.withOpacity(0),
  65. ],
  66. ),
  67. ),
  68. ),
  69. ),
  70. Padding(
  71. padding: const EdgeInsets.all(8),
  72. child: Align(
  73. alignment: Alignment.bottomCenter,
  74. child: Row(
  75. children: <Widget>[
  76. Padding(
  77. padding: const EdgeInsets.all(8),
  78. child: ClipOval(
  79. child: CachedNetworkImage(
  80. imageUrl: /*post.thumbnail?.sm ??*/ '',
  81. height: 30,
  82. width: 30,
  83. errorWidget: (context, url, error) {
  84. return Image.asset(
  85. 'assets/images/png/avatar.jpg',
  86. cacheWidth: 30 ~/ 1,
  87. cacheHeight: 30 ~/ 1,
  88. );
  89. },
  90. placeholder: (context, url) => Shimmer.fromColors(
  91. baseColor: Colors.grey.shade300,
  92. highlightColor: Colors.grey.shade100,
  93. child: Container(color: Colors.white),
  94. ),
  95. ),
  96. ),
  97. ),
  98. Text(
  99. "${Translator.translate('author')} : ${widget.post.author ?? ""}",
  100. style: const TextStyle(fontSize: 10),
  101. ),
  102. ],
  103. ),
  104. ),
  105. ),
  106. const Padding(
  107. padding: EdgeInsets.all(8),
  108. child: Align(
  109. alignment: Alignment.bottomCenter,
  110. child: Row(
  111. mainAxisAlignment: MainAxisAlignment.end,
  112. children: [],
  113. ),
  114. ),
  115. ),
  116. ],
  117. ),
  118. Padding(
  119. padding: EdgeInsetsDirectional.only(
  120. start: context.width * 26 / AppConstants.instance.appWidth,
  121. end: context.width * 37 / AppConstants.instance.appWidth,
  122. ),
  123. child: Column(
  124. crossAxisAlignment: CrossAxisAlignment.start,
  125. children: [
  126. const Text(
  127. 'عدم بیعت صحابه با ابوبکر+سند',
  128. style: TextStyle(
  129. fontWeight: FontWeight.bold,
  130. fontSize: 16,
  131. ),
  132. ),
  133. const Text(
  134. '1404/12/25',
  135. style: TextStyle(fontSize: 11),
  136. ),
  137. HTMLViewer(
  138. htmlContent: widget.post.content ?? '',
  139. fontSizeFactor: 1,
  140. ),
  141. ],
  142. ),
  143. ),
  144. ],
  145. ),
  146. ),
  147. );
  148. }
  149. }