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.

107 lines
3.9 KiB

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: Column(
  31. children: [
  32. SizedBox(height: context.height * 26 / AppConstants.instance.appHeight),
  33. Padding(
  34. padding: EdgeInsets.symmetric(horizontal: context.width * 26 / AppConstants.instance.appWidth),
  35. child: Row(
  36. children: [
  37. GestureDetector(
  38. onTap: () {},
  39. child: SvgPicture.asset(
  40. 'ic_more'.svgPath,
  41. ),
  42. ),
  43. SizedBox(width: context.width * 8 / AppConstants.instance.appWidth),
  44. GestureDetector(
  45. onTap: () {},
  46. child: SvgPicture.asset(
  47. 'ic_rounded_search'.svgPath,
  48. ),
  49. ),
  50. const Spacer(),
  51. Text(
  52. widget.title,
  53. style: const TextStyle(
  54. color: Color(0xff404966),
  55. fontSize: 22,
  56. ),
  57. ),
  58. const Spacer(),
  59. GestureDetector(
  60. onTap: () {
  61. Navigator.pop(context);
  62. },
  63. child: SvgPicture.asset(
  64. 'ic_back'.svgPath,
  65. ),
  66. ),
  67. ],
  68. ),
  69. ),
  70. SizedBox(height: context.height * 35 / AppConstants.instance.appHeight),
  71. SizedBox(
  72. height: context.height * 31 / AppConstants.instance.appHeight,
  73. child: ListView.builder(
  74. padding: EdgeInsetsDirectional.only(start: context.width * 26 / AppConstants.instance.appWidth),
  75. itemBuilder: (context, index) {
  76. return FilterItemWidget(title: _filterList[index].title, selected: _filterList[index].selected);
  77. },
  78. itemCount: _filterList.length,
  79. scrollDirection: Axis.horizontal,
  80. ),
  81. ),
  82. SizedBox(height: context.height * 26 / AppConstants.instance.appHeight),
  83. Expanded(
  84. child: ListView.builder(
  85. itemBuilder: (context, index) {
  86. return const PostItemWidget();
  87. },
  88. itemCount: 10,
  89. ),
  90. )
  91. ],
  92. ),
  93. );
  94. }
  95. }
  96. class FilterItem {
  97. final bool selected;
  98. final String title;
  99. const FilterItem({required this.selected, required this.title});
  100. }