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.

266 lines
9.7 KiB

1 year ago
1 year ago
1 year ago
10 months ago
1 year ago
10 months ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
10 months 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
10 months 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/select_language/cubit/select_language_cubit.dart';
  8. import 'package:sonnat/core/select_language/screen/select_language_screen.dart';
  9. import 'package:sonnat/core/utils/app_constants.dart';
  10. import 'package:sonnat/core/widgets/more_options_widget.dart';
  11. import 'package:sonnat/features/about_us/about_us_screen.dart';
  12. import 'package:sonnat/features/main/widget/main_item_widget.dart';
  13. import 'package:sonnat/features/posts/cubit/posts_cubit.dart';
  14. import 'package:sonnat/features/posts/screen/posts_screen.dart';
  15. class MainScreen extends StatefulWidget {
  16. const MainScreen({super.key});
  17. @override
  18. State<MainScreen> createState() => _MainScreenState();
  19. }
  20. class _MainScreenState extends State<MainScreen> {
  21. final List<String> _icons = [
  22. 'ic_mataen',
  23. 'ic_shobahat',
  24. 'ic_aqayed',
  25. 'ic_vijeha',
  26. 'ic_akhbar',
  27. 'ic_video',
  28. ];
  29. final List<Map<String, String>> _names = [
  30. {'name': Translator.translate('forbidden'), 'catId': '77,78,79'},
  31. {'name': Translator.translate('doubts'), 'catId': '83'},
  32. {'name': Translator.translate('criticism_of_ideas'), 'catId': '101'},
  33. {'name': Translator.translate('specials'), 'catId': '109'},
  34. {'name': Translator.translate('news'), 'catId': '104'},
  35. {'name': Translator.translate('video'), 'catId': ''},
  36. ];
  37. @override
  38. Widget build(BuildContext context) {
  39. return Scaffold(
  40. backgroundColor: const Color(0xff26237A),
  41. body: SafeArea(
  42. child: Column(
  43. children: [
  44. Align(
  45. alignment: AlignmentDirectional.centerStart,
  46. child: Padding(
  47. padding: EdgeInsetsDirectional.only(
  48. start: context.width * 24 / AppConstants.instance.appWidth,
  49. top: context.height * 12 / AppConstants.instance.appHeight,
  50. ),
  51. child: GestureDetector(
  52. onTap: _showOptions,
  53. child: SvgPicture.asset('ic_more'.svgPath),
  54. ),
  55. ),
  56. ),
  57. Container(
  58. margin: EdgeInsets.only(
  59. left: context.width * 86 / AppConstants.instance.appWidth,
  60. right: context.width * 86 / AppConstants.instance.appWidth,
  61. ),
  62. child: Image.asset(
  63. 'ic_main_header'.pngPath,
  64. width: context.width * 200 / AppConstants.instance.appWidth,
  65. height: context.height * 200 / AppConstants.instance.appHeight,
  66. ),
  67. ),
  68. Text(
  69. Translator.translate('main_header_text'),
  70. style: const TextStyle(
  71. color: Color(0xffFFD800),
  72. fontSize: 28,
  73. ),
  74. ),
  75. Text(
  76. Translator.translate('second_header_text'),
  77. style: const TextStyle(
  78. color: Color(0xffDEDEDE),
  79. fontSize: 16,
  80. ),
  81. ),
  82. GestureDetector(
  83. onTap: () {
  84. Navigator.push(
  85. context,
  86. MaterialPageRoute(
  87. builder: (context) {
  88. return BlocProvider(
  89. create: (context) => PostsCubit(lastCatId: '77,78,79'),
  90. child: const PostsScreen(title: '', searchMode: true),
  91. );
  92. },
  93. ),
  94. );
  95. },
  96. child: Container(
  97. decoration: BoxDecoration(
  98. color: const Color(0xffF4F4F8),
  99. borderRadius: BorderRadius.circular(22),
  100. ),
  101. margin: EdgeInsets.only(
  102. left: context.width * 35 / AppConstants.instance.appWidth,
  103. right: context.width * 35 / AppConstants.instance.appWidth,
  104. top: context.height * 40 / AppConstants.instance.appHeight,
  105. bottom: context.height * 60 / AppConstants.instance.appHeight,
  106. ),
  107. padding: EdgeInsets.symmetric(
  108. vertical: context.height * 13 / AppConstants.instance.appHeight,
  109. horizontal: context.width * 8 / AppConstants.instance.appWidth,
  110. ),
  111. child: Row(
  112. children: [
  113. SvgPicture.asset('ic_search'.svgPath),
  114. SizedBox(width: context.width * 14 / AppConstants.instance.appWidth),
  115. Text(
  116. Translator.translate('search_term'),
  117. style: const TextStyle(
  118. color: Color(0xffBCC1CD),
  119. fontSize: 16,
  120. ),
  121. ),
  122. ],
  123. ),
  124. ),
  125. ),
  126. SvgPicture.asset('ic_line'.svgPath),
  127. SizedBox(height: context.height * 30 / AppConstants.instance.appHeight),
  128. Padding(
  129. padding: EdgeInsets.symmetric(horizontal: context.width * 35 / AppConstants.instance.appWidth),
  130. child: Row(
  131. children: [
  132. GestureDetector(
  133. child: MainItemWidget(icon: _icons[2], name: _names[2]['name']!),
  134. onTap: () => _openItem(index: 2),
  135. ),
  136. SizedBox(width: context.width * 13 / AppConstants.instance.appWidth),
  137. GestureDetector(
  138. child: MainItemWidget(icon: _icons[1], name: _names[1]['name']!),
  139. onTap: () => _openItem(index: 1),
  140. ),
  141. SizedBox(width: context.width * 13 / AppConstants.instance.appWidth),
  142. GestureDetector(
  143. child: MainItemWidget(icon: _icons[0], name: _names[0]['name']!),
  144. onTap: () => _openItem(index: 0),
  145. ),
  146. ],
  147. ),
  148. ),
  149. SizedBox(height: context.height * 10 / AppConstants.instance.appHeight),
  150. Padding(
  151. padding: EdgeInsets.symmetric(horizontal: context.width * 35 / AppConstants.instance.appWidth),
  152. child: Row(
  153. children: [
  154. GestureDetector(
  155. child: MainItemWidget(icon: _icons[5], name: _names[5]['name']!),
  156. onTap: () => _openItem(index: 5),
  157. ),
  158. SizedBox(width: context.width * 13 / AppConstants.instance.appWidth),
  159. GestureDetector(
  160. child: MainItemWidget(icon: _icons[4], name: _names[4]['name']!),
  161. onTap: () => _openItem(index: 4),
  162. ),
  163. SizedBox(width: context.width * 13 / AppConstants.instance.appWidth),
  164. GestureDetector(
  165. child: MainItemWidget(icon: _icons[3], name: _names[3]['name']!),
  166. onTap: () => _openItem(index: 3),
  167. ),
  168. ],
  169. ),
  170. ),
  171. SizedBox(height: context.height * 20 / AppConstants.instance.appHeight),
  172. ],
  173. ),
  174. ),
  175. );
  176. }
  177. void _openItem({required int index}) {
  178. Navigator.push(
  179. context,
  180. MaterialPageRoute(
  181. builder: (context) {
  182. return BlocProvider(
  183. create: (context) => PostsCubit(lastCatId: _names[index]['catId']!),
  184. child: PostsScreen(
  185. title: _names[index]['name']!,
  186. showFilters: index == 0,
  187. ),
  188. );
  189. },
  190. ),
  191. );
  192. }
  193. void _showOptions() {
  194. showModalBottomSheet(
  195. context: context,
  196. backgroundColor: Colors.transparent,
  197. builder: (context) {
  198. return Container(
  199. height: 120,
  200. width: context.width,
  201. decoration: BoxDecoration(
  202. color: Colors.white,
  203. border: Border.all(color: Colors.white, width: 0.2),
  204. borderRadius: const BorderRadius.only(
  205. topLeft: Radius.circular(16),
  206. topRight: Radius.circular(16),
  207. ),
  208. ),
  209. padding: const EdgeInsets.only(
  210. top: 16,
  211. left: 4,
  212. right: 4,
  213. ),
  214. child: Column(
  215. children: [
  216. MoreOptionsWidget(
  217. title: Translator.translate('about_us'),
  218. onTap: () {
  219. Navigator.pop(context);
  220. Navigator.push(
  221. context,
  222. MaterialPageRoute(
  223. builder: (context) {
  224. return const AboutUsScreen();
  225. },
  226. ),
  227. );
  228. },
  229. ),
  230. const SizedBox(height: 8),
  231. Container(
  232. width: context.width,
  233. height: 1,
  234. color: const Color(0xffD3D8E9),
  235. ),
  236. const SizedBox(height: 8),
  237. MoreOptionsWidget(
  238. title: Translator.translate('select_language'),
  239. onTap: () {
  240. Navigator.pop(context);
  241. Navigator.push(
  242. context,
  243. MaterialPageRoute(
  244. builder: (context) {
  245. return BlocProvider(
  246. child: const SelectLanguageScreen(),
  247. create: (context) => SelectLanguageCubit(),
  248. );
  249. },
  250. ),
  251. );
  252. },
  253. ),
  254. ],
  255. ),
  256. );
  257. },
  258. );
  259. }
  260. }