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.

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