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.

181 lines
6.9 KiB

1 year ago
1 year ago
1 year ago
1 year 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
1 year ago
1 year ago
11 months 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 year 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
11 months ago
1 year ago
11 months 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
11 months ago
1 year ago
1 year ago
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_bloc/flutter_bloc.dart';
  3. import 'package:flutter_svg/flutter_svg.dart';
  4. import 'package:sonnat/core/extensions/context_extension.dart';
  5. import 'package:sonnat/core/extensions/string_extension.dart';
  6. import 'package:sonnat/core/language/translator.dart';
  7. import 'package:sonnat/core/utils/app_constants.dart';
  8. import 'package:sonnat/features/main/widget/main_item_widget.dart';
  9. import 'package:sonnat/features/posts/cubit/posts_cubit.dart';
  10. import 'package:sonnat/features/posts/screen/posts_screen.dart';
  11. class MainScreen extends StatefulWidget {
  12. const MainScreen({super.key});
  13. @override
  14. State<MainScreen> createState() => _MainScreenState();
  15. }
  16. class _MainScreenState extends State<MainScreen> {
  17. final List<String> _icons = [
  18. 'ic_mataen',
  19. 'ic_shobahat',
  20. 'ic_aqayed',
  21. 'ic_vijeha',
  22. 'ic_akhbar',
  23. 'ic_video',
  24. ];
  25. final List<Map<String, String>> _names = [
  26. {'name': Translator.translate('forbidden'), 'catId': '77,78,79'},
  27. {'name': Translator.translate('doubts'), 'catId': '83'},
  28. {'name': Translator.translate('criticism_of_ideas'), 'catId': '101'},
  29. {'name': Translator.translate('specials'), 'catId': '109'},
  30. {'name': Translator.translate('news'), 'catId': '104'},
  31. {'name': Translator.translate('video'), 'catId': ''},
  32. ];
  33. @override
  34. Widget build(BuildContext context) {
  35. return Scaffold(
  36. backgroundColor: const Color(0xff26237A),
  37. body: SafeArea(
  38. child: Column(
  39. children: [
  40. Container(
  41. margin: EdgeInsets.only(
  42. left: context.width * 86 / AppConstants.instance.appWidth,
  43. right: context.width * 86 / AppConstants.instance.appWidth,
  44. ),
  45. child: Image.asset(
  46. 'ic_main_header'.pngPath,
  47. width: context.width * 200 / AppConstants.instance.appWidth,
  48. height: context.height * 200 / AppConstants.instance.appHeight,
  49. ),
  50. ),
  51. Text(
  52. Translator.translate('main_header_text'),
  53. style: const TextStyle(
  54. color: Color(0xffFFD800),
  55. fontSize: 28,
  56. ),
  57. ),
  58. Text(
  59. Translator.translate('second_header_text'),
  60. style: const TextStyle(
  61. color: Color(0xffDEDEDE),
  62. fontSize: 16,
  63. ),
  64. ),
  65. GestureDetector(
  66. onTap: () {
  67. Navigator.push(
  68. context,
  69. MaterialPageRoute(
  70. builder: (context) {
  71. return BlocProvider(
  72. create: (context) => PostsCubit(lastCatId: '77,78,79'),
  73. child: const PostsScreen(title: '', searchMode: true),
  74. );
  75. },
  76. ),
  77. );
  78. },
  79. child: Container(
  80. decoration: BoxDecoration(
  81. color: const Color(0xffF4F4F8),
  82. borderRadius: BorderRadius.circular(22),
  83. ),
  84. margin: EdgeInsets.only(
  85. left: context.width * 35 / AppConstants.instance.appWidth,
  86. right: context.width * 35 / AppConstants.instance.appWidth,
  87. top: context.height * 40 / AppConstants.instance.appHeight,
  88. bottom: context.height * 60 / AppConstants.instance.appHeight,
  89. ),
  90. padding: EdgeInsets.symmetric(
  91. vertical: context.height * 13 / AppConstants.instance.appHeight,
  92. horizontal: context.width * 8 / AppConstants.instance.appWidth,
  93. ),
  94. child: Row(
  95. children: [
  96. SvgPicture.asset('ic_search'.svgPath),
  97. SizedBox(width: context.width * 14 / AppConstants.instance.appWidth),
  98. Text(
  99. Translator.translate('search_term'),
  100. style: const TextStyle(
  101. color: Color(0xffBCC1CD),
  102. fontSize: 16,
  103. ),
  104. ),
  105. ],
  106. ),
  107. ),
  108. ),
  109. SvgPicture.asset('ic_line'.svgPath),
  110. SizedBox(height: context.height * 30 / AppConstants.instance.appHeight),
  111. Padding(
  112. padding: EdgeInsets.symmetric(horizontal: context.width * 35 / AppConstants.instance.appWidth),
  113. child: Row(
  114. children: [
  115. GestureDetector(
  116. child: MainItemWidget(icon: _icons[2], name: _names[2]['name']!),
  117. onTap: () => _openItem(index: 2),
  118. ),
  119. SizedBox(width: context.width * 13 / AppConstants.instance.appWidth),
  120. GestureDetector(
  121. child: MainItemWidget(icon: _icons[1], name: _names[1]['name']!),
  122. onTap: () => _openItem(index: 1),
  123. ),
  124. SizedBox(width: context.width * 13 / AppConstants.instance.appWidth),
  125. GestureDetector(
  126. child: MainItemWidget(icon: _icons[0], name: _names[0]['name']!),
  127. onTap: () => _openItem(index: 0),
  128. ),
  129. ],
  130. ),
  131. ),
  132. SizedBox(height: context.height * 10 / AppConstants.instance.appHeight),
  133. Padding(
  134. padding: EdgeInsets.symmetric(horizontal: context.width * 35 / AppConstants.instance.appWidth),
  135. child: Row(
  136. children: [
  137. GestureDetector(
  138. child: MainItemWidget(icon: _icons[5], name: _names[5]['name']!),
  139. onTap: () => _openItem(index: 5),
  140. ),
  141. SizedBox(width: context.width * 13 / AppConstants.instance.appWidth),
  142. GestureDetector(
  143. child: MainItemWidget(icon: _icons[4], name: _names[4]['name']!),
  144. onTap: () => _openItem(index: 4),
  145. ),
  146. SizedBox(width: context.width * 13 / AppConstants.instance.appWidth),
  147. GestureDetector(
  148. child: MainItemWidget(icon: _icons[3], name: _names[3]['name']!),
  149. onTap: () => _openItem(index: 3),
  150. ),
  151. ],
  152. ),
  153. ),
  154. SizedBox(height: context.height * 20 / AppConstants.instance.appHeight),
  155. ],
  156. ),
  157. ),
  158. );
  159. }
  160. void _openItem({required int index}) {
  161. Navigator.push(
  162. context,
  163. MaterialPageRoute(
  164. builder: (context) {
  165. return BlocProvider(
  166. create: (context) => PostsCubit(lastCatId: _names[index]['catId']!),
  167. child: PostsScreen(
  168. title: _names[index]['name']!,
  169. showFilters: index == 0,
  170. ),
  171. );
  172. },
  173. ),
  174. );
  175. }
  176. }