Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit Hold shift + click to select a range
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
18 changes: 18 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,21 @@ plugins {
id(Dependency.Google.GOOGLE_SERVICES_PLUGIN) version Versions.GOOGLE_SERVICE_PLUGIN apply false
id(Dependency.Gradle.KSP) version Versions.KSP apply false
}


allprojects {
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinCompile::class.java).configureEach {
kotlinOptions {
if (project.findProperty("enableMultiModuleComposeReports") == "true") {
freeCompilerArgs += listOf(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + rootProject.buildDir.absolutePath + "/compose_metrics/"
)
freeCompilerArgs += listOf(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" + rootProject.buildDir.absolutePath + "/compose_metrics/"
)
}
}
}
}
Binary file modified buildSrc/build/classes/kotlin/main/Dependency$Coil.class
Binary file not shown.
Binary file modified buildSrc/build/classes/kotlin/main/Dependency$DataStore.class
Binary file not shown.
Binary file modified buildSrc/build/classes/kotlin/main/Dependency$Gauth.class
Binary file not shown.
Binary file modified buildSrc/build/classes/kotlin/main/Dependency$Hilt.class
Binary file not shown.
Binary file modified buildSrc/build/classes/kotlin/main/Dependency$Moshi.class
Binary file not shown.
Binary file modified buildSrc/build/classes/kotlin/main/Dependency$OkHttp.class
Binary file not shown.
Binary file modified buildSrc/build/classes/kotlin/main/Dependency$Retrofit.class
Binary file not shown.
Binary file modified buildSrc/build/classes/kotlin/main/Dependency$Test.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
6
5
0
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified buildSrc/build/kotlin/compileKotlin/cacheable/last-build.bin
Binary file not shown.
Binary file not shown.
Binary file modified buildSrc/build/libs/buildSrc.jar
Binary file not shown.
1 change: 0 additions & 1 deletion buildSrc/src/main/kotlin/Dependency.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ object Dependency {

const val GOOGLE_SERVICES_PLUGIN = "com.google.gms.google-services"


const val SWIPE_REFRESH ="com.google.accompanist:accompanist-swiperefresh:${Versions.SWIPE_REFRESH}"
}

Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/ProjectProperties.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ object ProjectProperties {
const val MIN_SDK = 26
const val TARGET_SDK = 34
const val JVM_TARGET = "17"
const val VERSION_CODE = 1
const val VERSION_NAME = "1.0"
const val VERSION_CODE = 20
const val VERSION_NAME = "1.2.9"
const val KOTLIN_COMPILER_EXTENSION = "1.4.3"

val JAVA_VERSION = JavaVersion.VERSION_17
Expand Down
1 change: 0 additions & 1 deletion presentation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@


plugins {
id(Dependency.Gradle.KOTLIN)
id(Dependency.Gradle.LIBRARY)
Expand Down
89 changes: 79 additions & 10 deletions presentation/src/main/java/view/login/screen/LoginScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand All @@ -20,24 +23,75 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.msg.gauthsignin.GAuthSigninWebView
import view.login.component.DoMaGAthButton
import viewmodel.login.AuthViewModel
import viewmodel.login.uistate.LoginUiState
import viewmodel.login.uistate.SaveTokenUiState

@Composable
internal fun LoginRoute(
navigateToHome: () -> Unit,
modifier: Modifier = Modifier,
navigateToHome: () -> Unit,
authViewModel: AuthViewModel = hiltViewModel(),
) {
//๊ตฌํ˜„ํ•  ์˜ˆ์ •์ž…๋‹ˆ๋‹ค.
val saveTokenUiState by authViewModel.saveTokenUiState.collectAsStateWithLifecycle()
val loginUiState by authViewModel.loginUiState.collectAsStateWithLifecycle()
val (ClickButton, leIsClickLoginButton) = rememberSaveable { mutableStateOf(false) }

LoginScreen(
modifier = modifier,
ClickButton = ClickButton,
loginUiState = loginUiState,
saveTokenUiState = saveTokenUiState,
onErrorToast = { throwable, message -> },
navigateToHome = navigateToHome,
gAuthLogin = { code -> authViewModel.gAuthLogin(code = code) },
leIsClickLoginButton = {leIsClickLoginButton(!ClickButton)}
Comment on lines 42 to 52
Copy link

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

rememberSaveable ์ƒํƒœ ๋ณ€์ˆ˜ ๋ฐ ํ•จ์ˆ˜๋ช…์ด ์ถฉ๋Œ๋˜์–ด ํ˜ผ๋™์„ ์œ ๋ฐœํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
๋™์ผํ•œ ์ด๋ฆ„(leIsClickLoginButton)์„ ์ƒํƒœ์˜ Setter ํ•จ์ˆ˜์™€ ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์–ด, ๊ฐ€๋…์„ฑ๊ณผ ์œ ์ง€๋ณด์ˆ˜์„ฑ์— ๋ฌธ์ œ๊ฐ€ ์ƒ๊ธธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Setter ํ•จ์ˆ˜๋ฅผ ๋ช…ํ™•ํžˆ ๊ตฌ๋ถ„ํ•  ์ˆ˜ ์žˆ๋„๋ก ์•„๋ž˜์ฒ˜๋Ÿผ ๋ณ€๊ฒฝ์„ ์ œ์•ˆ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

-    val (ClickButton, leIsClickLoginButton) = rememberSaveable { mutableStateOf(false) }
+    val (isLoginButtonClicked, setLoginButtonClicked) = rememberSaveable { mutableStateOf(false) }

 ...

-        leIsClickLoginButton = { leIsClickLoginButton(!ClickButton) }
+        leIsClickLoginButton = { setLoginButtonClicked(!isLoginButtonClicked) }
๐Ÿ“ Committable suggestion

โ€ผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
val (ClickButton, leIsClickLoginButton) = rememberSaveable { mutableStateOf(false) }
LoginScreen(
modifier = modifier,
ClickButton = ClickButton,
loginUiState = loginUiState,
saveTokenUiState = saveTokenUiState,
onErrorToast = { throwable, message -> },
navigateToHome = navigateToHome,
gAuthLogin = { code -> authViewModel.gAuthLogin(code = code) },
leIsClickLoginButton = {leIsClickLoginButton(!ClickButton)}
val (isLoginButtonClicked, setLoginButtonClicked) = rememberSaveable { mutableStateOf(false) }
LoginScreen(
modifier = modifier,
ClickButton = ClickButton,
loginUiState = loginUiState,
saveTokenUiState = saveTokenUiState,
onErrorToast = { throwable, message -> },
navigateToHome = navigateToHome,
gAuthLogin = { code -> authViewModel.gAuthLogin(code = code) },
leIsClickLoginButton = { setLoginButtonClicked(!isLoginButtonClicked) }


)
}




@Composable
fun LoginScreen(
modifier: Modifier = Modifier,
ClickButton: () -> Unit,
navigateToHome: () -> Unit
ClickButton: Boolean,
loginUiState: LoginUiState,
leIsClickLoginButton: () -> Unit,
gAuthLogin: (String) -> Unit,
navigateToHome: () -> Unit,
saveTokenUiState: SaveTokenUiState,
onErrorToast: (throwable: Throwable?, message: Int?) -> Unit

) {
Column(
) {

when (loginUiState) {
is LoginUiState.Loading -> Unit
is LoginUiState.Success -> {
when (saveTokenUiState) {
is SaveTokenUiState.Success -> {
navigateToHome()
}

is SaveTokenUiState.Error -> {
onErrorToast(saveTokenUiState.exception, 0)
}

is SaveTokenUiState.Loading -> Unit
}
}

is LoginUiState.Error -> {
onErrorToast(loginUiState.exception, 0)

}
}
Column (
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
modifier = modifier
Expand Down Expand Up @@ -84,7 +138,15 @@ fun LoginScreen(
),
verticalAlignment = Alignment.CenterVertically
) {
DoMaGAthButton(onClick = ClickButton)
DoMaGAthButton(onClick = leIsClickLoginButton)
}
}
if (ClickButton){
GAuthSigninWebView(
clientId = "ghskfend",
redirectUri = "ghskfen"
){
code -> gAuthLogin(code)
}
}
}
Expand All @@ -95,6 +157,13 @@ fun LoginScreen(
@Preview
@Composable
fun PreviewLoginScreen() {
LoginScreen(ClickButton = {}, navigateToHome = {})
}

LoginScreen(
ClickButton = false,
navigateToHome = {},
onErrorToast = { _, _ -> },
saveTokenUiState = SaveTokenUiState.Loading,
loginUiState = LoginUiState.Loading,
gAuthLogin = {},
leIsClickLoginButton = {}
)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package viewModel.login.uiState
package viewmodel.login.uistate

sealed interface LoginUiState {
object Loading : LoginUiState
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package viewModel.login.uiState
package viewmodel.login.uistate

sealed interface SaveTokenUiState {
object Loading : SaveTokenUiState
Expand Down
11 changes: 6 additions & 5 deletions presentation/src/main/java/viewModel/users/UsersViewModel.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package viewModel.users
package viewmodel.users

import Untill.Result
import Untill.asResult
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
import usecase.Users.GetUsersUseCase
import viewModel.UIstate.UsersUiState
import viewmodel.users.uistate.UsersUiState

import javax.inject.Inject

@HiltViewModel
Expand All @@ -37,11 +39,10 @@ class UsersViewModel @Inject constructor(
if (result.data.isEmpty()) {
_usersUiState.value = UsersUiState.Empty
} else {
_usersUiState.value = UsersUiState.Success(result.data)
_usersUiState.value = UsersUiState.Success(result.data.toImmutableList())
}
}
}
}
}
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package viewModel.UIstate
package viewmodel.users.uistate

import kotlinx.collections.immutable.ImmutableList
import model.users.response.UsersResponseModel

sealed interface UsersUiState {
object Loading : UsersUiState
object Empty : UsersUiState
data class Success(val data: List<UsersResponseModel>) : UsersUiState
data class Success(val data: ImmutableList<UsersResponseModel>) : UsersUiState
object Fail : UsersUiState
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import model.auth.request.GAuthLoginRequestBodyModel
import model.auth.response.GAuthLoginResponseModel
import usecase.auth.GAuthLoginUseCase
import usecase.auth.SaveTokenUseCase
import viewModel.login.uiState.LoginUiState
import viewModel.login.uiState.SaveTokenUiState
import viewmodel.login.uistate.LoginUiState
import viewmodel.login.uistate.SaveTokenUiState
import javax.inject.Inject

@HiltViewModel
Expand Down Expand Up @@ -54,6 +54,4 @@ class AuthViewModel @Inject constructor(
_saveTokenUiState.value = SaveTokenUiState.Error(exception)
}
}


}
8 changes: 4 additions & 4 deletions presentation/src/main/res/values/string.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="stringResource">%s: %d</string>
<string name="CleanResource">%dํšŒ</string>
<string name="DemeritList">%s - %dํšŒ</string>
<string name="Rank">%d๋“ฑ</string>
<string name="stringResource">%1$s: %2$d</string>
<string name="CleanResource">%1$dํšŒ</string>
<string name="DemeritList">%1$s - %2$dํšŒ</string>
<string name="Rank">%1$d๋“ฑ</string>
</resources>