athrainsky преди 7 месеца
родител
ревизия
ff0360a6e3

+ 25 - 0
.vscode/launch.json

@@ -0,0 +1,25 @@
+{
+    // Use IntelliSense to learn about possible attributes.
+    // Hover to view descriptions of existing attributes.
+    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+    "version": "0.2.0",
+    "configurations": [
+        {
+            "name": "bug",
+            "request": "launch",
+            "type": "dart"
+        },
+        {
+            "name": "bug (profile mode)",
+            "request": "launch",
+            "type": "dart",
+            "flutterMode": "profile"
+        },
+        {
+            "name": "bug (release mode)",
+            "request": "launch",
+            "type": "dart",
+            "flutterMode": "release"
+        }
+    ]
+}

+ 1 - 1
lib/bug/addbug.dart

@@ -1,6 +1,6 @@
 import 'package:flutter/material.dart';
 import 'package:namer_app/footer.dart';
-import 'package:namer_app/head.dart';
+import 'package:namer_app/header.dart';
 
 class AddBugPage extends StatelessWidget {
   const AddBugPage({super.key});

+ 1 - 7
lib/bug/editbug.dart

@@ -1,7 +1,6 @@
 import 'package:flutter/material.dart';
 import 'package:namer_app/footer.dart';
-import 'package:namer_app/head.dart';
-// import 'package:namer_app/header.dart';
+import 'package:namer_app/header.dart';
 
 class EditBugPage extends StatelessWidget {
   const EditBugPage({super.key});
@@ -9,11 +8,6 @@ class EditBugPage extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
     return Scaffold(
-      // appBar: Header(
-      //   title: Text('title'),
-      //   appBar: AppBar(),
-      //   widgets: <Widget>[Icon(Icons.more_vert)],
-      // ),
       appBar: CustomAppbar(),
       backgroundColor: Colors.white,
       body: Stack(children: [

+ 2 - 7
lib/bug/listbug.dart

@@ -2,8 +2,7 @@ import 'package:flutter/material.dart';
 import 'package:go_router/go_router.dart';
 import 'package:namer_app/data/databug.dart';
 import 'package:namer_app/footer.dart';
-import 'package:namer_app/head.dart';
-// import 'package:namer_app/header.dart';
+import 'package:namer_app/header.dart';
 
 class ListBugPage extends StatelessWidget {
   const ListBugPage({super.key});
@@ -11,11 +10,7 @@ class ListBugPage extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
     return Scaffold(
-      // appBar: Header(
-      //   title: Text('title'),
-      //   appBar: AppBar(),
-      //   widgets: <Widget>[Icon(Icons.more_vert)],
-      // ),
+
       appBar: CustomAppbar(),
       body: Stack(children: [
         SingleChildScrollView(

+ 1 - 7
lib/bug/listcomment.dart

@@ -1,8 +1,7 @@
 import 'package:flutter/material.dart';
 import 'package:namer_app/data/datacomment.dart';
 import 'package:namer_app/footer.dart';
-import 'package:namer_app/head.dart';
-// import 'package:namer_app/header.dart';
+import 'package:namer_app/header.dart';
 
 class ListCommentPage extends StatelessWidget {
   const ListCommentPage({super.key});
@@ -10,11 +9,6 @@ class ListCommentPage extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
     return Scaffold(
-      // appBar: Header(
-      //   title: Text('title'),
-      //   appBar: AppBar(),
-      //   widgets: <Widget>[Icon(Icons.more_vert)],
-      // ),
       appBar: CustomAppbar(),
       body: Stack(children: [
         SingleChildScrollView(

+ 3 - 0
lib/globals.dart

@@ -0,0 +1,3 @@
+library my_prj.globals;
+
+String userLogin = '';

+ 0 - 283
lib/head.dart

@@ -1,283 +0,0 @@
-import 'package:dropdown_button2/dropdown_button2.dart';
-import 'package:flutter/material.dart';
-import 'package:go_router/go_router.dart';
-import 'package:namer_app/test.dart';
-import 'package:namer_app/token.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: callAPI,
-            ),
-          ),
-        ),
-      ],
-    );
-  }
-}
-
-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);
-// }

+ 254 - 30
lib/header.dart

@@ -1,17 +1,21 @@
+import 'package:dropdown_button2/dropdown_button2.dart';
 import 'package:flutter/material.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
   Widget build(BuildContext context) {
     return AppBar(
@@ -23,35 +27,255 @@ class Header extends StatelessWidget implements PreferredSizeWidget {
         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),
+        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(
-            '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(
-            '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);
+// }

+ 0 - 78
lib/intercept.dart

@@ -1,78 +0,0 @@
-import 'package:dio/dio.dart';
-import 'package:flutter/material.dart';
-
-class DioPage extends StatefulWidget {
-  @override
-  State<StatefulWidget> createState() {
-    return _DioPageState();
-  }
-}
-
-class _DioPageState extends State<DioPage> {
-
-Dio dio = Dio(
-  BaseOptions(
-    baseUrl: 'http://localhost:8080/api/v1',
-    connectTimeout: Durations.short4,
-    receiveTimeout: Durations.short3,
-  ),
-);
-
-Future<void> fetchData() async {
-  try {
-    Response response = await dio.get('http://localhost:8080/api/v1');
-    print(response.data);
-  } on DioException catch (e) {
-    print(e.message);
-  }
-}
-
-Future<void> postData() async {
-  try {
-    Response response = await dio.post(
-      'http://localhost:8080/api/v1',
-      data: {'key': 'value'},
-    );
-    print(response.data);
-  } on DioException catch (e) {
-    print(e.message);
-  }
-}
-
-Future<String> refreshToken() async {
-  // Perform a request to the refresh token endpoint and return the new access token.
-  // You can replace this with your own implementation.
-  return 'your_new_access_token';
-}
-
-  @override
-  Widget build(BuildContext context) {
-    Function(dynamic options, dynamic handler) onRequest;
-    Future Function(DioException e, dynamic handler) onError;
-    dio.interceptors.add(
-  InterceptorsWrapper(
-    onRequest:  onRequest = (options, handler) {
-      // Add the access token to the request header
-      options.headers['Authorization'] = 'Bearer your_access_token';
-      return handler.next(options);
-    },
-    onError:  onError = (DioException e, handler) async {
-      if (e.response?.statusCode == 401) {
-        // If a 401 response is received, refresh the access token
-        String newAccessToken = await refreshToken();
-
-        // Update the request header with the new access token
-        e.requestOptions.headers['Authorization'] = 'Bearer $newAccessToken';
-
-        // Repeat the request with the updated header
-        return handler.resolve(await dio.fetch(e.requestOptions));
-      }
-      return handler.next(e);
-    },
-  ),
-);
-    throw UnimplementedError();
-  }
-
-
-}

+ 1 - 7
lib/listtable.dart

@@ -1,8 +1,7 @@
 import 'package:flutter/material.dart';
 import 'package:namer_app/data/datatable.dart';
 import 'package:namer_app/footer.dart';
-import 'package:namer_app/head.dart';
-// import 'package:namer_app/header.dart';
+import 'package:namer_app/header.dart';
 
 class ListTablePage extends StatelessWidget {
   const ListTablePage({super.key});
@@ -10,11 +9,6 @@ class ListTablePage extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
     return Scaffold(
-      // appBar: Header(
-      //   title: Text('title'),
-      //   appBar: AppBar(),
-      //   widgets: <Widget>[Icon(Icons.more_vert)],
-      // ),
       appBar: CustomAppbar(),
       body: Stack(children: [
         SingleChildScrollView(

+ 7 - 27
lib/login.dart

@@ -1,31 +1,20 @@
-import 'dart:convert';
-// import 'package:date_format/date_format.dart';
-// import 'package:dio/dio.dart';
+// ignore_for_file: use_build_context_synchronously
+
+import 'package:dio/dio.dart';
 import 'package:flutter/material.dart';
-import 'package:http/http.dart' as http;
-// import 'package:go_router/go_router.dart';
 import 'package:namer_app/footer.dart';
-import 'package:namer_app/head.dart';
-// import 'package:namer_app/services/signIn.dart';
-// import 'package:namer_app/header.dart';
+import 'package:namer_app/header.dart';
+import 'package:namer_app/service/submit.dart';
 
 class LoginPage extends StatelessWidget {
   const LoginPage({super.key});
 
   @override
   Widget build(BuildContext context) {
-    // var dio = Dio();
-    // Response response;
+
     final usernameController = TextEditingController();
     final passwordController = TextEditingController();
-    // var auth =
-    //     'Basic ${base64Encode(utf8.encode('$usernameController:$passwordController'))}';
     return Scaffold(
-      // appBar: Header(
-      //   title: Text('title'),
-      //   appBar: AppBar(),
-      //   widgets: <Widget>[Icon(Icons.more_vert)],
-      // ),
       appBar: CustomAppbar(),
       backgroundColor: Colors.white,
       body: Column(
@@ -98,16 +87,7 @@ class LoginPage extends StatelessWidget {
                   width: 396,
                   height: 61,
                   child: ElevatedButton(
-                    onPressed: () async{
-                      String basicAuth = 'Basic ${base64.encode('usernameController:passwordController' as List<int>)}';
-  var response = await http.post(
-      'http://localhost:8080/api/v1' as Uri,
-      headers: <String, String>{'authorization': basicAuth},
-  );
-
-  print('Response status: ${response.statusCode}');
-  print('Response body: ${response.body}');
-                    },
+                    onPressed: () => submit(context, usernameController.text, passwordController.text),
                     style: ElevatedButton.styleFrom(
                       backgroundColor: Colors.black, //todo putih lage
                       side: BorderSide(color: Colors.white),

+ 2 - 9
lib/main.dart

@@ -4,10 +4,9 @@ import 'package:namer_app/bug/addbug.dart';
 import 'package:namer_app/platform/addplatform.dart';
 import 'package:namer_app/bug/editbug.dart';
 import 'package:namer_app/platform/editplatform.dart';
-import 'package:namer_app/token.dart';
 import 'package:namer_app/user/edituser.dart';
 import 'package:namer_app/footer.dart';
-import 'package:namer_app/head.dart';
+import 'package:namer_app/header.dart';
 import 'package:namer_app/bug/listbug.dart';
 import 'package:namer_app/bug/listcomment.dart';
 import 'package:namer_app/platform/listmember.dart';
@@ -18,6 +17,7 @@ import 'package:namer_app/login.dart';
 import 'package:flutter/rendering.dart';
 import 'package:namer_app/user/signup.dart';
 
+
 void main() {
   runApp(MyApp());
 }
@@ -79,8 +79,6 @@ final _router = GoRouter(
         path: 'addplatform',
         builder: (context, state) => AddPlatformPage(),
       ),
-      GoRoute(path: 'token',
-      builder: (context, state) => TokenPage(),)
     ]),
   ],
 );
@@ -103,11 +101,6 @@ class MyHomePage extends StatelessWidget {
   Widget build(BuildContext context) {
     debugPaintSizeEnabled = false;
     return Scaffold(
-        // appBar: Header(
-        //   title: Text('title'),
-        //   appBar: AppBar(),
-        //   widgets: <Widget>[Icon(Icons.more_vert)],
-        // ),
         appBar: CustomAppbar(),
         body: Container(
           decoration: BoxDecoration(color: Colors.black.withOpacity(0.6)),

+ 1 - 1
lib/platform/addplatform.dart

@@ -1,6 +1,6 @@
 import 'package:flutter/material.dart';
 import 'package:namer_app/footer.dart';
-import 'package:namer_app/head.dart';
+import 'package:namer_app/header.dart';
 
 class AddPlatformPage extends StatelessWidget {
   const AddPlatformPage({super.key});

+ 1 - 7
lib/platform/editplatform.dart

@@ -1,7 +1,6 @@
 import 'package:flutter/material.dart';
 import 'package:namer_app/footer.dart';
-import 'package:namer_app/head.dart';
-// import 'package:namer_app/header.dart';
+import 'package:namer_app/header.dart';
 
 class EditPlatformPage extends StatelessWidget {
   const EditPlatformPage({super.key});
@@ -9,11 +8,6 @@ class EditPlatformPage extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
     return Scaffold(
-      // appBar: Header(
-      //   title: Text('title'),
-      //   appBar: AppBar(),
-      //   widgets: <Widget>[Icon(Icons.more_vert)],
-      // ),
       appBar: CustomAppbar(),
       backgroundColor: Colors.white,
       body: Column(

+ 1 - 7
lib/platform/listmember.dart

@@ -1,8 +1,7 @@
 import 'package:flutter/material.dart';
 import 'package:namer_app/data/datamember.dart';
 import 'package:namer_app/footer.dart';
-import 'package:namer_app/head.dart';
-// import 'package:namer_app/header.dart';
+import 'package:namer_app/header.dart';
 
 class ListMemberPage extends StatelessWidget {
   const ListMemberPage({super.key});
@@ -10,11 +9,6 @@ class ListMemberPage extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
     return Scaffold(
-      // appBar: Header(
-      //   title: Text('title'),
-      //   appBar: AppBar(),
-      //   widgets: <Widget>[Icon(Icons.more_vert)],
-      // ),
       appBar: CustomAppbar(),
       body: Stack(children: [
         SingleChildScrollView(

+ 1 - 7
lib/platform/listplatform.dart

@@ -2,8 +2,7 @@ import 'package:flutter/material.dart';
 import 'package:go_router/go_router.dart';
 import 'package:namer_app/data/dataplatform.dart';
 import 'package:namer_app/footer.dart';
-import 'package:namer_app/head.dart';
-// import 'package:namer_app/header.dart';
+import 'package:namer_app/header.dart';
 
 class ListPlatformPage extends StatelessWidget {
   const ListPlatformPage({super.key});
@@ -11,11 +10,6 @@ class ListPlatformPage extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
     return Scaffold(
-      // appBar: Header(
-      //   title: Text('title'),
-      //   appBar: AppBar(),
-      //   widgets: <Widget>[Icon(Icons.more_vert)],
-      // ),
       appBar: CustomAppbar(),
       body: Stack(children: [
         SingleChildScrollView(

+ 50 - 0
lib/service/submit.dart

@@ -0,0 +1,50 @@
+// ignore_for_file: use_build_context_synchronously
+
+import 'dart:convert';
+import 'package:dio/dio.dart';
+import 'package:flutter/material.dart';
+import 'package:go_router/go_router.dart';
+import 'package:namer_app/globals.dart' as globals;
+
+Future<void> submit(BuildContext context, String email, String password) async {
+    final dio = Dio();
+    Response response;
+    if (email.isEmpty || password.isEmpty) {
+      final snackBar = SnackBar(
+        duration: const Duration(seconds: 5),
+        content: Text("Username dan password harus diisi"),
+        backgroundColor: Colors.red,
+      );
+
+      ScaffoldMessenger.of(context).showSnackBar(snackBar);
+      return;
+    }
+
+    AlertDialog alert2 = AlertDialog(
+      title: Text("Login Gagal"),
+      content: Text("Username atau Password salah"),
+      actions: [
+        TextButton( 
+          child: Text('Ok'),
+          onPressed: () => Navigator.of(context).pop(),
+        ),
+      ],
+    );
+
+        var auth = 'Basic ${base64Encode(utf8.encode('$email:$password'))}';
+        Map<String, String> headers = {
+          'content-type': 'application/json',
+          'accept': 'application/json',
+          'authorization': auth
+      };
+    try{
+      response = await dio.get('http://localhost:8080/api/v1/users', 
+          options: Options(headers: headers));
+          if (response.statusCode == 200){
+              globals.userLogin = email;
+              return context.go('/login/bug');
+          } 
+     }  catch (error){     showDialog(context: context, builder: (context) => alert2);}
+          
+  }
+

+ 0 - 23
lib/services/signIn.dart

@@ -1,23 +0,0 @@
-// ignore_for_file: file_names
-
-import 'package:dio/dio.dart';
-
-
-Future<Response?> signIn(usernameController, passwordController) async {
-  var dio = Dio();
-  try {
-    var response = await dio.post('http://localhost:8080/api/v1',
-        data: {"username": usernameController, "password": passwordController},
-        options: Options(
-          headers: {
-            'Content-Type': 'application/json',
-            'Accept': 'application/json',
-          },
-        ));
-    print(response.data);
-    return response;
-  } catch (e) {
-    print(e.toString());
-  }
-  return null;
-}

+ 0 - 21
lib/test.dart

@@ -1,21 +0,0 @@
-import 'dart:convert';
-import 'package:http/http.dart';
-
-var username = 'user';
-var password = 'password';
-var auth = 'Basic ${base64Encode(utf8.encode('$username:$password'))}';
-
-Map<String, String> headers = {
-    'content-type': 'application/json',
-    'accept': 'application/json',
-    'authorization': auth
- };
-
-Future<Response> callAPI(param) async {
-    
-    Response r = await get(Uri.parse('http://localhost:8080/api/v1/projects'),
-      headers: {'authorization': auth});
-  print(r.statusCode);
-  print(r.body);
-  return r;
-  }

+ 0 - 74
lib/token.dart

@@ -1,74 +0,0 @@
-import 'dart:convert';
-import 'package:flutter/material.dart';
-import 'package:http/http.dart' as http;
-import 'package:dio/dio.dart';
-
-class TokenPage extends StatefulWidget {
-  @override
-  State<StatefulWidget> createState() {
-    return _TokenPageState();
-  }
-}
-
-class _TokenPageState extends State<TokenPage> {
-
-  TextEditingController usernameController = TextEditingController();
-  TextEditingController  passwordController = TextEditingController();
-
-Future<String> authorization() async {
-    var request = http.MultipartRequest(
-        'GET', Uri.parse('http://localhost:8080/api/v1/projects'));
-    request.fields.addAll({
-      'grant_type': 'info',
-      'client_id': 'info',
-      'username': usernameController.text, 
-      'password': passwordController.text, 
-    });
-
-
-    http.StreamedResponse response = await request.send();
-
-    if (response.statusCode == 200) {
-      Map<String, dynamic> auth =
-          jsonDecode(await response.stream.bytesToString());
-
-      return auth['access_token'];
-    } else {
-      return "";
-    }
-  }
-
-  @override
-  Widget build(BuildContext context) {
-    return Scaffold(
-      appBar: AppBar(
-        title: Text('Login'),
-        backgroundColor: Colors.green,
-      ),
-      body: Column(
-        children: [
-          Padding(
-            padding: EdgeInsets.all(8.0),
-            child: TextField(
-              decoration: InputDecoration(labelText: 'username'),
-              controller: usernameController,
-            ),
-          ),
-          Padding(
-            padding: EdgeInsets.all(8.0),
-            child: TextField(
-              decoration: InputDecoration(labelText: 'password'),
-              controller: passwordController,
-            ),
-          ),          
-          ElevatedButton(
-            onPressed: () async {
-              String token = await authorization();
-              print(token); //This will be your token.
-            },
-            child: Text('Login'),),
-        ],
-      ),
-    );
-  }
-}

+ 2 - 8
lib/user/chgpass.dart

@@ -1,6 +1,6 @@
 import 'package:flutter/material.dart';
 import 'package:namer_app/footer.dart';
-import 'package:namer_app/header.dart';
+import '../header.dart';
 
 class ChangepassPage extends StatelessWidget {
   const ChangepassPage({super.key});
@@ -8,11 +8,7 @@ class ChangepassPage extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
     return Scaffold(
-      appBar: Header(
-        title: Text('title'),
-        appBar: AppBar(),
-        widgets: <Widget>[Icon(Icons.more_vert)],
-      ),
+      appBar: CustomAppbar(),
       backgroundColor: Colors.white,
       body: Column(
         mainAxisAlignment: MainAxisAlignment.spaceEvenly,
@@ -33,7 +29,6 @@ class ChangepassPage extends StatelessWidget {
                 padding: const EdgeInsets.all(8.0),
                 child: SizedBox(
                   width: 396,
-                  // height: 51,
                   child: TextField(
                     decoration: InputDecoration(
                         border: OutlineInputBorder(),
@@ -56,7 +51,6 @@ class ChangepassPage extends StatelessWidget {
                 padding: const EdgeInsets.all(8.0),
                 child: SizedBox(
                   width: 396,
-                  // height: 51,
                   child: TextField(
                     decoration: InputDecoration(
                         border: OutlineInputBorder(),

+ 2 - 7
lib/user/edituser.dart

@@ -1,7 +1,7 @@
 import 'package:flutter/material.dart';
 import 'package:namer_app/footer.dart';
-import 'package:namer_app/head.dart';
-// import 'package:namer_app/header.dart';
+import 'package:namer_app/header.dart';
+
 
 class EditUserPage extends StatelessWidget {
   const EditUserPage({super.key});
@@ -9,11 +9,6 @@ class EditUserPage extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
     return Scaffold(
-      // appBar: Header(
-      //   title: Text('title'),
-      //   appBar: AppBar(),
-      //   widgets: <Widget>[Icon(Icons.more_vert)],
-      // ),
       appBar: CustomAppbar(),
       backgroundColor: Colors.white,
       body: Column(

+ 1 - 7
lib/user/listuser.dart

@@ -2,8 +2,7 @@ import 'package:flutter/material.dart';
 import 'package:go_router/go_router.dart';
 import 'package:namer_app/data/datauser.dart';
 import 'package:namer_app/footer.dart';
-import 'package:namer_app/head.dart';
-// import 'package:namer_app/header.dart';
+import 'package:namer_app/header.dart';
 
 class ListUserPage extends StatelessWidget {
   const ListUserPage({super.key});
@@ -11,11 +10,6 @@ class ListUserPage extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
     return Scaffold(
-      // appBar: Header(
-      //   title: Text('title'),
-      //   appBar: AppBar(),
-      //   widgets: <Widget>[Icon(Icons.more_vert)],
-      // ),
       appBar: CustomAppbar(),
       body: Stack(children: [
         SingleChildScrollView(

+ 1 - 7
lib/user/signup.dart

@@ -1,8 +1,7 @@
 import 'package:flutter/material.dart';
 import 'package:go_router/go_router.dart';
 import 'package:namer_app/footer.dart';
-import 'package:namer_app/head.dart';
-// import 'package:namer_app/header.dart';
+import 'package:namer_app/header.dart';
 
 class SignupPage extends StatelessWidget {
   const SignupPage({super.key});
@@ -10,11 +9,6 @@ class SignupPage extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
     return Scaffold(
-      // appBar: Header(
-      //   title: Text('title'),
-      //   appBar: AppBar(),
-      //   widgets: <Widget>[Icon(Icons.more_vert)],
-      // ),
       appBar: CustomAppbar(),
       backgroundColor: Colors.white,
       body: Column(