Skip to content
Merged
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
12 changes: 12 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
android:label="code_l"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name="com.aboutyou.dart_packages.sign_in_with_apple.SignInWithAppleCallback"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:scheme="signinwithapple" />
<data android:path="callback" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
5 changes: 5 additions & 0 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
A0C3D7BA37E297BF670F5764 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = "<group>"; };
AFE368912DBBC8390072E7EF /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
B955AE8AC425CE69815F5900 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C7F447F3DE684CF75971C579 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
E1FBF0C02DAE7C460017C51F /* GoogleService-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -145,6 +146,7 @@
97C146F01CF9000F007C117D /* Runner */ = {
isa = PBXGroup;
children = (
AFE368912DBBC8390072E7EF /* Runner.entitlements */,
E1FBF0C02DAE7C460017C51F /* GoogleService-Info.plist */,
97C146FA1CF9000F007C117D /* Main.storyboard */,
97C146FD1CF9000F007C117D /* Assets.xcassets */,
Expand Down Expand Up @@ -473,6 +475,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
Expand Down Expand Up @@ -660,6 +663,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
Expand Down Expand Up @@ -687,6 +691,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
Expand Down
10 changes: 10 additions & 0 deletions ios/Runner/Runner.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.applesignin</key>
<array>
<string>Default</string>
</array>
</dict>
</plist>
18 changes: 18 additions & 0 deletions lib/auth/data/datasources/remote/login_remote_datasource.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:kakao_flutter_sdk_user/kakao_flutter_sdk_user.dart';
import 'package:sign_in_with_apple/sign_in_with_apple.dart';

class LoginRemoteDataSource {
Future<User> loginWithKakao() async {
Expand All @@ -12,4 +13,21 @@ class LoginRemoteDataSource {

return await UserApi.instance.me();
}

Future<AuthorizationCredentialAppleID> loginWithApple() async {
final AuthorizationCredentialAppleID credential =
await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.email,
AppleIDAuthorizationScopes.fullName,
],
webAuthenticationOptions: WebAuthenticationOptions(
clientId: "codel.codel.com", // Apple Developer Console에 등록된 clientId
redirectUri: Uri.parse(
"https://chartreuse-gratis-lungfish.glitch.me/callbacks/sign_in_with_apple",
),
),
);
return credential;
}
}
5 changes: 3 additions & 2 deletions lib/auth/data/repositories/default_login_repository.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:code_l/auth/domain/repositories/login_repository.dart';
import 'package:kakao_flutter_sdk_user/kakao_flutter_sdk_user.dart';
import 'package:sign_in_with_apple/sign_in_with_apple.dart';

import '../datasources/remote/auth_remote_datasource.dart';
import '../datasources/remote/login_remote_datasource.dart';
Expand All @@ -19,8 +20,8 @@ class DefaultLoginRepository implements LoginRepository {
}

@override
Future<User> loginWithApple() {
throw UnimplementedError();
Future<AuthorizationCredentialAppleID> loginWithApple() {
throw loginRemoteDataSource.loginWithApple();
}

@override
Expand Down
3 changes: 2 additions & 1 deletion lib/auth/domain/repositories/login_repository.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'package:kakao_flutter_sdk_user/kakao_flutter_sdk_user.dart';
import 'package:sign_in_with_apple/sign_in_with_apple.dart';

abstract class LoginRepository {
Future<String> loginOauth(String type, String id);
Future<User> loginWithKakao();
Future<User> loginWithApple();
Future<AuthorizationCredentialAppleID> loginWithApple();
}
14 changes: 7 additions & 7 deletions lib/auth/domain/usecases/login_usecase.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import 'package:code_l/auth/domain/model/login_type.dart';
import 'package:code_l/auth/domain/repositories/login_repository.dart';
import 'package:kakao_flutter_sdk_user/kakao_flutter_sdk_user.dart';
import 'package:sign_in_with_apple/sign_in_with_apple.dart';

class LoginUseCase {
final LoginRepository repository;
LoginUseCase(this.repository);

Future<User> call(LoginType type) async {
switch (type) {
case LoginType.kakao:
return await repository.loginWithKakao();
case LoginType.apple:
return await repository.loginWithApple();
}
Future<User> callKakaoLogin(LoginType type) async {
return await repository.loginWithKakao();
}

Future<AuthorizationCredentialAppleID> callAppleLogin(LoginType type) async {
return await repository.loginWithApple();
}

Future<String> callOauth(LoginType type, String id) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ class CongratulationPage extends StatelessWidget {
height: 40,
),
),

Padding(
padding: const EdgeInsets.all(AppGaps.gap4),
child: CongratulationConfirmButton(
Expand Down
33 changes: 24 additions & 9 deletions lib/auth/presentation/pages/login/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class LoginPage extends ConsumerWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Flexible(
flex: 4,
flex: 3,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Expand All @@ -32,11 +32,22 @@ class LoginPage extends ConsumerWidget {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("코드가 맞는 우리만의", style: AppTypography.body1),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("공간에서 시작되는 ", style: AppTypography.body1),
Text(
"코드가 맞는 우리만의 공간",
style: AppTypography.subtitle2.copyWith(
color: AppColors.primary,
),
),
Text(" 에서", style: AppTypography.body1),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("시작되는 ", style: AppTypography.body1),
Text("진짜 인연", style: AppTypography.subtitle1),
],
),
Expand Down Expand Up @@ -88,12 +99,7 @@ class LoginPage extends ConsumerWidget {
side: const BorderSide(color: AppColors.black),
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const LoginPage(),
),
);
ref.read(loginViewModelProvider).loginWithApple();
},
child: Padding(
padding: const EdgeInsets.all(AppGaps.gap16),
Expand All @@ -116,6 +122,15 @@ class LoginPage extends ConsumerWidget {
],
),
),
Flexible(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("레즈비언", style: AppTypography.subtitle2),
Text("을 위한 더 깊이있는 매칭앱", style: AppTypography.body1),
],
),
),
],
),
),
Expand Down
32 changes: 28 additions & 4 deletions lib/auth/presentation/pages/login/login_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:developer';
import 'package:code_l/auth/domain/model/login_type.dart';
import 'package:flutter/cupertino.dart';
import 'package:kakao_flutter_sdk_user/kakao_flutter_sdk_user.dart';
import 'package:sign_in_with_apple/sign_in_with_apple.dart';

