-
Notifications
You must be signed in to change notification settings - Fork 0
[feat/#20] kakao api #25
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,17 +14,32 @@ | |
| android:roundIcon="@mipmap/ic_launcher_round" | ||
| android:supportsRtl="true" | ||
| android:theme="@style/Theme.HsLink"> | ||
|
|
||
| <!-- 메인 액티비티 (원래 그대로) --> | ||
| <activity | ||
| android:name=".presentation.main.MainActivity" | ||
| android:exported="true" | ||
| android:label="@string/app_name" | ||
| android:theme="@style/Theme.HsLink"> | ||
| <intent-filter> | ||
| <action android:name="android.intent.action.MAIN" /> | ||
|
|
||
| <category android:name="android.intent.category.LAUNCHER" /> | ||
| </intent-filter> | ||
| </activity> | ||
|
|
||
| <!-- 카카오 로그인용 별도 액티비티 (새로 추가) --> | ||
| <activity | ||
| android:name="com.kakao.sdk.auth.AuthCodeHandlerActivity" | ||
| 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:host="oauth" android:scheme="kakaoa0bbd28c9384baa131a731d1b914307c" /> | ||
| </intent-filter> | ||
| </activity> | ||
|
Comment on lines
+31
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move hardcoded API key to BuildConfig. The Kakao native app key Move the key to In android {
defaultConfig {
// Read from local.properties
val properties = Properties()
properties.load(project.rootProject.file("local.properties").inputStream())
val kakaoAppKey = properties.getProperty("kakao.app.key", "")
manifestPlaceholders["kakaoAppKey"] = kakaoAppKey
buildConfigField("String", "KAKAO_APP_KEY", "\"$kakaoAppKey\"")
}
}In - <data android:host="oauth" android:scheme="kakaoa0bbd28c9384baa131a731d1b914307c" />
+ <data android:host="oauth" android:scheme="kakao${kakaoAppKey}" />In - KakaoSdk.init(this, "a0bbd28c9384baa131a731d1b914307c")
+ KakaoSdk.init(this, BuildConfig.KAKAO_APP_KEY)In kakao.app.key=a0bbd28c9384baa131a731d1b914307c🤖 Prompt for AI Agents |
||
|
|
||
| </application> | ||
|
|
||
| </manifest> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.hsLink.hslink.core.navigation | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data object AppMain : Route // 전체 앱의 메인 (기존 MainScreen) | ||
|
|
||
| @Serializable | ||
| data object Onboarding : Route |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,15 +1,18 @@ | ||||||||||||||
| package com.hsLink.hslink.data.di | ||||||||||||||
|
|
||||||||||||||
| import com.hsLink.hslink.data.repositoryimpl.AuthRepositoryImpl | ||||||||||||||
| import com.hsLink.hslink.data.repositoryimpl.CommunityRepositoryImpl | ||||||||||||||
| import com.hsLink.hslink.data.repositoryimpl.DummyRepositoryImpl | ||||||||||||||
| import com.hsLink.hslink.data.repositoryimpl.home.PostRepositoryImpl | ||||||||||||||
| import com.hsLink.hslink.domain.DummyRepository | ||||||||||||||
| import com.hsLink.hslink.domain.repository.AuthRepository | ||||||||||||||
| import com.hsLink.hslink.domain.repository.community.CommunityRepository | ||||||||||||||
| import com.hsLink.hslink.domain.repository.home.PostRepository | ||||||||||||||
| import dagger.Binds | ||||||||||||||
| import dagger.Module | ||||||||||||||
| import dagger.hilt.InstallIn | ||||||||||||||
| import dagger.hilt.components.SingletonComponent | ||||||||||||||
| import javax.inject.Singleton | ||||||||||||||
|
|
||||||||||||||
| @Module | ||||||||||||||
| @InstallIn(SingletonComponent::class) | ||||||||||||||
|
|
@@ -25,9 +28,14 @@ interface RepositoryModule { | |||||||||||||
| postRepositoryImpl: PostRepositoryImpl, | ||||||||||||||
| ): PostRepository | ||||||||||||||
|
|
||||||||||||||
| @Binds | ||||||||||||||
| @Singleton | ||||||||||||||
| fun bindAuthRepository( | ||||||||||||||
| authRepositoryImpl: AuthRepositoryImpl | ||||||||||||||
| ): AuthRepository | ||||||||||||||
|
Comment on lines
+33
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix method naming to match existing pattern. The method name should be Apply this diff to fix the naming: - fun bindAuthRepository(
+ fun bindsAuthRepository(
authRepositoryImpl: AuthRepositoryImpl
): AuthRepository📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
| @Binds | ||||||||||||||
| fun bindsCommunityPostRepository( | ||||||||||||||
| communityPostRepositoryImpl: CommunityRepositoryImpl, | ||||||||||||||
| ): CommunityRepository | ||||||||||||||
|
|
||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.hsLink.hslink.data.dto.request | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class SocialLoginRequest( | ||
| val provider: String, | ||
| val accessToken: String | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.hsLink.hslink.data.dto.response | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class SocialLoginResponse( | ||
| val accessToken: String, | ||
| val refreshToken: String, | ||
| val isNewUser: Boolean, | ||
| val needsOnboarding: Boolean | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package com.hsLink.hslink.data.repositoryimpl | ||
|
|
||
| import com.hsLink.hslink.data.dto.request.SocialLoginRequest | ||
| import com.hsLink.hslink.data.dto.response.SocialLoginResponse | ||
| import com.hsLink.hslink.data.service.login.AuthService | ||
| import com.hsLink.hslink.domain.repository.AuthRepository | ||
| import javax.inject.Inject | ||
|
|
||
| class AuthRepositoryImpl @Inject constructor( | ||
| private val authService: AuthService | ||
| ) : AuthRepository { | ||
|
|
||
| override suspend fun loginWithSocialToken( | ||
| provider: String, | ||
| accessToken: String | ||
| ): Result<SocialLoginResponse> { | ||
| return try { | ||
| val request = SocialLoginRequest(provider, accessToken) | ||
| val response = authService.socialLogin(request) | ||
|
|
||
| if (response.isSuccessful) { | ||
| response.body()?.let { loginResponse -> | ||
| Result.success(loginResponse) | ||
| } ?: Result.failure(Exception("응답이 비어있습니다")) | ||
| } else { | ||
| Result.failure(Exception("로그인 실패: ${response.code()}")) | ||
| } | ||
| } catch (e: Exception) { | ||
| Result.failure(e) | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.hsLink.hslink.data.service.login | ||
|
|
||
| import com.hsLink.hslink.data.dto.request.SocialLoginRequest | ||
| import com.hsLink.hslink.data.dto.response.SocialLoginResponse | ||
| import retrofit2.Response | ||
| import retrofit2.http.Body | ||
| import retrofit2.http.POST | ||
|
|
||
| interface AuthService { | ||
| @POST("auth/login") | ||
| suspend fun socialLogin(@Body request: SocialLoginRequest): Response<SocialLoginResponse> | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.hsLink.hslink.domain.repository | ||
|
|
||
| import com.hsLink.hslink.data.dto.response.SocialLoginResponse | ||
|
|
||
| interface AuthRepository { | ||
| suspend fun loginWithSocialToken( | ||
| provider: String, | ||
| accessToken: String | ||
| ): Result<SocialLoginResponse> | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| package com.hsLink.hslink.presentation.login.component | ||
|
|
||
| import android.R.attr.enabled | ||
| import androidx.compose.foundation.Image | ||
| import androidx.compose.foundation.R | ||
| import androidx.compose.foundation.layout.Row | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.height | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.layout.size | ||
| import androidx.compose.foundation.shape.RoundedCornerShape | ||
| import androidx.compose.material3.Button | ||
| import androidx.compose.material3.ButtonDefaults | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.graphics.Color | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.compose.ui.unit.sp | ||
|
|
||
| @Composable | ||
| fun KakaoLoginButton( | ||
| onClick: () -> Unit, | ||
| modifier: Modifier = Modifier, | ||
| enabled: Boolean = true | ||
| ) { | ||
| Button( | ||
| onClick = onClick, | ||
| enabled = enabled, | ||
| colors = ButtonDefaults.buttonColors( | ||
| containerColor = Color(0xFFFEE500), // 카카오 노란색 | ||
| contentColor = Color.Black // 텍스트 및 아이콘 색상 | ||
| ), | ||
| shape = RoundedCornerShape(6.dp), // 모서리 둥글기 | ||
| modifier = Modifier | ||
| .fillMaxWidth(0.85f) // 가로 폭 (조정 가능) | ||
| .height(54.dp) // 높이 (Figma 기준) | ||
| ) { | ||
| Row( | ||
| verticalAlignment = Alignment.CenterVertically | ||
| ) { | ||
| // 말풍선 아이콘 (SVG 또는 PNG 리소스) | ||
| Image( | ||
| painter = painterResource(id = com.hsLink.hslink.R.drawable.ic_kakao_icon), | ||
| contentDescription = "카카오 로고", | ||
| modifier = Modifier | ||
| .size(20.dp) | ||
| .padding(end = 8.dp) | ||
| ) | ||
| Text( | ||
| text = "카카오 로그인", | ||
| color = Color(0xFF191919), // 카카오 가이드 기준 검정 85% | ||
| fontSize = 16.sp | ||
| ) | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package com.hsLink.hslink.presentation.login.navigation | ||
|
|
||
| import androidx.compose.foundation.layout.PaddingValues | ||
| import androidx.navigation.NavController | ||
| import androidx.navigation.NavGraphBuilder | ||
| import androidx.navigation.NavOptions | ||
| import androidx.navigation.compose.composable | ||
| import com.hsLink.hslink.core.navigation.Route | ||
| import com.hsLink.hslink.presentation.login.screen.KaKaoLoginScreen | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| fun NavController.navigateToLogin(navOptions: NavOptions? = null) { | ||
| navigate(Login, navOptions) | ||
| } | ||
|
|
||
| fun NavGraphBuilder.loginNavGraph( | ||
| padding: PaddingValues, | ||
| onNavigateToMain: () -> Unit, | ||
| onNavigateToOnboarding: () -> Unit | ||
| ) { | ||
| composable<Login> { | ||
| KaKaoLoginScreen( | ||
| paddingValues = padding, | ||
| onNavigateToHome = onNavigateToMain, | ||
| onNavigateToOnboarding = onNavigateToOnboarding | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| @Serializable | ||
| data object Login : Route // Route 인터페이스 구현 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
님아.