header.dart 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. import 'package:dropdown_button2/dropdown_button2.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:go_router/go_router.dart';
  4. class CustomAppbar extends StatefulWidget implements PreferredSizeWidget {
  5. final bool? isBack;
  6. final TextEditingController? controller;
  7. const CustomAppbar({super.key, this.isBack, this.controller});
  8. @override
  9. State<CustomAppbar> createState() => _CustomAppbarState();
  10. @override
  11. Size get preferredSize => Size(15, 50);
  12. }
  13. class _CustomAppbarState extends State<CustomAppbar> {
  14. @override
  15. Widget build(BuildContext context) {
  16. return AppBar(
  17. backgroundColor: Colors.white,
  18. leading: Icon(Icons.bug_report),
  19. titleSpacing: 0,
  20. title: Text(
  21. 'Bug Listing',
  22. style: TextStyle(fontSize: 28, fontWeight: FontWeight.w500),
  23. ),
  24. actions: [
  25. Padding(
  26. padding: const EdgeInsets.symmetric(horizontal: 8.0),
  27. child: DropdownButtonHideUnderline(
  28. child: DropdownButton2(
  29. customButton: const Icon(Icons.home),
  30. onChanged: (value) => context.go('/'),
  31. items: [
  32. DropdownMenuItem(
  33. child: Text('Home'),
  34. )
  35. ],
  36. dropdownStyleData: DropdownStyleData(
  37. width: 80,
  38. padding: const EdgeInsets.symmetric(vertical: 6),
  39. decoration: BoxDecoration(
  40. borderRadius: BorderRadius.circular(4),
  41. ),
  42. offset: const Offset(0, 8),
  43. ),
  44. ),
  45. ),
  46. ),
  47. Padding(
  48. padding: const EdgeInsets.symmetric(horizontal: 8.0),
  49. child: DropdownButtonHideUnderline(
  50. child: DropdownButton2(
  51. customButton: const Icon(Icons.person),
  52. items: [
  53. ...UserItems.firstItems.map(
  54. (item) => DropdownMenuItem<MenuItem>(
  55. value: item,
  56. child: UserItems.buildItem(item),
  57. ),
  58. ),
  59. ],
  60. onChanged: (value) {
  61. UserItems.onChanged(context, value!);
  62. },
  63. dropdownStyleData: DropdownStyleData(
  64. width: 100,
  65. padding: const EdgeInsets.symmetric(vertical: 6),
  66. decoration: BoxDecoration(
  67. borderRadius: BorderRadius.circular(4),
  68. ),
  69. offset: const Offset(0, 8),
  70. ),
  71. menuItemStyleData: MenuItemStyleData(
  72. customHeights: [
  73. ...List<double>.filled(UserItems.firstItems.length, 48),
  74. ],
  75. padding: const EdgeInsets.only(left: 16, right: 16),
  76. ),
  77. ),
  78. ),
  79. ),
  80. Padding(
  81. padding: const EdgeInsets.symmetric(horizontal: 8.0),
  82. child: DropdownButtonHideUnderline(
  83. child: DropdownButton2(
  84. customButton: const Icon(Icons.bug_report),
  85. items: [
  86. ...BugItems.firstItems.map(
  87. (item) => DropdownMenuItem<MenuItem>(
  88. value: item,
  89. child: BugItems.buildItem(item),
  90. ),
  91. ),
  92. ],
  93. onChanged: (value) {
  94. BugItems.onChanged(context, value!);
  95. },
  96. dropdownStyleData: DropdownStyleData(
  97. width: 120,
  98. padding: const EdgeInsets.symmetric(vertical: 6),
  99. decoration: BoxDecoration(
  100. borderRadius: BorderRadius.circular(4),
  101. ),
  102. offset: const Offset(0, 8),
  103. ),
  104. menuItemStyleData: MenuItemStyleData(
  105. customHeights: [
  106. ...List<double>.filled(BugItems.firstItems.length, 48),
  107. ],
  108. padding: const EdgeInsets.only(left: 16, right: 16),
  109. ),
  110. ),
  111. ),
  112. ),
  113. Padding(
  114. padding: const EdgeInsets.symmetric(horizontal: 8.0),
  115. child: DropdownButtonHideUnderline(
  116. child: DropdownButton2(
  117. customButton: const Icon(Icons.build),
  118. items: [
  119. ...ProjectItems.firstItems.map(
  120. (item) => DropdownMenuItem<MenuItem>(
  121. value: item,
  122. child: ProjectItems.buildItem(item),
  123. ),
  124. ),
  125. ],
  126. onChanged: (value) {
  127. ProjectItems.onChanged(context, value!);
  128. },
  129. dropdownStyleData: DropdownStyleData(
  130. width: 150,
  131. padding: const EdgeInsets.symmetric(vertical: 6),
  132. decoration: BoxDecoration(
  133. borderRadius: BorderRadius.circular(4),
  134. ),
  135. offset: const Offset(0, 8),
  136. ),
  137. menuItemStyleData: MenuItemStyleData(
  138. customHeights: [
  139. ...List<double>.filled(ProjectItems.firstItems.length, 48),
  140. ],
  141. padding: const EdgeInsets.only(left: 16, right: 16),
  142. ),
  143. ),
  144. ),
  145. ),
  146. Padding(
  147. padding: const EdgeInsets.symmetric(horizontal: 8.0),
  148. child: DropdownButtonHideUnderline(
  149. child: DropdownButton2(
  150. customButton: const Icon(Icons.dynamic_form),
  151. items: [
  152. ...PlatformItems.firstItems.map(
  153. (item) => DropdownMenuItem<MenuItem>(
  154. value: item,
  155. child: PlatformItems.buildItem(item),
  156. ),
  157. ),
  158. ],
  159. onChanged: (value) {
  160. PlatformItems.onChanged(context, value!);
  161. },
  162. dropdownStyleData: DropdownStyleData(
  163. width: 150,
  164. padding: const EdgeInsets.symmetric(vertical: 6),
  165. decoration: BoxDecoration(
  166. borderRadius: BorderRadius.circular(4),
  167. ),
  168. offset: const Offset(0, 8),
  169. ),
  170. menuItemStyleData: MenuItemStyleData(
  171. customHeights: [
  172. ...List<double>.filled(PlatformItems.firstItems.length, 48),
  173. ],
  174. padding: const EdgeInsets.only(left: 16, right: 16),
  175. ),
  176. ),
  177. ),
  178. ),
  179. Padding(
  180. padding: const EdgeInsets.symmetric(horizontal: 8),
  181. child: DropdownButtonHideUnderline(
  182. child: DropdownButton2(
  183. customButton: const Icon(Icons.pan_tool),
  184. items: [
  185. DropdownMenuItem(
  186. child: Text('Maintenance'),
  187. )
  188. ],
  189. onChanged: (value) => context.go('/maintenance'),
  190. dropdownStyleData: DropdownStyleData(
  191. width: 130,
  192. padding: const EdgeInsets.symmetric(vertical: 6),
  193. decoration: BoxDecoration(
  194. borderRadius: BorderRadius.circular(4),
  195. ),
  196. offset: const Offset(0, 8),
  197. ),
  198. ),
  199. ),
  200. ),
  201. Padding(
  202. padding: const EdgeInsets.symmetric(horizontal: 8.0),
  203. child: DropdownButtonHideUnderline(
  204. child: DropdownButton2(
  205. customButton: const Icon(Icons.logout),
  206. items: [
  207. ...LogoutItems.firstItems.map(
  208. (item) => DropdownMenuItem<MenuItem>(
  209. value: item,
  210. child: LogoutItems.buildItem(item),
  211. ),
  212. ),
  213. ],
  214. onChanged: (value) {
  215. LogoutItems.onChanged(context, value!);
  216. },
  217. dropdownStyleData: DropdownStyleData(
  218. width: 170,
  219. padding: const EdgeInsets.symmetric(vertical: 6),
  220. decoration: BoxDecoration(
  221. borderRadius: BorderRadius.circular(4),
  222. ),
  223. offset: const Offset(0, 8),
  224. ),
  225. menuItemStyleData: MenuItemStyleData(
  226. customHeights: [
  227. ...List<double>.filled(LogoutItems.firstItems.length, 48),
  228. ],
  229. padding: const EdgeInsets.only(left: 16, right: 16),
  230. ),
  231. ),
  232. ),
  233. ),
  234. ],
  235. );
  236. }
  237. }
  238. class MenuItem {
  239. const MenuItem({
  240. required this.text,
  241. });
  242. final String text;
  243. }
  244. mixin PlatformItems {
  245. static const List<MenuItem> firstItems = [add, edit, list];
  246. static const add = MenuItem(text: 'Add Platform');
  247. static const edit = MenuItem(text: 'Edit Platform');
  248. static const list = MenuItem(text: 'List Platform');
  249. static Widget buildItem(MenuItem item) {
  250. return Row(
  251. children: [
  252. Expanded(
  253. child: Text(
  254. item.text,
  255. style: const TextStyle(
  256. color: Colors.black,
  257. ),
  258. ),
  259. ),
  260. ],
  261. );
  262. }
  263. static void onChanged(BuildContext context, MenuItem item) {
  264. switch (item) {
  265. case PlatformItems.add:
  266. context.go('/addplatform');
  267. break;
  268. case PlatformItems.edit:
  269. context.go('/listplatform/editplatform');
  270. break;
  271. case PlatformItems.list:
  272. context.go('/listplatform');
  273. break;
  274. }
  275. }
  276. }
  277. mixin BugItems {
  278. static const List<MenuItem> firstItems = [add, edit, list/*, listcomment*/];
  279. static const add = MenuItem(text: 'Add Bug');
  280. static const edit = MenuItem(text: 'Edit Bug');
  281. static const list = MenuItem(text: 'List Bug');
  282. static const listcomment = MenuItem(text: 'List Comment');
  283. static Widget buildItem(MenuItem item) {
  284. return Row(
  285. children: [
  286. Expanded(
  287. child: Text(
  288. item.text,
  289. style: const TextStyle(
  290. color: Colors.black,
  291. ),
  292. ),
  293. ),
  294. ],
  295. );
  296. }
  297. static void onChanged(BuildContext context, MenuItem item) {
  298. switch (item) {
  299. case BugItems.add:
  300. context.go('/addbug');
  301. break;
  302. case BugItems.edit:
  303. context.go('/login/bug/editbug');
  304. break;
  305. case BugItems.list:
  306. context.go('/login/bug');
  307. break;
  308. case BugItems.listcomment:
  309. context.go('/listcomment');
  310. break;
  311. }
  312. }
  313. }
  314. mixin UserItems {
  315. static const List<MenuItem> firstItems = [/*edit, change,*/ list];
  316. static const edit = MenuItem(text: 'Edit User');
  317. static const change = MenuItem(text: 'Edit Password');
  318. static const list = MenuItem(text: 'List User');
  319. static Widget buildItem(MenuItem item) {
  320. return Row(
  321. children: [
  322. Expanded(
  323. child: Text(
  324. item.text,
  325. style: const TextStyle(
  326. color: Colors.black,
  327. ),
  328. ),
  329. ),
  330. ],
  331. );
  332. }
  333. static void onChanged(BuildContext context, MenuItem item) {
  334. switch (item) {
  335. // case UserItems.edit:
  336. // context.go('/signup/listuser/edit');
  337. // break;
  338. // case UserItems.change:
  339. // context.go('/login/bug/editbug');
  340. // break;
  341. case UserItems.list:
  342. context.go('/signup/listuser');
  343. break;
  344. }
  345. }
  346. }
  347. mixin ProjectItems {
  348. static const List<MenuItem> firstItems = [add, edit, list, /*addMember, listMember*/];
  349. static const add = MenuItem(text: 'Add Project');
  350. static const edit = MenuItem(text: 'Edit Project');
  351. static const list = MenuItem(text: 'List Project');
  352. static const addMember = MenuItem(text: 'Add Member');
  353. static const listMember = MenuItem(text: 'List Member');
  354. static Widget buildItem(MenuItem item) {
  355. return Row(
  356. children: [
  357. Expanded(
  358. child: Text(
  359. item.text,
  360. style: const TextStyle(
  361. color: Colors.black,
  362. ),
  363. ),
  364. ),
  365. ],
  366. );
  367. }
  368. static void onChanged(BuildContext context, MenuItem item) {
  369. switch (item) {
  370. case ProjectItems.add:
  371. context.go('/addproject');
  372. break;
  373. case ProjectItems.edit:
  374. context.go('/editproject');
  375. break;
  376. case ProjectItems.list:
  377. context.go('/listproject');
  378. break;
  379. case ProjectItems.addMember:
  380. context.go('/addmember');
  381. break;
  382. case ProjectItems.listMember:
  383. context.go('/listplatform/listmember');
  384. break;
  385. }
  386. }
  387. }
  388. mixin LogoutItems {
  389. static const List<MenuItem> firstItems = [changepass, logout];
  390. static const logout = MenuItem(text: 'Log Out');
  391. static const changepass = MenuItem(text: 'Change Password');
  392. static Widget buildItem(MenuItem item) {
  393. return Row(
  394. children: [
  395. Expanded(
  396. child: Text(
  397. item.text,
  398. style: const TextStyle(
  399. color: Colors.black,
  400. ),
  401. ),
  402. ),
  403. ],
  404. );
  405. }
  406. static void onChanged(BuildContext context, MenuItem item) {
  407. switch (item) {
  408. case LogoutItems.changepass:
  409. context.go('/changepass');
  410. break;
  411. case LogoutItems.logout:
  412. // context.go('/editproject');
  413. break;
  414. }
  415. }
  416. }