123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443 |
- import 'package:dropdown_button2/dropdown_button2.dart';
- import 'package:flutter/material.dart';
- import 'package:go_router/go_router.dart';
- class CustomAppbar extends StatefulWidget implements PreferredSizeWidget {
- final bool? isBack;
- final TextEditingController? controller;
- const CustomAppbar({super.key, this.isBack, this.controller});
- @override
- State<CustomAppbar> createState() => _CustomAppbarState();
- @override
- Size get preferredSize => Size(15, 50);
- }
- class _CustomAppbarState extends State<CustomAppbar> {
- @override
- Widget build(BuildContext context) {
- return AppBar(
- backgroundColor: Colors.white,
- leading: Icon(Icons.bug_report),
- titleSpacing: 0,
- title: Text(
- 'Bug Listing',
- style: TextStyle(fontSize: 28, fontWeight: FontWeight.w500),
- ),
- actions: [
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8.0),
- child: DropdownButtonHideUnderline(
- child: DropdownButton2(
- customButton: const Icon(Icons.home),
- onChanged: (value) => context.go('/'),
- items: [
- DropdownMenuItem(
- child: Text('Home'),
- )
- ],
- dropdownStyleData: DropdownStyleData(
- width: 80,
- padding: const EdgeInsets.symmetric(vertical: 6),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(4),
- ),
- offset: const Offset(0, 8),
- ),
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8.0),
- child: DropdownButtonHideUnderline(
- child: DropdownButton2(
- customButton: const Icon(Icons.person),
- items: [
- ...UserItems.firstItems.map(
- (item) => DropdownMenuItem<MenuItem>(
- value: item,
- child: UserItems.buildItem(item),
- ),
- ),
- ],
- onChanged: (value) {
- UserItems.onChanged(context, value!);
- },
- dropdownStyleData: DropdownStyleData(
- width: 100,
- padding: const EdgeInsets.symmetric(vertical: 6),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(4),
- ),
- offset: const Offset(0, 8),
- ),
- menuItemStyleData: MenuItemStyleData(
- customHeights: [
- ...List<double>.filled(UserItems.firstItems.length, 48),
- ],
- padding: const EdgeInsets.only(left: 16, right: 16),
- ),
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8.0),
- child: DropdownButtonHideUnderline(
- child: DropdownButton2(
- customButton: const Icon(Icons.bug_report),
- items: [
- ...BugItems.firstItems.map(
- (item) => DropdownMenuItem<MenuItem>(
- value: item,
- child: BugItems.buildItem(item),
- ),
- ),
- ],
- onChanged: (value) {
- BugItems.onChanged(context, value!);
- },
- dropdownStyleData: DropdownStyleData(
- width: 120,
- padding: const EdgeInsets.symmetric(vertical: 6),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(4),
- ),
- offset: const Offset(0, 8),
- ),
- menuItemStyleData: MenuItemStyleData(
- customHeights: [
- ...List<double>.filled(BugItems.firstItems.length, 48),
- ],
- padding: const EdgeInsets.only(left: 16, right: 16),
- ),
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8.0),
- child: DropdownButtonHideUnderline(
- child: DropdownButton2(
- customButton: const Icon(Icons.build),
- items: [
- ...ProjectItems.firstItems.map(
- (item) => DropdownMenuItem<MenuItem>(
- value: item,
- child: ProjectItems.buildItem(item),
- ),
- ),
- ],
- onChanged: (value) {
- ProjectItems.onChanged(context, value!);
- },
- dropdownStyleData: DropdownStyleData(
- width: 150,
- padding: const EdgeInsets.symmetric(vertical: 6),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(4),
- ),
- offset: const Offset(0, 8),
- ),
- menuItemStyleData: MenuItemStyleData(
- customHeights: [
- ...List<double>.filled(ProjectItems.firstItems.length, 48),
- ],
- padding: const EdgeInsets.only(left: 16, right: 16),
- ),
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8.0),
- child: DropdownButtonHideUnderline(
- child: DropdownButton2(
- customButton: const Icon(Icons.dynamic_form),
- items: [
- ...PlatformItems.firstItems.map(
- (item) => DropdownMenuItem<MenuItem>(
- value: item,
- child: PlatformItems.buildItem(item),
- ),
- ),
- ],
- onChanged: (value) {
- PlatformItems.onChanged(context, value!);
- },
- dropdownStyleData: DropdownStyleData(
- width: 150,
- padding: const EdgeInsets.symmetric(vertical: 6),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(4),
- ),
- offset: const Offset(0, 8),
- ),
- menuItemStyleData: MenuItemStyleData(
- customHeights: [
- ...List<double>.filled(PlatformItems.firstItems.length, 48),
- ],
- padding: const EdgeInsets.only(left: 16, right: 16),
- ),
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8),
- child: DropdownButtonHideUnderline(
- child: DropdownButton2(
- customButton: const Icon(Icons.pan_tool),
- items: [
- DropdownMenuItem(
- child: Text('Maintenance'),
- )
- ],
- onChanged: (value) => context.go('/maintenance'),
- dropdownStyleData: DropdownStyleData(
- width: 130,
- padding: const EdgeInsets.symmetric(vertical: 6),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(4),
- ),
- offset: const Offset(0, 8),
- ),
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8.0),
- child: DropdownButtonHideUnderline(
- child: DropdownButton2(
- customButton: const Icon(Icons.logout),
- items: [
- ...LogoutItems.firstItems.map(
- (item) => DropdownMenuItem<MenuItem>(
- value: item,
- child: LogoutItems.buildItem(item),
- ),
- ),
- ],
- onChanged: (value) {
- LogoutItems.onChanged(context, value!);
- },
- dropdownStyleData: DropdownStyleData(
- width: 170,
- padding: const EdgeInsets.symmetric(vertical: 6),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(4),
- ),
- offset: const Offset(0, 8),
- ),
- menuItemStyleData: MenuItemStyleData(
- customHeights: [
- ...List<double>.filled(LogoutItems.firstItems.length, 48),
- ],
- padding: const EdgeInsets.only(left: 16, right: 16),
- ),
- ),
- ),
- ),
- ],
- );
- }
- }
- class MenuItem {
- const MenuItem({
- required this.text,
- });
- final String text;
- }
- mixin PlatformItems {
- static const List<MenuItem> firstItems = [add, edit, list];
- static const add = MenuItem(text: 'Add Platform');
- static const edit = MenuItem(text: 'Edit Platform');
- static const list = MenuItem(text: 'List Platform');
- static Widget buildItem(MenuItem item) {
- return Row(
- children: [
- Expanded(
- child: Text(
- item.text,
- style: const TextStyle(
- color: Colors.black,
- ),
- ),
- ),
- ],
- );
- }
- static void onChanged(BuildContext context, MenuItem item) {
- switch (item) {
- case PlatformItems.add:
- context.go('/addplatform');
- break;
- case PlatformItems.edit:
- context.go('/listplatform/editplatform');
- break;
- case PlatformItems.list:
- context.go('/listplatform');
- break;
- }
- }
- }
- mixin BugItems {
- static const List<MenuItem> firstItems = [add, edit, list/*, listcomment*/];
- static const add = MenuItem(text: 'Add Bug');
- static const edit = MenuItem(text: 'Edit Bug');
- static const list = MenuItem(text: 'List Bug');
- static const listcomment = MenuItem(text: 'List Comment');
- static Widget buildItem(MenuItem item) {
- return Row(
- children: [
- Expanded(
- child: Text(
- item.text,
- style: const TextStyle(
- color: Colors.black,
- ),
- ),
- ),
- ],
- );
- }
- static void onChanged(BuildContext context, MenuItem item) {
- switch (item) {
- case BugItems.add:
- context.go('/addbug');
- break;
- case BugItems.edit:
- context.go('/login/bug/editbug');
- break;
- case BugItems.list:
- context.go('/login/bug');
- break;
- case BugItems.listcomment:
- context.go('/listcomment');
- break;
- }
- }
- }
- mixin UserItems {
- static const List<MenuItem> firstItems = [/*edit, change,*/ list];
- static const edit = MenuItem(text: 'Edit User');
- static const change = MenuItem(text: 'Edit Password');
- static const list = MenuItem(text: 'List User');
- static Widget buildItem(MenuItem item) {
- return Row(
- children: [
- Expanded(
- child: Text(
- item.text,
- style: const TextStyle(
- color: Colors.black,
- ),
- ),
- ),
- ],
- );
- }
- static void onChanged(BuildContext context, MenuItem item) {
- switch (item) {
- // case UserItems.edit:
- // context.go('/signup/listuser/edit');
- // break;
- // case UserItems.change:
- // context.go('/login/bug/editbug');
- // break;
- case UserItems.list:
- context.go('/signup/listuser');
- break;
- }
- }
- }
- mixin ProjectItems {
- static const List<MenuItem> firstItems = [add, edit, list, /*addMember, listMember*/];
- static const add = MenuItem(text: 'Add Project');
- static const edit = MenuItem(text: 'Edit Project');
- static const list = MenuItem(text: 'List Project');
- static const addMember = MenuItem(text: 'Add Member');
- static const listMember = MenuItem(text: 'List Member');
- static Widget buildItem(MenuItem item) {
- return Row(
- children: [
- Expanded(
- child: Text(
- item.text,
- style: const TextStyle(
- color: Colors.black,
- ),
- ),
- ),
- ],
- );
- }
- static void onChanged(BuildContext context, MenuItem item) {
- switch (item) {
- case ProjectItems.add:
- context.go('/addproject');
- break;
- case ProjectItems.edit:
- context.go('/editproject');
- break;
- case ProjectItems.list:
- context.go('/listproject');
- break;
- case ProjectItems.addMember:
- context.go('/addmember');
- break;
- case ProjectItems.listMember:
- context.go('/listplatform/listmember');
- break;
- }
- }
- }
- mixin LogoutItems {
- static const List<MenuItem> firstItems = [changepass, logout];
- static const logout = MenuItem(text: 'Log Out');
- static const changepass = MenuItem(text: 'Change Password');
- static Widget buildItem(MenuItem item) {
- return Row(
- children: [
- Expanded(
- child: Text(
- item.text,
- style: const TextStyle(
- color: Colors.black,
- ),
- ),
- ),
- ],
- );
- }
- static void onChanged(BuildContext context, MenuItem item) {
- switch (item) {
- case LogoutItems.changepass:
- context.go('/changepass');
- break;
- case LogoutItems.logout:
- // context.go('/editproject');
- break;
- }
- }
- }
|