|
@@ -1,17 +1,21 @@
|
|
|
|
+import 'package:dropdown_button2/dropdown_button2.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
|
|
-class Header extends StatelessWidget implements PreferredSizeWidget {
|
|
|
|
- final Text title;
|
|
|
|
- final AppBar appBar;
|
|
|
|
- final List<Widget> widgets;
|
|
|
|
|
|
+class CustomAppbar extends StatefulWidget implements PreferredSizeWidget {
|
|
|
|
+ final bool? isBack;
|
|
|
|
+ final TextEditingController? controller;
|
|
|
|
|
|
- const Header(
|
|
|
|
- {super.key,
|
|
|
|
- required this.title,
|
|
|
|
- required this.appBar,
|
|
|
|
- required this.widgets});
|
|
|
|
|
|
+ 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
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Widget build(BuildContext context) {
|
|
return AppBar(
|
|
return AppBar(
|
|
@@ -23,35 +27,255 @@ class Header extends StatelessWidget implements PreferredSizeWidget {
|
|
style: TextStyle(fontSize: 28, fontWeight: FontWeight.w500),
|
|
style: TextStyle(fontSize: 28, fontWeight: FontWeight.w500),
|
|
),
|
|
),
|
|
actions: [
|
|
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),
|
|
|
|
|
|
+ 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(
|
|
child: Text(
|
|
- 'Platform',
|
|
|
|
- style: TextStyle(color: Colors.black),
|
|
|
|
|
|
+ item.text,
|
|
|
|
+ style: const TextStyle(
|
|
|
|
+ color: Colors.black,
|
|
|
|
+ ),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
- ElevatedButton(
|
|
|
|
- onPressed: () => context.go('/maintenance'),
|
|
|
|
- style: ElevatedButton.styleFrom(surfaceTintColor: Colors.white),
|
|
|
|
|
|
+ ],
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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(
|
|
child: Text(
|
|
- 'Maintenance',
|
|
|
|
- style: TextStyle(color: Colors.black),
|
|
|
|
|
|
+ item.text,
|
|
|
|
+ style: const TextStyle(
|
|
|
|
+ color: Colors.black,
|
|
|
|
+ ),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
- Text('Log Out'),
|
|
|
|
],
|
|
],
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
- @override
|
|
|
|
- Size get preferredSize => Size.fromHeight(appBar.preferredSize.height);
|
|
|
|
|
|
+ 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);
|
|
|
|
+// }
|