import '../../../domain/usecases/login_usecase.dart';

Expand All @@ -15,10 +16,9 @@ class LoginViewModel extends ChangeNotifier {
try {
bool installed = await isKakaoTalkInstalled();

OAuthToken token =
installed
? await UserApi.instance.loginWithKakaoTalk()
: await UserApi.instance.loginWithKakaoAccount();
OAuthToken token = installed
? await UserApi.instance.loginWithKakaoTalk()
: await UserApi.instance.loginWithKakaoAccount();

final user = await UserApi.instance.me();

Expand All @@ -38,4 +38,28 @@ class LoginViewModel extends ChangeNotifier {
log(name: 'LoginViewModel::loginOauth', 'error: $e');
}
}

Future<void> loginWithApple() async {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분의 로직을 repository로 옮기고 viewmodel에서는 usecase의 함수만 호출하여 가져오도록 분리하면 좋을 것 같아요 !

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵!!!

try {
// 애플 인증 정보 가져오기
final credential = useCase.callAppleLogin(LoginType.apple);
// authorizationCode와 identityToken 확인
final authorizationCode =
credential.then((value) => value.authorizationCode);
final identityToken = credential.then((value) => value.identityToken);

if (authorizationCode == null || identityToken == null) {
throw Exception("Authorization Code 또는 Identity Token을 가져오지 못했습니다.");
}

// 백엔드로 OAuth 인증 요청
await loginOauth(LoginType.apple, identityToken.toString());

log(
name: 'LoginViewModel::loginWithApple',
'success: ${identityToken.toString()}');
} catch (e) {
log(name: 'LoginViewModel::loginWithApple', 'error: $e');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,19 @@ class TermsAndConditionPage extends ConsumerWidget {
Text(
"모두 동의합니다.",
style: AppTypography.subtitle2.copyWith(
color:
viewmodel.checkState[0]
? AppColors.grey900
: AppColors.grey500,
color: viewmodel.checkState[0]
? AppColors.grey900
: AppColors.grey500,
),
),
IconButton(
onPressed: () => notifier.toggleAll(),
iconSize: 36,
icon: Icon(
Icons.check_circle_outline,
color:
viewmodel.checkState[0]
? AppColors.grey900
: AppColors.grey500,
color: viewmodel.checkState[0]
? AppColors.grey900
: AppColors.grey500,
),
),
],
Expand All @@ -104,10 +102,9 @@ class TermsAndConditionPage extends ConsumerWidget {
getLabel(i),
style: AppTypography.body2.copyWith(
decoration: TextDecoration.underline,
color:
viewmodel.checkState[i]
? AppColors.grey900
: AppColors.grey500,
color: viewmodel.checkState[i]
? AppColors.grey900
: AppColors.grey500,
),
),
),
Expand All @@ -116,10 +113,9 @@ class TermsAndConditionPage extends ConsumerWidget {
iconSize: 24,
icon: Icon(
Icons.check,
color:
viewmodel.checkState[i]
? AppColors.grey900
: AppColors.grey500,
color: viewmodel.checkState[i]
? AppColors.grey900
: AppColors.grey500,
),
),
],
Expand Down
14 changes: 6 additions & 8 deletions lib/auth/presentation/pages/woman/woman_verification_Page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,9 @@ class WomanVerificationPage extends ConsumerWidget {
Text(
"위 안내사항을 모두 확인하였습니다.",
style: AppTypography.subtitle2.copyWith(
color:
viewModel.isChecked
? AppColors.grey800
: AppColors.grey400,
color: viewModel.isChecked
? AppColors.grey800
: AppColors.grey400,
),
),
IconButton(
Expand All @@ -142,10 +141,9 @@ class WomanVerificationPage extends ConsumerWidget {
},
icon: Icon(
Icons.check_circle_outline,
color:
viewModel.isChecked
? AppColors.grey800
: AppColors.grey400,
color: viewModel.isChecked
? AppColors.grey800
: AppColors.grey400,
),
),
],
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
title: 'Kakao Login Demo',
home: const ProfileInterestPage(),
home: const LoginPage(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

theme: ThemeData(
primarySwatch: Colors.blue,
scaffoldBackgroundColor: Colors.white,
Expand Down
Loading