athrainsky 8 місяців тому
батько
коміт
1db7cdac0f

lib/addbug.dart → lib/bug/addbug.dart


lib/editbug.dart → lib/bug/editbug.dart


+ 1 - 1
lib/listbug.dart

@@ -1,6 +1,6 @@
 import 'package:flutter/material.dart';
 import 'package:go_router/go_router.dart';
-import 'package:namer_app/databug.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';

+ 1 - 1
lib/listcomment.dart

@@ -1,5 +1,5 @@
 import 'package:flutter/material.dart';
-import 'package:namer_app/datacomment.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';

lib/databug.dart → lib/data/databug.dart


lib/datacomment.dart → lib/data/datacomment.dart


lib/datamember.dart → lib/data/datamember.dart


lib/dataplatform.dart → lib/data/dataplatform.dart


lib/datatable.dart → lib/data/datatable.dart


lib/datauser.dart → lib/data/datauser.dart


+ 1 - 1
lib/listmember.dart

@@ -1,5 +1,5 @@
 import 'package:flutter/material.dart';
-import 'package:namer_app/datamember.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';

+ 1 - 1
lib/listtable.dart

@@ -1,5 +1,5 @@
 import 'package:flutter/material.dart';
-import 'package:namer_app/datatable.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';

+ 17 - 14
lib/login.dart

@@ -1,13 +1,12 @@
 import 'dart:convert';
-
-import 'package:dio/dio.dart';
+// import 'package:date_format/date_format.dart';
+// 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:dio/dio.dart';
-// import 'package:namer_app/models/user_model.dart';
-// import 'package:namer_app/services/login_service.dart';
+// import 'package:namer_app/services/signIn.dart';
 // import 'package:namer_app/header.dart';
 
 class LoginPage extends StatelessWidget {
@@ -15,12 +14,12 @@ class LoginPage extends StatelessWidget {
 
   @override
   Widget build(BuildContext context) {
-    var dio = Dio();
-    Response response;
+    // var dio = Dio();
+    // Response response;
     final usernameController = TextEditingController();
     final passwordController = TextEditingController();
-    var auth =
-        'Basic ${base64Encode(utf8.encode('$usernameController:$passwordController'))}';
+    // var auth =
+    //     'Basic ${base64Encode(utf8.encode('$usernameController:$passwordController'))}';
     return Scaffold(
       // appBar: Header(
       //   title: Text('title'),
@@ -99,11 +98,15 @@ class LoginPage extends StatelessWidget {
                   width: 396,
                   height: 61,
                   child: ElevatedButton(
-                    onPressed: () async {
-                      response = await dio.post('http://localhost:8080/api/v1',
-                          options: Options(headers: <String, String>{
-                            'authorization': auth
-                          }));
+                    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}');
                     },
                     style: ElevatedButton.styleFrom(
                       backgroundColor: Colors.black, //todo putih lage

+ 10 - 10
lib/main.dart

@@ -1,21 +1,21 @@
 import 'package:flutter/material.dart';
 import 'package:go_router/go_router.dart';
-import 'package:namer_app/addbug.dart';
-import 'package:namer_app/addplatform.dart';
-import 'package:namer_app/editbug.dart';
-import 'package:namer_app/editplatform.dart';
-import 'package:namer_app/edituser.dart';
+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/user/edituser.dart';
 import 'package:namer_app/footer.dart';
 import 'package:namer_app/head.dart';
-import 'package:namer_app/listbug.dart';
-import 'package:namer_app/listcomment.dart';
+import 'package:namer_app/bug/listbug.dart';
+import 'package:namer_app/bug/listcomment.dart';
 import 'package:namer_app/listmember.dart';
-import 'package:namer_app/listplatform.dart';
+import 'package:namer_app/platform/listplatform.dart';
 import 'package:namer_app/listtable.dart';
-import 'package:namer_app/listuser.dart';
+import 'package:namer_app/user/listuser.dart';
 import 'package:namer_app/login.dart';
 import 'package:flutter/rendering.dart';
-import 'package:namer_app/signup.dart';
+import 'package:namer_app/user/signup.dart';
 
 void main() {
   runApp(MyApp());

lib/addplatform.dart → lib/platform/addplatform.dart


lib/editplatform.dart → lib/platform/editplatform.dart


+ 1 - 1
lib/listplatform.dart

@@ -1,6 +1,6 @@
 import 'package:flutter/material.dart';
 import 'package:go_router/go_router.dart';
-import 'package:namer_app/dataplatform.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';

+ 23 - 0
lib/services/signIn.dart

@@ -0,0 +1,23 @@
+// 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;
+}

+ 14 - 0
lib/test.dart

@@ -0,0 +1,14 @@
+import 'dart:convert';
+
+import 'package:dio/dio.dart';
+
+final dio = Dio();
+
+void getHttp() async {
+  String username = 'user';
+  String password = 'password';
+  String basicAuth =
+      'Basic ${base64.encode(utf8.encode('$username:$password'))}';
+  final response = await dio.get('http://localhost:8080/api/v1/projects',options:Options(headers: <String,String>{'authorization': basicAuth}));
+  print(response);
+}

lib/chgpass.dart → lib/user/chgpass.dart


lib/edituser.dart → lib/user/edituser.dart


+ 1 - 1
lib/listuser.dart

@@ -1,6 +1,6 @@
 import 'package:flutter/material.dart';
 import 'package:go_router/go_router.dart';
-import 'package:namer_app/datauser.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';

lib/signup.dart → lib/user/signup.dart


+ 3 - 3
pubspec.lock

@@ -124,10 +124,10 @@ packages:
     dependency: "direct main"
     description:
       name: go_router
-      sha256: "170c46e237d6eb0e6e9f0e8b3f56101e14fb64f787016e42edd74c39cf8b176a"
+      sha256: "7ecb2f391edbca5473db591b48555a8912dde60edd0fb3013bd6743033b2d3f8"
       url: "https://pub.dev"
     source: hosted
-    version: "13.2.0"
+    version: "13.2.1"
   http:
     dependency: "direct main"
     description:
@@ -351,4 +351,4 @@ packages:
     version: "0.5.1"
 sdks:
   dart: ">=3.3.0 <4.0.0"
-  flutter: ">=3.13.0"
+  flutter: ">=3.16.0"

+ 1 - 1
pubspec.yaml

@@ -13,7 +13,7 @@ dependencies:
     sdk: flutter
   english_words: ^4.0.0
   provider: ^6.0.0
-  go_router: ^13.2.0
+  go_router: ^13.2.1
   flutter_layout_grid: ^2.0.5
   date_format: ^2.0.7
   dotted_line: ^3.1.0