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

Feat:[snsproject] navigation-compose, hilt-navigation-compose 의존성 추가 … #24

Merged
merged 2 commits into from
Apr 18, 2024
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
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ dependencies {
implementation(libs.converter.gson)
implementation(libs.hilt.android)
ksp(libs.hilt.android.compiler)
implementation(libs.androidx.hilt.navigation.compose)
implementation(libs.androidx.navigation.compose)
implementation(libs.orbit.viewmodel)
implementation(libs.coil.compose)
implementation(libs.androidx.paging.compose)
Expand Down
4 changes: 4 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ converter-gson = "2.9.0"
core-ktx = "1.12.0"
espresso-core = "3.5.1"
hilt-android = "2.48"
hilt-navigation-compose = "1.2.0"
junit = "4.13.2"
kotlinx-coroutines-core = "1.8.0"
lifecycle-runtime-ktx = "2.7.0"
material = "1.11.0"

navigation-compose = "2.7.7"
orbit-viewmodel = "7.0.1"
paging-compose = "3.3.0-beta01"
paging-runtime = "3.2.1"
Expand All @@ -34,8 +36,10 @@ androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "a
androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "constraintlayout" }
androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "core-ktx" }
androidx-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso-core" }
androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "hilt-navigation-compose" }
androidx-junit = { module = "androidx.test.ext:junit", version.ref = "androidx-junit" }
androidx-lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycle-runtime-ktx" }
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigation-compose" }
androidx-paging-common = { module = "androidx.paging:paging-common", version.ref = "paging-runtime" }
androidx-paging-compose = { module = "androidx.paging:paging-compose", version.ref = "paging-compose" }
androidx-paging-runtime = { module = "androidx.paging:paging-runtime", version.ref = "paging-runtime" }
Expand Down
2 changes: 2 additions & 0 deletions presentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,7 @@ dependencies {
debugImplementation(libs.androidx.compose.ui.ui.test.manifest)
implementation(libs.hilt.android)
ksp(libs.hilt.android.compiler)
implementation(libs.androidx.hilt.navigation.compose)
implementation(libs.androidx.navigation.compose)
implementation(project(":domain"))
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package com.example.presentation.login

import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import com.example.presentation.ui.theme.SnsProjectTheme

class LoginActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
SnsProjectTheme {
LoginNavHost()
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.example.presentation.login

import androidx.compose.runtime.Composable
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController

@Composable
fun LoginNavHost() {
val navController = rememberNavController()
NavHost(
navController = navController,
startDestination = LoginRoute.WelcomeScreen.route,
) {
composable(route = LoginRoute.WelcomeScreen.route) {
WelcomeScreen {
navController.navigate(LoginRoute.LoginScreen.route)
}
}

composable(route = LoginRoute.LoginScreen.route) {
LoginScreen()
}

composable(route = LoginRoute.SignUpScreen.route) {
SignUpScreen(id = "", username = "", password1 = "", password2 = "", {}, {}, {}, {}, {})
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.presentation.login

sealed class LoginRoute(val route: String) {
data object WelcomeScreen : LoginRoute("WelcomeScreen")

data object LoginScreen : LoginRoute("LoginScreen")

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:blank-line-before-declaration reported by reviewdog 🐶
Expected a blank line for this declaration


data object SignUpScreen : LoginRoute("SignUpScreen")

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:blank-line-before-declaration reported by reviewdog 🐶
Expected a blank line for this declaration

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,22 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.example.presentation.component.LoginTextField
import com.example.presentation.component.SubmitButton
import com.example.presentation.ui.theme.SnsProjectTheme

@Composable
fun LoginScreen(viewmodel: LoginViewModel = hiltViewModel()) {
LoginScreen(
id = "",
password = "",
onIdChange = {},
passwordChange = {},
onNavigationToSignUpScreen = { viewmodel.onLoginClick() },
)
}

@Composable
fun LoginScreen(
id: String,
Expand Down Expand Up @@ -89,7 +101,13 @@ fun LoginScreen(
)

Spacer(modifier = Modifier.weight(1f))
Row(modifier = Modifier.align(Alignment.CenterHorizontally).padding(bottom = 24.dp).clickable(onClick = onNavigationToSignUpScreen)) {
Row(
modifier =
Modifier
.align(Alignment.CenterHorizontally)
.padding(bottom = 24.dp)
.clickable(onClick = onNavigationToSignUpScreen),
) {
Text(text = "Don't hava and account?")
Text(text = "Sign up", color = MaterialTheme.colorScheme.primary)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.example.presentation.login

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.domain.usecase.login.LoginUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.coroutines.launch

@HiltViewModel
class LoginViewModel
@Inject
constructor(
private val loginUseCase: LoginUseCase,
) : ViewModel() {
fun onLoginClick() {
val id = ""
val pwd = ""
viewModelScope.launch {
loginUseCase(id, pwd)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import com.example.presentation.component.SubmitButton
import com.example.presentation.ui.theme.SnsProjectTheme

@Composable
fun WelcomeScreen() {
fun WelcomeScreen(onNavigationToLoginScreen: () -> Unit) {
Surface {
Box(
modifier = Modifier.fillMaxSize(),
Expand All @@ -39,7 +39,7 @@ fun WelcomeScreen() {
.padding(bottom = 24.dp)
.align(Alignment.BottomCenter),
text = "로그인",
onClick = {},
onClick = onNavigationToLoginScreen,
)
}
}
Expand All @@ -49,6 +49,6 @@ fun WelcomeScreen() {
@Composable
private fun WelcomeScreenPreview() {
SnsProjectTheme {
WelcomeScreen()
WelcomeScreen({})
}
}