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.

172 lines
6.5 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. 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<String> _names = [
  26. Translator.translate('forbidden'),
  27. Translator.translate('doubts'),
  28. Translator.translate('criticism_of_ideas'),
  29. Translator.translate('specials'),
  30. Translator.translate('news'),
  31. Translator.translate('video'),
  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(context, MaterialPageRoute(
  68. builder: (context) {
  69. return BlocProvider(
  70. create: (context) => PostsCubit(),
  71. child: const PostsScreen(title: '', searchMode: true),
  72. );
  73. },
  74. ));
  75. },
  76. child: Container(
  77. decoration: BoxDecoration(
  78. color: const Color(0xffF4F4F8),
  79. borderRadius: BorderRadius.circular(22),
  80. ),
  81. margin: EdgeInsets.only(
  82. left: context.width * 35 / AppConstants.instance.appWidth,
  83. right: context.width * 35 / AppConstants.instance.appWidth,
  84. top: context.height * 40 / AppConstants.instance.appHeight,
  85. bottom: context.height * 60 / AppConstants.instance.appHeight,
  86. ),
  87. padding: EdgeInsets.symmetric(
  88. vertical: context.height * 13 / AppConstants.instance.appHeight,
  89. horizontal: context.width * 8 / AppConstants.instance.appWidth,
  90. ),
  91. child: Row(
  92. children: [
  93. SvgPicture.asset('ic_search'.svgPath),
  94. SizedBox(width: context.width * 14 / AppConstants.instance.appWidth),
  95. Text(
  96. Translator.translate('search_term'),
  97. style: const TextStyle(
  98. color: Color(0xffBCC1CD),
  99. fontSize: 16,
  100. ),
  101. ),
  102. ],
  103. ),
  104. ),
  105. ),
  106. SvgPicture.asset('ic_line'.svgPath),
  107. SizedBox(height: context.height * 30 / AppConstants.instance.appHeight),
  108. Padding(
  109. padding: EdgeInsets.symmetric(horizontal: context.width * 35 / AppConstants.instance.appWidth),
  110. child: Row(
  111. children: [
  112. GestureDetector(
  113. child: MainItemWidget(icon: _icons[2], name: _names[2]),
  114. onTap: () => _openItem(index: 2),
  115. ),
  116. SizedBox(width: context.width * 13 / AppConstants.instance.appWidth),
  117. GestureDetector(
  118. child: MainItemWidget(icon: _icons[1], name: _names[1]),
  119. onTap: () => _openItem(index: 1),
  120. ),
  121. SizedBox(width: context.width * 13 / AppConstants.instance.appWidth),
  122. GestureDetector(
  123. child: MainItemWidget(icon: _icons[0], name: _names[0]),
  124. onTap: () => _openItem(index: 0),
  125. ),
  126. ],
  127. ),
  128. ),
  129. SizedBox(height: context.height * 10 / AppConstants.instance.appHeight),
  130. Padding(
  131. padding: EdgeInsets.symmetric(horizontal: context.width * 35 / AppConstants.instance.appWidth),
  132. child: Row(
  133. children: [
  134. GestureDetector(
  135. child: MainItemWidget(icon: _icons[5], name: _names[5]),
  136. onTap: () => _openItem(index: 5),
  137. ),
  138. SizedBox(width: context.width * 13 / AppConstants.instance.appWidth),
  139. GestureDetector(
  140. child: MainItemWidget(icon: _icons[4], name: _names[4]),
  141. onTap: () => _openItem(index: 4),
  142. ),
  143. SizedBox(width: context.width * 13 / AppConstants.instance.appWidth),
  144. GestureDetector(
  145. child: MainItemWidget(icon: _icons[3], name: _names[3]),
  146. onTap: () => _openItem(index: 3),
  147. ),
  148. ],
  149. ),
  150. ),
  151. SizedBox(height: context.height * 20 / AppConstants.instance.appHeight),
  152. ],
  153. ),
  154. ),
  155. );
  156. }
  157. void _openItem({required int index}) {
  158. Navigator.push(context, MaterialPageRoute(
  159. builder: (context) {
  160. return BlocProvider(
  161. create: (context) => PostsCubit(),
  162. child: PostsScreen(title: _names[index]),
  163. );
  164. },
  165. ));
  166. }
  167. }