Skip to content

Commit cc42214

Browse files
committed
Chore: ktlint 적용
1 parent 22c6406 commit cc42214

File tree

6 files changed

+138
-148
lines changed

6 files changed

+138
-148
lines changed

core/datastore/src/main/java/com/threegap/bitnagil/datastore/serializer/AuthTokenSerializer.kt

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,39 @@ import java.io.OutputStream
1010
import java.util.Base64
1111
import javax.inject.Inject
1212

13-
internal class AuthTokenSerializer
14-
@Inject
15-
constructor(
16-
private val crypto: Crypto,
17-
) : TokenSerializer {
18-
override val defaultValue: AuthToken
19-
get() = AuthToken()
13+
internal class AuthTokenSerializer @Inject constructor(
14+
private val crypto: Crypto,
15+
) : TokenSerializer {
16+
override val defaultValue: AuthToken
17+
get() = AuthToken()
2018

21-
override suspend fun readFrom(input: InputStream): AuthToken {
22-
return try {
23-
val encryptedBytes =
24-
withContext(Dispatchers.IO) {
25-
input.use { it.readBytes() }
26-
}
27-
val decodedBytes = Base64.getDecoder().decode(encryptedBytes)
28-
val decryptedBytes = crypto.decrypt(decodedBytes)
29-
val decodedJsonString = decryptedBytes.decodeToString()
30-
Json.decodeFromString(decodedJsonString)
31-
} catch (e: Exception) {
32-
AuthToken()
33-
}
19+
override suspend fun readFrom(input: InputStream): AuthToken {
20+
return try {
21+
val encryptedBytes =
22+
withContext(Dispatchers.IO) {
23+
input.use { it.readBytes() }
24+
}
25+
val decodedBytes = Base64.getDecoder().decode(encryptedBytes)
26+
val decryptedBytes = crypto.decrypt(decodedBytes)
27+
val decodedJsonString = decryptedBytes.decodeToString()
28+
Json.decodeFromString(decodedJsonString)
29+
} catch (e: Exception) {
30+
AuthToken()
3431
}
32+
}
3533

36-
override suspend fun writeTo(
37-
t: AuthToken,
38-
output: OutputStream,
39-
) {
40-
val json = Json.encodeToString(t)
41-
val bytes = json.toByteArray()
42-
val encryptedBytes = crypto.encrypt(bytes)
43-
val encryptedBytesBase64 = Base64.getEncoder().encode(encryptedBytes)
44-
withContext(Dispatchers.IO) {
45-
output.use {
46-
it.write(encryptedBytesBase64)
47-
}
34+
override suspend fun writeTo(
35+
t: AuthToken,
36+
output: OutputStream,
37+
) {
38+
val json = Json.encodeToString(t)
39+
val bytes = json.toByteArray()
40+
val encryptedBytes = crypto.encrypt(bytes)
41+
val encryptedBytesBase64 = Base64.getEncoder().encode(encryptedBytes)
42+
withContext(Dispatchers.IO) {
43+
output.use {
44+
it.write(encryptedBytesBase64)
4845
}
4946
}
5047
}
48+
}

core/datastore/src/main/java/com/threegap/bitnagil/datastore/storage/AuthTokenDataStoreImpl.kt

Lines changed: 51 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,62 +6,60 @@ import com.threegap.bitnagil.datastore.model.AuthToken
66
import kotlinx.coroutines.flow.Flow
77
import javax.inject.Inject
88

9-
internal class AuthTokenDataStoreImpl
10-
@Inject
11-
constructor(
12-
private val dataStore: DataStore<AuthToken>,
13-
) : AuthTokenDataStore {
14-
override val tokenFlow: Flow<AuthToken> = dataStore.data
9+
internal class AuthTokenDataStoreImpl @Inject constructor(
10+
private val dataStore: DataStore<AuthToken>,
11+
) : AuthTokenDataStore {
12+
override val tokenFlow: Flow<AuthToken> = dataStore.data
1513

16-
override suspend fun updateAuthToken(authToken: AuthToken): AuthToken =
17-
runCatching {
18-
dataStore.updateData { authToken }
19-
}.fold(
20-
onSuccess = { it },
21-
onFailure = {
22-
Log.e(TAG, "updateAuthToken failed:", it)
23-
throw it
24-
},
25-
)
14+
override suspend fun updateAuthToken(authToken: AuthToken): AuthToken =
15+
runCatching {
16+
dataStore.updateData { authToken }
17+
}.fold(
18+
onSuccess = { it },
19+
onFailure = {
20+
Log.e(TAG, "updateAuthToken failed:", it)
21+
throw it
22+
},
23+
)
2624

27-
override suspend fun updateAccessToken(accessToken: String): AuthToken =
28-
runCatching {
29-
dataStore.updateData { authToken ->
30-
authToken.copy(accessToken = accessToken)
31-
}
32-
}.fold(
33-
onSuccess = { it },
34-
onFailure = {
35-
Log.e(TAG, "updateAccessToken failed:", it)
36-
throw it
37-
},
38-
)
25+
override suspend fun updateAccessToken(accessToken: String): AuthToken =
26+
runCatching {
27+
dataStore.updateData { authToken ->
28+
authToken.copy(accessToken = accessToken)
29+
}
30+
}.fold(
31+
onSuccess = { it },
32+
onFailure = {
33+
Log.e(TAG, "updateAccessToken failed:", it)
34+
throw it
35+
},
36+
)
3937

40-
override suspend fun updateRefreshToken(refreshToken: String): AuthToken =
41-
runCatching {
42-
dataStore.updateData { authToken ->
43-
authToken.copy(refreshToken = refreshToken)
44-
}
45-
}.fold(
46-
onSuccess = { it },
47-
onFailure = {
48-
Log.e(TAG, "updateRefreshToken failed:", it)
49-
throw it
50-
},
51-
)
38+
override suspend fun updateRefreshToken(refreshToken: String): AuthToken =
39+
runCatching {
40+
dataStore.updateData { authToken ->
41+
authToken.copy(refreshToken = refreshToken)
42+
}
43+
}.fold(
44+
onSuccess = { it },
45+
onFailure = {
46+
Log.e(TAG, "updateRefreshToken failed:", it)
47+
throw it
48+
},
49+
)
5250

53-
override suspend fun clearAuthToken(): AuthToken =
54-
runCatching {
55-
dataStore.updateData { AuthToken() }
56-
}.fold(
57-
onSuccess = { it },
58-
onFailure = {
59-
Log.e(TAG, "clearAuthToken failed:", it)
60-
throw it
61-
},
62-
)
51+
override suspend fun clearAuthToken(): AuthToken =
52+
runCatching {
53+
dataStore.updateData { AuthToken() }
54+
}.fold(
55+
onSuccess = { it },
56+
onFailure = {
57+
Log.e(TAG, "clearAuthToken failed:", it)
58+
throw it
59+
},
60+
)
6361

64-
companion object {
65-
private const val TAG = "AuthTokenDataStore"
66-
}
62+
companion object {
63+
private const val TAG = "AuthTokenDataStore"
6764
}
65+
}

core/designsystem/src/main/java/com/threegap/bitnagil/designsystem/Type.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ import androidx.compose.ui.unit.sp
99
// Set of Material typography styles to start with
1010
val Typography =
1111
Typography(
12-
bodyLarge =
13-
TextStyle(
14-
fontFamily = FontFamily.Default,
15-
fontWeight = FontWeight.Normal,
16-
fontSize = 16.sp,
17-
lineHeight = 24.sp,
18-
letterSpacing = 0.5.sp,
19-
),
12+
bodyLarge = TextStyle(
13+
fontFamily = FontFamily.Default,
14+
fontWeight = FontWeight.Normal,
15+
fontSize = 16.sp,
16+
lineHeight = 24.sp,
17+
letterSpacing = 0.5.sp,
18+
),
2019
)

presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeScreen.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ fun HomeScreen(modifier: Modifier = Modifier) {
1717
Column(
1818
verticalArrangement = Arrangement.Center,
1919
horizontalAlignment = Alignment.CenterHorizontally,
20-
modifier =
21-
modifier
22-
.fillMaxSize()
23-
.background(Color.White),
20+
modifier = modifier
21+
.fillMaxSize()
22+
.background(Color.White),
2423
) {
2524
Text(text = "여긴 홈 화면")
2625
}

presentation/src/main/java/com/threegap/bitnagil/presentation/login/LoginScreen.kt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,9 @@ private fun LoginScreen(
5656
modifier: Modifier = Modifier,
5757
) {
5858
Box(
59-
modifier =
60-
modifier
61-
.fillMaxSize()
62-
.background(Color.White),
59+
modifier = modifier
60+
.fillMaxSize()
61+
.background(Color.White),
6362
) {
6463
Text(
6564
text = "빛나길 로고",
@@ -68,10 +67,9 @@ private fun LoginScreen(
6867

6968
Button(
7069
onClick = onKakaoLoginClick,
71-
modifier =
72-
Modifier
73-
.align(Alignment.BottomCenter)
74-
.padding(20.dp),
70+
modifier = Modifier
71+
.align(Alignment.BottomCenter)
72+
.padding(20.dp),
7573
) {
7674
Text(
7775
text = "카카오 로그인버튼",

presentation/src/main/java/com/threegap/bitnagil/presentation/login/LoginViewModel.kt

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,55 +14,53 @@ import org.orbitmvi.orbit.syntax.simple.SimpleSyntax
1414
import javax.inject.Inject
1515

1616
@HiltViewModel
17-
class LoginViewModel
18-
@Inject
19-
constructor(
20-
private val savedStateHandle: SavedStateHandle,
21-
) : MviViewModel<LoginState, LoginSideEffect, LoginIntent>(
22-
initState = LoginState(),
23-
savedStateHandle = savedStateHandle,
24-
) {
25-
override suspend fun SimpleSyntax<LoginState, LoginSideEffect>.reduceState(
26-
intent: LoginIntent,
27-
state: LoginState,
28-
): LoginState? =
29-
when (intent) {
30-
is LoginIntent.OnKakaoLoginClick -> {
31-
if (!intent.onKakaoTalkLoginAvailable) {
32-
sendSideEffect(LoginSideEffect.RequestKakaoAccountLogin)
33-
} else {
34-
sendSideEffect(LoginSideEffect.RequestKakaoTalkLogin)
35-
}
36-
null
17+
class LoginViewModel @Inject constructor(
18+
private val savedStateHandle: SavedStateHandle,
19+
) : MviViewModel<LoginState, LoginSideEffect, LoginIntent>(
20+
initState = LoginState(),
21+
savedStateHandle = savedStateHandle,
22+
) {
23+
override suspend fun SimpleSyntax<LoginState, LoginSideEffect>.reduceState(
24+
intent: LoginIntent,
25+
state: LoginState,
26+
): LoginState? =
27+
when (intent) {
28+
is LoginIntent.OnKakaoLoginClick -> {
29+
if (!intent.onKakaoTalkLoginAvailable) {
30+
sendSideEffect(LoginSideEffect.RequestKakaoAccountLogin)
31+
} else {
32+
sendSideEffect(LoginSideEffect.RequestKakaoTalkLogin)
3733
}
34+
null
35+
}
3836

39-
is LoginIntent.OnKakaoLoginResult -> {
40-
when {
41-
intent.token != null -> {
42-
Log.i("KakaoLogin", "로그인 성공 ${intent.token.accessToken}")
43-
UserApiClient.instance.me { user, error ->
44-
if (error != null) {
45-
Log.e("KakaoLogin", "사용자 정보 요청 실패", error)
46-
} else if (user != null) {
47-
Log.i(
48-
"KakaoLogin",
49-
"사용자 정보 요청 성공" +
50-
"\n이메일: ${user.kakaoAccount?.email}" +
51-
"\n닉네임: ${user.kakaoAccount?.profile?.nickname}",
52-
)
53-
}
37+
is LoginIntent.OnKakaoLoginResult -> {
38+
when {
39+
intent.token != null -> {
40+
Log.i("KakaoLogin", "로그인 성공 ${intent.token.accessToken}")
41+
UserApiClient.instance.me { user, error ->
42+
if (error != null) {
43+
Log.e("KakaoLogin", "사용자 정보 요청 실패", error)
44+
} else if (user != null) {
45+
Log.i(
46+
"KakaoLogin",
47+
"사용자 정보 요청 성공" +
48+
"\n이메일: ${user.kakaoAccount?.email}" +
49+
"\n닉네임: ${user.kakaoAccount?.profile?.nickname}",
50+
)
5451
}
5552
}
53+
}
5654

57-
intent.error is ClientError && intent.error.reason == ClientErrorCause.Cancelled -> {
58-
Log.e("KakaoLogin", "로그인 취소", intent.error)
59-
}
55+
intent.error is ClientError && intent.error.reason == ClientErrorCause.Cancelled -> {
56+
Log.e("KakaoLogin", "로그인 취소", intent.error)
57+
}
6058

61-
intent.error != null -> {
62-
Log.e("KakaoLogin", "로그인 실패", intent.error)
63-
}
59+
intent.error != null -> {
60+
Log.e("KakaoLogin", "로그인 실패", intent.error)
6461
}
65-
null
6662
}
63+
null
6764
}
68-
}
65+
}
66+
}

0 commit comments

Comments
 (0)