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.

116 lines
4.1 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_svg/flutter_svg.dart';
  3. import 'package:sonnat/core/extensions/context_extension.dart';
  4. import 'package:sonnat/core/extensions/string_extension.dart';
  5. import 'package:sonnat/core/utils/app_constants.dart';
  6. import 'package:sonnat/features/posts/widgets/filter_item_widget.dart';
  7. import 'package:sonnat/features/posts/widgets/post_item_widget.dart';
  8. class PostsScreen extends StatefulWidget {
  9. final String title;
  10. const PostsScreen({super.key, required this.title});
  11. @override
  12. State<PostsScreen> createState() => _PostsScreenState();
  13. }
  14. class _PostsScreenState extends State<PostsScreen> {
  15. final List<FilterItem> _filterList = [
  16. const FilterItem(selected: false, title: 'پر تکرارترین‌ها'),
  17. const FilterItem(selected: true, title: 'مشابه‌ها'),
  18. const FilterItem(selected: false, title: 'محبوبترین‌ها'),
  19. const FilterItem(selected: false, title: 'برای‌ شما'),
  20. const FilterItem(selected: false, title: 'محبوبترین‌ها'),
  21. const FilterItem(selected: false, title: 'پر تکرارترین‌ها'),
  22. const FilterItem(selected: true, title: 'مشابه‌ها'),
  23. const FilterItem(selected: false, title: 'محبوبترین‌ها'),
  24. const FilterItem(selected: false, title: 'برای‌ شما'),
  25. const FilterItem(selected: false, title: 'محبوبترین‌ها'),
  26. ];
  27. @override
  28. Widget build(BuildContext context) {
  29. return Scaffold(
  30. body: SafeArea(
  31. child: Column(
  32. children: [
  33. SizedBox(height: context.height * 26 / AppConstants.instance.appHeight),
  34. Padding(
  35. padding: EdgeInsets.symmetric(horizontal: context.width * 26 / AppConstants.instance.appWidth),
  36. child: Row(
  37. children: [
  38. GestureDetector(
  39. onTap: () {},
  40. child: SvgPicture.asset(
  41. 'ic_more'.svgPath,
  42. ),
  43. ),
  44. SizedBox(width: context.width * 8 / AppConstants.instance.appWidth),
  45. GestureDetector(
  46. onTap: () {},
  47. child: SvgPicture.asset(
  48. 'ic_rounded_search'.svgPath,
  49. ),
  50. ),
  51. const Spacer(),
  52. Text(
  53. widget.title,
  54. style: const TextStyle(
  55. color: Color(0xff404966),
  56. fontSize: 22,
  57. ),
  58. ),
  59. const Spacer(),
  60. GestureDetector(
  61. onTap: () {
  62. Navigator.pop(context);
  63. },
  64. child: SvgPicture.asset(
  65. 'ic_back'.svgPath,
  66. ),
  67. ),
  68. ],
  69. ),
  70. ),
  71. SizedBox(height: context.height * 35 / AppConstants.instance.appHeight),
  72. SizedBox(
  73. height: context.height * 31 / AppConstants.instance.appHeight,
  74. child: ListView.builder(
  75. padding: EdgeInsetsDirectional.only(start: context.width * 26 / AppConstants.instance.appWidth),
  76. itemBuilder: (context, index) {
  77. return FilterItemWidget(title: _filterList[index].title, selected: _filterList[index].selected);
  78. },
  79. itemCount: _filterList.length,
  80. scrollDirection: Axis.horizontal,
  81. ),
  82. ),
  83. SizedBox(height: context.height * 26 / AppConstants.instance.appHeight),
  84. Expanded(
  85. child: ListView.builder(
  86. itemBuilder: (context, index) {
  87. return GestureDetector(
  88. onTap: _clickOnPost,
  89. child: const PostItemWidget(),
  90. );
  91. },
  92. itemCount: 10,
  93. ),
  94. )
  95. ],
  96. ),
  97. ),
  98. );
  99. }
  100. void _clickOnPost() {
  101. }
  102. }
  103. class FilterItem {
  104. final bool selected;
  105. final String title;
  106. const FilterItem({required this.selected, required this.title});
  107. }