head.dart 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. import 'package:dropdown_button2/dropdown_button2.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:go_router/go_router.dart';
  4. import 'package:namer_app/test.dart';
  5. import 'package:namer_app/token.dart';
  6. class CustomAppbar extends StatefulWidget implements PreferredSizeWidget {
  7. final bool? isBack;
  8. final TextEditingController? controller;
  9. const CustomAppbar({super.key, this.isBack, this.controller});
  10. @override
  11. State<CustomAppbar> createState() => _CustomAppbarState();
  12. @override
  13. Size get preferredSize => Size(15, 50);
  14. }
  15. class _CustomAppbarState extends State<CustomAppbar> {
  16. @override
  17. Widget build(BuildContext context) {
  18. return AppBar(
  19. backgroundColor: Colors.white,
  20. leading: Icon(Icons.bug_report),
  21. titleSpacing: 0,
  22. title: Text(
  23. 'Bug Listing',
  24. style: TextStyle(fontSize: 28, fontWeight: FontWeight.w500),
  25. ),
  26. actions: [
  27. Padding(
  28. padding: const EdgeInsets.symmetric(horizontal: 8.0),
  29. child: DropdownButtonHideUnderline(
  30. child: DropdownButton2(
  31. items: [
  32. DropdownMenuItem(
  33. child: Text('Home'),
  34. )
  35. ],
  36. onChanged: (value) => context.go('/'),
  37. ),
  38. ),
  39. ),
  40. Padding(
  41. padding: const EdgeInsets.symmetric(horizontal: 8.0),
  42. child: DropdownButtonHideUnderline(
  43. child: DropdownButton2(
  44. customButton: Text(
  45. 'Bug',
  46. style: TextStyle(fontSize: 15),
  47. ),
  48. items: [
  49. ...MenuItems2.firstItems.map(
  50. (item) => DropdownMenuItem<MenuItem>(
  51. value: item,
  52. child: MenuItems2.buildItem(item),
  53. ),
  54. ),
  55. ],
  56. onChanged: (value) {
  57. MenuItems2.onChanged(context, value!);
  58. },
  59. dropdownStyleData: DropdownStyleData(
  60. width: 150,
  61. padding: const EdgeInsets.symmetric(vertical: 6),
  62. decoration: BoxDecoration(
  63. borderRadius: BorderRadius.circular(4),
  64. ),
  65. offset: const Offset(0, 8),
  66. ),
  67. menuItemStyleData: MenuItemStyleData(
  68. customHeights: [
  69. ...List<double>.filled(MenuItems2.firstItems.length, 48),
  70. ],
  71. padding: const EdgeInsets.only(left: 16, right: 16),
  72. ),
  73. ),
  74. ),
  75. ),
  76. Padding(
  77. padding: const EdgeInsets.symmetric(horizontal: 8.0),
  78. child: DropdownButtonHideUnderline(
  79. child: DropdownButton2(
  80. customButton: Text(
  81. 'Platform',
  82. style: TextStyle(fontSize: 15),
  83. ),
  84. items: [
  85. ...MenuItems.firstItems.map(
  86. (item) => DropdownMenuItem<MenuItem>(
  87. value: item,
  88. child: MenuItems.buildItem(item),
  89. ),
  90. ),
  91. ],
  92. onChanged: (value) {
  93. MenuItems.onChanged(context, value!);
  94. },
  95. dropdownStyleData: DropdownStyleData(
  96. width: 150,
  97. padding: const EdgeInsets.symmetric(vertical: 6),
  98. decoration: BoxDecoration(
  99. borderRadius: BorderRadius.circular(4),
  100. ),
  101. offset: const Offset(0, 8),
  102. ),
  103. menuItemStyleData: MenuItemStyleData(
  104. customHeights: [
  105. ...List<double>.filled(MenuItems.firstItems.length, 48),
  106. ],
  107. padding: const EdgeInsets.only(left: 16, right: 16),
  108. ),
  109. ),
  110. ),
  111. ),
  112. Padding(
  113. padding: const EdgeInsets.symmetric(horizontal: 8),
  114. child: DropdownButtonHideUnderline(
  115. child: DropdownButton2(
  116. items: [
  117. DropdownMenuItem(
  118. child: Text('Maintenance'),
  119. )
  120. ],
  121. onChanged: (value) => context.go('/maintenance'),
  122. ),
  123. ),
  124. ),
  125. Padding(
  126. padding: const EdgeInsets.symmetric(horizontal: 6),
  127. child: DropdownButtonHideUnderline(
  128. child: DropdownButton2(
  129. items: [
  130. DropdownMenuItem(
  131. child: Text('Log Out'),
  132. )
  133. ],
  134. onChanged: callAPI,
  135. ),
  136. ),
  137. ),
  138. ],
  139. );
  140. }
  141. }
  142. class MenuItem {
  143. const MenuItem({
  144. required this.text,
  145. });
  146. final String text;
  147. }
  148. abstract class MenuItems {
  149. static const List<MenuItem> firstItems = [add, edit, list];
  150. static const add = MenuItem(text: 'Add Platform');
  151. static const edit = MenuItem(text: 'Edit Platform');
  152. static const list = MenuItem(text: 'List Platform');
  153. static Widget buildItem(MenuItem item) {
  154. return Row(
  155. children: [
  156. Expanded(
  157. child: Text(
  158. item.text,
  159. style: const TextStyle(
  160. color: Colors.black,
  161. ),
  162. ),
  163. ),
  164. ],
  165. );
  166. }
  167. static void onChanged(BuildContext context, MenuItem item) {
  168. switch (item) {
  169. case MenuItems.add:
  170. context.go('/addplatform');
  171. break;
  172. case MenuItems.edit:
  173. context.go('/listplatform/editplatform');
  174. break;
  175. case MenuItems.list:
  176. context.go('/listplatform');
  177. break;
  178. }
  179. }
  180. }
  181. abstract class MenuItems2 {
  182. static const List<MenuItem> firstItems = [add, edit, list];
  183. static const add = MenuItem(text: 'Add Bug');
  184. static const edit = MenuItem(text: 'Edit Bug');
  185. static const list = MenuItem(text: 'List Bug');
  186. static Widget buildItem(MenuItem item) {
  187. return Row(
  188. children: [
  189. Expanded(
  190. child: Text(
  191. item.text,
  192. style: const TextStyle(
  193. color: Colors.black,
  194. ),
  195. ),
  196. ),
  197. ],
  198. );
  199. }
  200. static void onChanged(BuildContext context, MenuItem item) {
  201. switch (item) {
  202. case MenuItems2.add:
  203. context.go('/addbug');
  204. break;
  205. case MenuItems2.edit:
  206. context.go('/login/bug/editbug');
  207. break;
  208. case MenuItems2.list:
  209. context.go('/login/bug');
  210. break;
  211. }
  212. }
  213. }
  214. // class Header extends StatelessWidget implements PreferredSizeWidget {
  215. // final Text title;
  216. // final AppBar appBar;
  217. // final List<Widget> widgets;
  218. // const Header(
  219. // {super.key,
  220. // required this.title,
  221. // required this.appBar,
  222. // required this.widgets});
  223. // @override
  224. // Widget build(BuildContext context) {
  225. // return AppBar(
  226. // backgroundColor: Colors.white,
  227. // leading: Icon(Icons.bug_report),
  228. // titleSpacing: 0,
  229. // title: Text(
  230. // 'Bug Listing',
  231. // style: TextStyle(fontSize: 28, fontWeight: FontWeight.w500),
  232. // ),
  233. // actions: [
  234. // //todo hide kalo non login
  235. // ElevatedButton(
  236. // onPressed: () => context.go('/'),
  237. // style: ElevatedButton.styleFrom(surfaceTintColor: Colors.white),
  238. // child: Text(
  239. // 'Home',
  240. // style: TextStyle(color: Colors.black),
  241. // )),
  242. // ElevatedButton(
  243. // onPressed: () => context.go('/listplatform'),
  244. // style: ElevatedButton.styleFrom(surfaceTintColor: Colors.white),
  245. // child: Text(
  246. // 'Platform',
  247. // style: TextStyle(color: Colors.black),
  248. // ),
  249. // ),
  250. // ElevatedButton(
  251. // onPressed: () => context.go('/maintenance'),
  252. // style: ElevatedButton.styleFrom(surfaceTintColor: Colors.white),
  253. // child: Text(
  254. // 'Maintenance',
  255. // style: TextStyle(color: Colors.black),
  256. // ),
  257. // ),
  258. // Text('Log Out'),
  259. // ],
  260. // );
  261. // }
  262. // @override
  263. // Size get preferredSize => Size.fromHeight(appBar.preferredSize.height);
  264. // }