123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- 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(
- items: [
- DropdownMenuItem(
- child: Text('Home'),
- )
- ],
- onChanged: (value) => context.go('/'),
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8.0),
- child: DropdownButtonHideUnderline(
- child: DropdownButton2(
- customButton: Text(
- 'Bug',
- style: TextStyle(fontSize: 15),
- ),
- items: [
- ...MenuItems2.firstItems.map(
- (item) => DropdownMenuItem<MenuItem>(
- value: item,
- child: MenuItems2.buildItem(item),
- ),
- ),
- ],
- onChanged: (value) {
- MenuItems2.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(MenuItems2.firstItems.length, 48),
- ],
- padding: const EdgeInsets.only(left: 16, right: 16),
- ),
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8.0),
- child: DropdownButtonHideUnderline(
- child: DropdownButton2(
- customButton: Text(
- 'Platform',
- style: TextStyle(fontSize: 15),
- ),
- items: [
- ...MenuItems.firstItems.map(
- (item) => DropdownMenuItem<MenuItem>(
- value: item,
- child: MenuItems.buildItem(item),
- ),
- ),
- ],
- onChanged: (value) {
- MenuItems.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(MenuItems.firstItems.length, 48),
- ],
- padding: const EdgeInsets.only(left: 16, right: 16),
- ),
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8),
- child: DropdownButtonHideUnderline(
- child: DropdownButton2(
- items: [
- DropdownMenuItem(
- child: Text('Maintenance'),
- )
- ],
- onChanged: (value) => context.go('/maintenance'),
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 6),
- child: DropdownButtonHideUnderline(
- child: DropdownButton2(
- items: [
- DropdownMenuItem(
- child: Text('Log Out'),
- )
- ],
- onChanged: null,
- ),
- ),
- ),
- ],
- );
- }
- }
- class MenuItem {
- const MenuItem({
- required this.text,
- });
- final String text;
- }
- abstract class MenuItems {
- 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 MenuItems.add:
- context.go('/addplatform');
- break;
- case MenuItems.edit:
- context.go('/listplatform/editplatform');
- break;
- case MenuItems.list:
- context.go('/listplatform');
- break;
- }
- }
- }
- abstract class MenuItems2 {
- static const List<MenuItem> firstItems = [add, edit, list];
- static const add = MenuItem(text: 'Add Bug');
- static const edit = MenuItem(text: 'Edit Bug');
- static const list = MenuItem(text: 'List Bug');
- 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 MenuItems2.add:
- context.go('/addbug');
- break;
- case MenuItems2.edit:
- context.go('/login/bug/editbug');
- break;
- case MenuItems2.list:
- context.go('/login/bug');
- break;
- }
- }
- }
- // class Header extends StatelessWidget implements PreferredSizeWidget {
- // final Text title;
- // final AppBar appBar;
- // final List<Widget> widgets;
- // const Header(
- // {super.key,
- // required this.title,
- // required this.appBar,
- // required this.widgets});
- // @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: [
- // //todo hide kalo non login
- // ElevatedButton(
- // onPressed: () => context.go('/'),
- // style: ElevatedButton.styleFrom(surfaceTintColor: Colors.white),
- // child: Text(
- // 'Home',
- // style: TextStyle(color: Colors.black),
- // )),
- // ElevatedButton(
- // onPressed: () => context.go('/listplatform'),
- // style: ElevatedButton.styleFrom(surfaceTintColor: Colors.white),
- // child: Text(
- // 'Platform',
- // style: TextStyle(color: Colors.black),
- // ),
- // ),
- // ElevatedButton(
- // onPressed: () => context.go('/maintenance'),
- // style: ElevatedButton.styleFrom(surfaceTintColor: Colors.white),
- // child: Text(
- // 'Maintenance',
- // style: TextStyle(color: Colors.black),
- // ),
- // ),
- // Text('Log Out'),
- // ],
- // );
- // }
- // @override
- // Size get preferredSize => Size.fromHeight(appBar.preferredSize.height);
- // }
|