-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/#26 navigation #27
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
0e2ae8a
e013975
fc3f01c
67b7dd7
50a7980
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.yapp.app.official.navigation | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.navigation.compose.NavHost | ||
import com.yapp.app.official.ui.NavigatorState | ||
import com.yapp.feature.home.navigation.homeNavGraph | ||
import com.yapp.feature.login.navigation.loginNavGraph | ||
import com.yapp.feature.notice.navigation.noticeNavGraph | ||
import com.yapp.feature.signup.navigation.signupNavGraph | ||
|
||
|
||
@Composable | ||
fun YappNavHost( | ||
navigator: NavigatorState, | ||
modifier: Modifier = Modifier | ||
) { | ||
NavHost( | ||
navController = navigator.navController, | ||
startDestination = navigator.startDestination, | ||
modifier = modifier, | ||
) { | ||
loginNavGraph( | ||
onSignUpClick = { navigator.navigateSignUpScreen() } | ||
) | ||
signupNavGraph() | ||
homeNavGraph() | ||
noticeNavGraph() | ||
} | ||
} | ||
ashwon12 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.yapp.app.official.ui | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.navigation.NavDestination | ||
import androidx.navigation.NavHostController | ||
import androidx.navigation.compose.currentBackStackEntryAsState | ||
import androidx.navigation.compose.rememberNavController | ||
import com.yapp.feature.home.navigation.navigateToHome | ||
import com.yapp.feature.login.navigation.LoginRoute | ||
import com.yapp.feature.login.navigation.navigateToLogin | ||
import com.yapp.feature.notice.navigation.navigateToNotice | ||
import com.yapp.feature.signup.navigation.navigateToSignUp | ||
|
||
|
||
@Composable | ||
fun rememberNavigator( | ||
navController: NavHostController = rememberNavController(), | ||
): NavigatorState = remember(navController) { | ||
NavigatorState( | ||
navController = navController, | ||
) | ||
} | ||
|
||
|
||
class NavigatorState( | ||
val navController: NavHostController, | ||
) { | ||
private val currentDestination: NavDestination? | ||
@Composable get() = navController | ||
.currentBackStackEntryAsState().value?.destination | ||
|
||
val startDestination = LoginRoute | ||
|
||
fun navigateLoginScreen() { | ||
navController.navigateToLogin() | ||
} | ||
|
||
fun navigateSignUpScreen() { | ||
navController.navigateToSignUp() | ||
} | ||
|
||
fun navigateHomeScreen() { | ||
navController.navigateToHome() | ||
} | ||
|
||
fun navigateNoticeScreen() { | ||
navController.navigateToNotice() | ||
} | ||
ashwon12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
private fun popBackStack() { | ||
navController.popBackStack() | ||
} | ||
} | ||
ashwon12 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.yapp.app.official.ui | ||
|
||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import com.yapp.app.official.navigation.YappNavHost | ||
|
||
|
||
@Composable | ||
fun YappApp(navigator: NavigatorState) { | ||
Scaffold{ padding -> | ||
YappNavHost(navigator, modifier = Modifier.padding(padding)) | ||
} | ||
} | ||
ashwon12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package com.yapp | |
import org.gradle.api.JavaVersion | ||
import org.gradle.api.Project | ||
import org.gradle.api.tasks.compile.JavaCompile | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.gradle.kotlin.dsl.provideDelegate | ||
import org.gradle.kotlin.dsl.withType | ||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
|
@@ -16,7 +17,10 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | |
*/ | ||
internal fun Project.configureKotlinAndroid() { | ||
// Plugins | ||
pluginManager.apply("org.jetbrains.kotlin.android") | ||
with(pluginManager) { | ||
apply("org.jetbrains.kotlin.android") | ||
apply("org.jetbrains.kotlin.plugin.serialization") | ||
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. A: ์ค Nia์์๋ serialization์ ์ฌ๊ธฐ์ ํ๋์? 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. ์ ์๋
ใ
ใ
์ปจ๋ฐด์
์ด๋ฒ์ ์ถ๊ฐํ๋ฉด์ ๋๋๊ฑด๋ฐ ์์ ์ด ํ์๋ก ํด๋ณด์
๋๋ค.. ! ์ฐ์ ์์ ๋์ ์์ ๋๋๋ฉด ๋ ผ์ ํตํด์ ๊ฐ์ ํ๋๊ฒ ์ข์ ๊ฒ ๊ฐ์ต๋๋ท 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. ์ข์ต๋๋ค!! ์ผ๋จ ์๋ ๊ฒ ๊ณ ๊ณ ํ์์ฃ |
||
} | ||
|
||
// Android settings | ||
androidExtension.apply { | ||
|
@@ -44,6 +48,10 @@ internal fun Project.configureKotlinAndroid() { | |
|
||
} | ||
configureKotlinCommon(jvmTarget = JvmTarget.JVM_17) | ||
val libs = extensions.libs | ||
dependencies { | ||
"implementation"(libs.findLibrary("kotlinx.serialization.json").get()) | ||
} | ||
} | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.yapp.feature.home.navigation | ||
|
||
import androidx.navigation.NavController | ||
import androidx.navigation.NavGraphBuilder | ||
import androidx.navigation.NavOptions | ||
import androidx.navigation.compose.composable | ||
import com.yapp.feature.home.HomeScreen | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable data object HomeRoute | ||
|
||
fun NavController.navigateToHome(navOptions: NavOptions? = null) { navigate(HomeRoute, navOptions) } | ||
|
||
fun NavGraphBuilder.homeNavGraph(){ | ||
composable<HomeRoute> { | ||
HomeScreen() | ||
} | ||
} | ||
ashwon12 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.yapp.feature.login | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.unit.dp | ||
import com.yapp.core.designsystem.component.button.text.YappTextAssistiveButtonSmall | ||
|
||
@Composable | ||
fun LoginScreen ( | ||
){ | ||
ashwon12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Column( | ||
verticalArrangement = Arrangement.spacedBy(12.dp)) { | ||
YappTextAssistiveButtonSmall( | ||
text = "Login", | ||
enable = true, | ||
onClick = {} | ||
) | ||
ashwon12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.yapp.feature.login.navigation | ||
|
||
import androidx.navigation.NavController | ||
import androidx.navigation.NavGraphBuilder | ||
import androidx.navigation.NavOptions | ||
import androidx.navigation.compose.composable | ||
import com.yapp.feature.login.LoginScreen | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable data object LoginRoute | ||
|
||
fun NavController.navigateToLogin(navOptions: NavOptions? = null) { navigate(LoginRoute, navOptions) } | ||
|
||
fun NavGraphBuilder.loginNavGraph( | ||
onSignUpClick: NavGraphBuilder.() -> Unit, | ||
){ | ||
composable<LoginRoute> { | ||
LoginScreen() | ||
} | ||
} | ||
ashwon12 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.yapp.feature.notice | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.WindowInsets | ||
import androidx.compose.foundation.layout.safeContent | ||
import androidx.compose.foundation.layout.windowInsetsPadding | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import com.yapp.core.designsystem.component.button.text.YappTextAssistiveButtonSmall | ||
|
||
@Composable | ||
fun NoticeScreen ( | ||
){ | ||
Column( | ||
modifier = Modifier.windowInsetsPadding(WindowInsets.safeContent), | ||
verticalArrangement = Arrangement.spacedBy(12.dp)) { | ||
YappTextAssistiveButtonSmall( | ||
text = "Notice", | ||
enable = true, | ||
onClick = {} | ||
) | ||
} | ||
} | ||
ashwon12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.yapp.feature.notice.navigation | ||
|
||
import androidx.navigation.NavController | ||
import androidx.navigation.NavGraphBuilder | ||
import androidx.navigation.NavOptions | ||
import androidx.navigation.compose.composable | ||
import com.yapp.feature.notice.NoticeScreen | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable data object NoticeRoute | ||
|
||
fun NavController.navigateToNotice(navOptions: NavOptions? = null) { navigate(NoticeRoute, navOptions) } | ||
|
||
fun NavGraphBuilder.noticeNavGraph( | ||
){ | ||
composable<NoticeRoute> { | ||
NoticeScreen() | ||
} | ||
} | ||
ashwon12 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.yapp.feature.signup | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.WindowInsets | ||
import androidx.compose.foundation.layout.safeContent | ||
import androidx.compose.foundation.layout.windowInsetsPadding | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import com.yapp.core.designsystem.component.button.text.YappTextAssistiveButtonSmall | ||
|
||
@Composable | ||
fun SignUpScreen ( | ||
){ | ||
ashwon12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Column( | ||
modifier = Modifier.windowInsetsPadding(WindowInsets.safeContent), | ||
verticalArrangement = Arrangement.spacedBy(12.dp)) { | ||
YappTextAssistiveButtonSmall( | ||
text = "ํ์๊ฐ์ ", | ||
enable = true, | ||
onClick = {} | ||
) | ||
ashwon12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
ashwon12 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.yapp.feature.signup.navigation | ||
|
||
import androidx.navigation.NavController | ||
import androidx.navigation.NavGraphBuilder | ||
import androidx.navigation.NavOptions | ||
import androidx.navigation.compose.composable | ||
import com.yapp.feature.signup.SignUpScreen | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable data object SignUpRoute | ||
|
||
fun NavController.navigateToSignUp(navOptions: NavOptions? = null) { navigate(SignUpRoute, navOptions) } | ||
|
||
fun NavGraphBuilder.signupNavGraph(){ | ||
Comment on lines
+12
to
+14
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. ์ข๋ค์ ๐ |
||
composable<SignUpRoute> { | ||
SignUpScreen() | ||
} | ||
} |
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.
๏ฟฝC: NIA์์๋ loginNavGraph์ onXXXClick ๋ค์ด๋ฐ์ด ๋ค์ด๊ฐ๋์?
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.
nia์์๋
toSignUpDestination
์ด๋ฐ ๋ค์ด๋ฐ์ด ๋ค์ด๊ฐ๋๋ฐ์ ํฌ๋ ๋ฒํผ์ ํตํด์ ์ ํ์ด ๋์ด์ click ๋ค์ด๋ฐ์ด ๋ ์ง๊ด์ ์ผ ๊ฒ ๊ฐ๋ค๊ณ ์๊ฐํ์ด์ !
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.
์ํ ์ .. onSignUpClick์ด SignUpButton์ ํด๋ฆญํ ๊ฒฝ์ฐ์ธ๊ฐ์?
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.
๋ต ๋ง์ต๋๋ค~~
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.
์ ๊ทธ๋ ๋ค๋ฉด Graph์์๋ Screen์ ๋์์ ๋ชจ๋ฅด๊ฒ๋ ํ๋๊ฒ ๋์ค์ ์ ์ง๋ณด์ ํ๊ธฐ ๋ ์ข์ ๊ฒ ๊ฐ์์!
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.
์คํธ .. ์ข์ต๋๋ค ! ๋ก๊ทธ์ธ ๋ทฐ ์์ ํ๋ฉด ๋งค๊ฐ๋ณ์๊ฐ ์ถ๊ฐ ๋ ๊ฒ ๊ฐ์์ ๊ทธ ๋ ๊ฐ์ด ๋ค์ด๋ฐ ๋ฐ์ํ๋๋ก ํ ๊ฒ์ !