25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

251 lines
7.8 KiB

  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_gen/gen_l10n/app_localizations.dart';
  3. import 'package:font_awesome_flutter/font_awesome_flutter.dart';
  4. import 'package:provider/provider.dart';
  5. import 'package:qadirneyriz/config/config.dart';
  6. import 'package:qadirneyriz/screens/auth/state/state.dart';
  7. import 'package:qadirneyriz/screens/home/screen.dart';
  8. import 'package:qadirneyriz/screens/meeting/screen.dart';
  9. import 'package:qadirneyriz/setting/setting.dart';
  10. class CustomDrawerNavigation extends StatefulWidget {
  11. final int activeTab;
  12. const CustomDrawerNavigation({super.key, required this.activeTab});
  13. @override
  14. _CustomDrawerNavigationState createState() => _CustomDrawerNavigationState();
  15. }
  16. class _CustomDrawerNavigationState extends State<CustomDrawerNavigation> {
  17. late final PageController _pageController;
  18. int _selectedIndex = 0;
  19. final String language = setting.userLocalDb.getUser().language;
  20. String? selectedLanguage; // زبان پیش‌فرض فارسی
  21. late AuthState state;
  22. @override
  23. void initState() {
  24. super.initState();
  25. state = Provider.of(context, listen: false);
  26. selectedLanguage = language;
  27. _selectedIndex = widget.activeTab;
  28. _pageController = PageController(initialPage: _selectedIndex);
  29. }
  30. final List<Widget> _bottomBarPages = [
  31. const HomeScreen(),
  32. const MeetingsScreen()
  33. // Add more screens here
  34. ];
  35. void _onItemTapped(int index) {
  36. setState(() {
  37. _selectedIndex = index;
  38. });
  39. _pageController.jumpToPage(index);
  40. Navigator.pop(context); // Close the drawer
  41. }
  42. @override
  43. Widget build(BuildContext context) {
  44. return Scaffold(
  45. drawer: Consumer<AuthState>(
  46. builder: (context, value, child) {
  47. return Drawer(
  48. child: Column(
  49. crossAxisAlignment: CrossAxisAlignment.start,
  50. children: <Widget>[
  51. Padding(
  52. padding: const EdgeInsets.only(left: 16.0, top: 40),
  53. child: Image.asset(
  54. 'assets/images/iconinappbar.png', // مسیر لوگوی شما
  55. height: 60,
  56. ),
  57. ),
  58. NewSessionButton(),
  59. Expanded(
  60. child: ListView(
  61. padding: EdgeInsets.zero,
  62. children: <Widget>[
  63. _buildDrawerItem(
  64. icon: FontAwesomeIcons.house,
  65. text: 'خانه',
  66. index: 0,
  67. ),
  68. _buildDrawerItem(
  69. icon: FontAwesomeIcons.pencil,
  70. text: 'جلسات',
  71. index: 1,
  72. ),
  73. _buildDrawerItem(
  74. icon: FontAwesomeIcons.pencil,
  75. text: 'ملاقات ها',
  76. index: 2,
  77. ),
  78. _buildDrawerItem(
  79. icon: FontAwesomeIcons.pencil,
  80. text: 'گزارشات',
  81. index: 3,
  82. ),
  83. Padding(
  84. padding: const EdgeInsets.all(8.0),
  85. child: Container(
  86. decoration: BoxDecoration(
  87. color: Colors.grey[300],
  88. borderRadius: BorderRadius.circular(10),
  89. ),
  90. child: Row(
  91. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  92. children: [
  93. _buildLanguageButton('fa', 'فارسی', () {
  94. value.setLocale('fa');
  95. }),
  96. _buildLanguageButton('en', 'English', () {
  97. value.setLocale('en');
  98. }),
  99. ],
  100. ),
  101. ),
  102. )
  103. ],
  104. ),
  105. ),
  106. const Divider(),
  107. ],
  108. ),
  109. );
  110. },
  111. ),
  112. body: PageView(
  113. controller: _pageController,
  114. physics: const NeverScrollableScrollPhysics(),
  115. children: _bottomBarPages,
  116. ),
  117. );
  118. }
  119. Widget _buildDrawerItem(
  120. {required IconData icon, required String text, required int index}) {
  121. bool isSelected = _selectedIndex == index;
  122. return Padding(
  123. padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 2),
  124. child: Material(
  125. color: isSelected
  126. ? config.ui.mainGreen.withOpacity(.2)
  127. : Colors.transparent,
  128. borderRadius: BorderRadius.circular(8),
  129. child: InkWell(
  130. borderRadius: BorderRadius.circular(8),
  131. onTap: () => _onItemTapped(index),
  132. child: Container(
  133. decoration: BoxDecoration(
  134. borderRadius: BorderRadius.circular(8),
  135. ),
  136. child: ListTile(
  137. leading: FaIcon(
  138. icon,
  139. size: 19,
  140. color: isSelected ? config.ui.mainGreen : config.ui.mainGray,
  141. ),
  142. title: Text(
  143. text,
  144. style: TextStyle(
  145. color:
  146. isSelected ? config.ui.mainGreen : config.ui.mainGray,
  147. fontWeight:
  148. isSelected ? FontWeight.bold : FontWeight.normal,
  149. fontSize: 15),
  150. ),
  151. selected: isSelected,
  152. ),
  153. ),
  154. ),
  155. ),
  156. );
  157. }
  158. Widget _buildLanguageButton(
  159. String language, String text, void Function() onPressed) {
  160. bool isSelected = selectedLanguage == language;
  161. return ElevatedButton(
  162. onPressed: () {
  163. setState(() {
  164. selectedLanguage = language; // به‌روز کردن زبان انتخاب شده
  165. });
  166. onPressed(); // اجرای متد تغییر زبان
  167. },
  168. style: ElevatedButton.styleFrom(
  169. backgroundColor: isSelected ? Colors.green : Colors.grey[300],
  170. shape: RoundedRectangleBorder(
  171. borderRadius: BorderRadius.circular(8.0),
  172. ),
  173. ),
  174. child: Text(
  175. text,
  176. style: TextStyle(
  177. color: isSelected ? Colors.white : Colors.black,
  178. ),
  179. ),
  180. );
  181. }
  182. @override
  183. void dispose() {
  184. _pageController.dispose();
  185. super.dispose();
  186. }
  187. }
  188. class NewSessionButton extends StatelessWidget {
  189. @override
  190. Widget build(BuildContext context) {
  191. return ElevatedButton(
  192. style: ElevatedButton.styleFrom(
  193. backgroundColor: Colors.green, // رنگ لبه‌ها
  194. shape: RoundedRectangleBorder(
  195. borderRadius: BorderRadius.circular(8), // گرد کردن گوشه‌ها
  196. ),
  197. elevation: 0, // بدون سایه
  198. padding: EdgeInsets.symmetric(vertical: 20, horizontal: 16),
  199. ),
  200. onPressed: () {
  201. // کاری که باید انجام شود
  202. },
  203. child: Column(
  204. mainAxisSize: MainAxisSize.min,
  205. children: [
  206. Icon(
  207. Icons.person_outline,
  208. color: Colors.white, // رنگ آیکون
  209. size: 40,
  210. ),
  211. SizedBox(height: 8),
  212. Text(
  213. 'جلسه جدید',
  214. style: TextStyle(
  215. color: Colors.white, // رنگ متن
  216. fontSize: 16,
  217. fontWeight: FontWeight.bold,
  218. ),
  219. ),
  220. ],
  221. ),
  222. );
  223. }
  224. }
  225. class CustomScalfod extends StatefulWidget {
  226. const CustomScalfod({super.key});
  227. @override
  228. State<CustomScalfod> createState() => _CustomScalfodState();
  229. }
  230. class _CustomScalfodState extends State<CustomScalfod> {
  231. @override
  232. Widget build(BuildContext context) {
  233. return Scaffold();
  234. }
  235. }