Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leeyj #8

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ android {
applicationId "com.example.cs496_2nd_week"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion flutter.minSdkVersion
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
13 changes: 13 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@
android:label="cs496_2nd_week"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">

<activity android:name="com.kakao.sdk.flutter.AuthCodeCustomTabsActivity">
<intent-filter android:label="flutter_web_auth">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<!-- Redirect URI, "kakao${YOUR_NATIVE_APP_KEY}://oauth" 형식 -->
<data android:scheme="kakao9605435e2388fdc026ed845e3772ecca" android:host="oauth"/>
</intent-filter>
</activity>


<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
Binary file added assets/images/kakaotalk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import 'package:cs496_2nd_week/pages/signup_page.dart';
import 'package:cs496_2nd_week/pages/my_info.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter/material.dart';
import 'package:kakao_flutter_sdk_user/kakao_flutter_sdk_user.dart';

void main() async {
await dotenv.load(fileName: '.env');
KakaoSdk.init(nativeAppKey: '9605435e2388fdc026ed845e3772ecca');
runApp(const MainApp());
}

Expand Down
2 changes: 1 addition & 1 deletion lib/pages/login_email_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class _LoginEmailPageState extends State<LoginEmailPage> {
key: 'token',
value: jsonDecode(response.body)['token'],
); //storage.delete(key: "login");
Navigator.pushReplacement(context, FadePageRoute(MainPage(token: '${idController.text}.${passController.text}')));
Navigator.pushReplacement(context, FadePageRoute(MainPage(token: jsonDecode(response.body)['token'])));
}
else {
print('wrong id or password');
Expand Down
193 changes: 103 additions & 90 deletions lib/pages/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,117 +2,130 @@ import 'package:cs496_2nd_week/pages/login_email_page.dart';
import 'package:cs496_2nd_week/pages/main_page.dart';
import 'package:cs496_2nd_week/pages/signup_page.dart';
import 'package:cs496_2nd_week/utils/fade_page_route.dart';
import 'package:cs496_2nd_week/widgets/kakao_login.dart';
import 'package:cs496_2nd_week/widgets/main_view_model.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/foundation/key.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'dart:developer';

import 'package:flutter_secure_storage/flutter_secure_storage.dart';

class LoginPage extends StatelessWidget {
const LoginPage({Key? key}) : super(key: key);
class LoginPage extends StatefulWidget {
LoginPage({Key? key}) : super(key: key);
final viewModel = MainViewModel(KakaoLogin());
static const storage = FlutterSecureStorage();

@override
State<LoginPage> createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: MediaQuery.of(context).size.width * 0.8 < 500 ? MediaQuery.of(context).size.width * 0.8 : 500,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Align(
alignment: Alignment.centerLeft,
child: Text('Welcome to App!', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 28), ),
),
const SizedBox(height: 10,),
const Align(
alignment: Alignment.centerLeft,
child: Text('App은 자신이 만든 프로젝트를 공유하고 발전시킬 수 있는 플랫폼입니다', style: TextStyle(fontSize: 16), ),
),
const SizedBox(height: 10,),
OutlinedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
minimumSize: const Size.fromHeight(40)
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset('assets/images/login_googleIcon.png', width: 20, height: 20, ),
const SizedBox(width: 8),
const Text('Continue with Google', style: TextStyle(color: Color.fromARGB(255, 66, 66, 66)), )
],
body: Center(
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: MediaQuery.of(context).size.width * 0.8 < 500 ? MediaQuery.of(context).size.width * 0.8 : 500,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Align(
alignment: Alignment.centerLeft,
child: Text('Welcome to App!', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 28), ),
),
),
OutlinedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
minimumSize: const Size.fromHeight(40)
const SizedBox(height: 10,),
const Align(
alignment: Alignment.centerLeft,
child: Text('App은 자신이 만든 프로젝트를 공유하고 발전시킬 수 있는 플랫폼입니다', style: TextStyle(fontSize: 16), ),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Icon(Icons.facebook, color: Colors.blue),
SizedBox(width: 8),
Text('Continue with Facebook', style: TextStyle(color: Color.fromARGB(255, 66, 66, 66)), )
],
const SizedBox(height: 10,),
OutlinedButton(
onPressed: () async {
await widget.viewModel.login();
setState((){});
if(widget.viewModel.user?.kakaoAccount?.email != null)
Navigator.pushReplacement(context, FadePageRoute(MainPage(token: widget.viewModel.user?.kakaoAccount?.email)));
},
style: ElevatedButton.styleFrom(
minimumSize: const Size.fromHeight(40)
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Image.asset('assets/images/login_googleIcon.png', width: 20, height: 20, ),
Image.asset('assets/images/kakaotalk.png',width:20, height: 20,),
const SizedBox(width: 8),
const Text('Continue with Kakao', style: TextStyle(color: Color.fromARGB(255, 66, 66, 66)), )
],
),
),
),
const SizedBox(height: 8,),
Row(
children: const <Widget>[
Expanded(
child: Divider(color: Colors.black54,)
OutlinedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
minimumSize: const Size.fromHeight(40)
),
SizedBox(width:8, ),
Text("OR"),
SizedBox(width:8, ),
Expanded(
child: Divider(color: Colors.black54,)
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Icon(Icons.facebook, color: Colors.blue),
SizedBox(width: 8),
Text('Continue with Facebook', style: TextStyle(color: Color.fromARGB(255, 66, 66, 66)), )
],
),
],
),
const SizedBox(height: 8,),
OutlinedButton(
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => const LoginEmailPage()),);
},
style: ElevatedButton.styleFrom(
minimumSize: const Size.fromHeight(40),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Icon(Icons.mail_outlined, color: Color.fromARGB(255, 66, 66, 66),),
SizedBox(width: 8),
Text('Continue with Email', style: TextStyle(color: Color.fromARGB(255, 66, 66, 66)), )
const SizedBox(height: 8,),
Row(
children: const <Widget>[
Expanded(
child: Divider(color: Colors.black54,)
),
SizedBox(width:8, ),
Text("OR"),
SizedBox(width:8, ),
Expanded(
child: Divider(color: Colors.black54,)
),
],
),
),
SizedBox(height: 2,),
Align(
alignment: Alignment.centerRight,
child: RichText(
text: TextSpan(
text: 'Register as New Email User',
style: const TextStyle(color: Color.fromARGB(255, 66, 66, 66), decoration: TextDecoration.underline),
recognizer: TapGestureRecognizer()..onTap = () {
Navigator.push(context, MaterialPageRoute(builder: (context) => const SignupPage()),);
},
const SizedBox(height: 8,),
OutlinedButton(
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => const LoginEmailPage()),);
},
style: ElevatedButton.styleFrom(
minimumSize: const Size.fromHeight(40),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Icon(Icons.mail_outlined, color: Color.fromARGB(255, 66, 66, 66),),
SizedBox(width: 8),
Text('Continue with Email', style: TextStyle(color: Color.fromARGB(255, 66, 66, 66)), )
],
),
),
SizedBox(height: 2,),
Align(
alignment: Alignment.centerRight,
child: RichText(
text: TextSpan(
text: 'Register as New Email User',
style: const TextStyle(color: Color.fromARGB(255, 66, 66, 66), decoration: TextDecoration.underline),
recognizer: TapGestureRecognizer()..onTap = () {
Navigator.push(context, MaterialPageRoute(builder: (context) => const SignupPage()),);
},
),
),
),
),
],
],
),
),
),
),
)
)
);
}
}
}
Loading