diff --git a/frontend/lib/screens/home_screen/home_screen.dart b/frontend/lib/screens/home_screen/home_screen.dart index 7a35068..8939c8a 100644 --- a/frontend/lib/screens/home_screen/home_screen.dart +++ b/frontend/lib/screens/home_screen/home_screen.dart @@ -1,12 +1,19 @@ +import 'dart:convert'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:google_sign_in/google_sign_in.dart'; import 'package:leturn/api/google_signin_api.dart'; import 'package:leturn/const/colors.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:http/http.dart' as http; import 'package:leturn/screens/page_view.dart'; import 'package:leturn/screens/login/login_page.dart'; +import 'package:leturn/screens/user_folder.dart'; + +import '../../const/Server.dart'; +var token; class HomeScreen extends StatelessWidget{ const HomeScreen({Key? key}) : super(key: key); @@ -92,7 +99,12 @@ class _Buttons extends StatelessWidget{ ) ], ), - onPressed: signIn, + onPressed: () async { + //bool result = nextPage(); + if(await nextPage()) { + Navigator.push(context, MaterialPageRoute(builder: (context) => FolderPage())); + } + }, ), ), //2. 카카오 로그인 @@ -141,13 +153,34 @@ class _Buttons extends StatelessWidget{ final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn(); final GoogleSignInAuthentication? googleAuth = await googleUser?.authentication; - if(googleAuth == null){ - print("auth is null"); + if(googleAuth == null) { + print("google login error >>> googleAuth is null"); }else{ - var acct = googleAuth!.accessToken; - print("success: ${acct.toString()}"); + String url = '$serverHttp/login/google'; + //final req = jsonEncode({'access_token':googleAuth!.accessToken.toString()}); + final req = jsonEncode({'access_token':'accessToken'}); + + http.Response response = await http.post(Uri.parse(url),body: req); + + if(response.statusCode == 200){ + token = jsonDecode(response.body)["token"]; + print("token : $token"); + //저장소에 토큰 저장 + }else{ + print(response.statusCode.toString()); + } } } + Future nextPage() async{ + await signIn(); + if(token == null){ + return false; + }else{ + return true; + } + } + + } \ No newline at end of file