|
@@ -1,14 +1,26 @@
|
|
|
+import 'dart:convert';
|
|
|
+
|
|
|
+import 'package:dio/dio.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
-import 'package:go_router/go_router.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:dio/dio.dart';
|
|
|
+// import 'package:namer_app/models/user_model.dart';
|
|
|
+// import 'package:namer_app/services/login_service.dart';
|
|
|
+// import 'package:namer_app/header.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'),
|
|
@@ -55,6 +67,7 @@ class LoginPage extends StatelessWidget {
|
|
|
fillColor: Colors.white.withOpacity(0.25)),
|
|
|
cursorColor: Colors.black,
|
|
|
style: TextStyle(color: Colors.black),
|
|
|
+ controller: usernameController,
|
|
|
),
|
|
|
),
|
|
|
),
|
|
@@ -77,6 +90,7 @@ class LoginPage extends StatelessWidget {
|
|
|
fillColor: Colors.white.withOpacity(0.25)),
|
|
|
cursorColor: Colors.black,
|
|
|
style: TextStyle(color: Colors.black),
|
|
|
+ controller: passwordController,
|
|
|
),
|
|
|
),
|
|
|
Padding(
|
|
@@ -85,7 +99,12 @@ class LoginPage extends StatelessWidget {
|
|
|
width: 396,
|
|
|
height: 61,
|
|
|
child: ElevatedButton(
|
|
|
- onPressed: () => context.go('/login/bug'),
|
|
|
+ onPressed: () async {
|
|
|
+ response = await dio.post('http://localhost:8080/api/v1',
|
|
|
+ options: Options(headers: <String, String>{
|
|
|
+ 'authorization': auth
|
|
|
+ }));
|
|
|
+ },
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
backgroundColor: Colors.black, //todo putih lage
|
|
|
side: BorderSide(color: Colors.white),
|