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/onboarding/57 onboarding UI #59

Merged
merged 3 commits into from
Aug 12, 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
9 changes: 3 additions & 6 deletions app/src/main/java/com/easyhz/noffice/NofficeApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ import com.easyhz.noffice.core.design_system.component.button.HomeAddButton
import com.easyhz.noffice.core.design_system.component.scaffold.NofficeScaffold
import com.easyhz.noffice.navigation.NofficeNavController
import com.easyhz.noffice.navigation.announcement.announcementGraph
import com.easyhz.noffice.navigation.announcement.navigateToAnnouncementDetail
import com.easyhz.noffice.navigation.announcement.navigateToAnnouncementNofficeSelection
import com.easyhz.noffice.navigation.home.homeGraph
import com.easyhz.noffice.navigation.home.screen.Home
import com.easyhz.noffice.navigation.home.screen.Splash
import com.easyhz.noffice.navigation.my_page.myPageGraph
import com.easyhz.noffice.navigation.my_page.navigateToConsent
import com.easyhz.noffice.navigation.my_page.navigateToMyPage
import com.easyhz.noffice.navigation.my_page.navigateToNotice
import com.easyhz.noffice.navigation.my_page.navigateToNoticeDetail
import com.easyhz.noffice.navigation.my_page.navigateToWithdrawal
Expand Down Expand Up @@ -83,7 +81,7 @@ internal fun NofficeApp(
) {
NavHost(
navController = navController,
startDestination = Home,
startDestination = Splash,
enterTransition = {
slideIntoContainer(
AnimatedContentTransitionScope.SlideDirection.Start, tween(
Expand Down Expand Up @@ -115,8 +113,7 @@ internal fun NofficeApp(
) {
homeGraph(
modifier = Modifier.padding(it),
navigateToAnnouncementDetail = navController::navigateToAnnouncementDetail,
navigateToMyPage = navController::navigateToMyPage
navController = navController
)
organizationGraph(
modifier = Modifier.padding(it),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,36 @@ import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavOptions
import androidx.navigation.compose.composable
import androidx.navigation.navOptions
import com.easyhz.noffice.feature.home.screen.home.HomeScreen
import com.easyhz.noffice.feature.home.screen.onboarding.OnboardingScreen
import com.easyhz.noffice.feature.home.screen.splash.SplashScreen
import com.easyhz.noffice.navigation.announcement.navigateToAnnouncementDetail
import com.easyhz.noffice.navigation.home.screen.Home
import com.easyhz.noffice.navigation.home.screen.Onboarding
import com.easyhz.noffice.navigation.home.screen.Splash
import com.easyhz.noffice.navigation.my_page.navigateToMyPage
import com.easyhz.noffice.navigation.sign.navigateToLogIn
import com.easyhz.noffice.navigation.sign.screen.LogIn

internal fun NavGraphBuilder.homeGraph(
modifier: Modifier,
navigateToAnnouncementDetail: (Int, String) -> Unit,
navigateToMyPage: () -> Unit
navController: NavController,
) {
composable<Splash> {
SplashScreen()
val navOptions = navOptions {
popUpTo(navController.graph.id) { inclusive = true }
}
SplashScreen(
navigateToOnboarding = { navController.navigateToOnboarding(navOptions) },
navigateToLogin = navController::navigateToLogIn,
navigateToHome = { navController.navigateToHome(navOptions) },
)
}
composable<Onboarding> {
OnboardingScreen(
navigateToLogin = navController::navigateToLogIn
)
}
composable<Home>(
enterTransition = {
Expand All @@ -35,8 +52,8 @@ internal fun NavGraphBuilder.homeGraph(
) {
HomeScreen(
modifier = modifier,
navigateToAnnouncementDetail = navigateToAnnouncementDetail,
navigateToMyPage = navigateToMyPage
navigateToAnnouncementDetail = navController::navigateToAnnouncementDetail,
navigateToMyPage = navController::navigateToMyPage
)
}
}
Expand All @@ -48,5 +65,9 @@ internal fun NavController.navigateToHome(navOptions: NavOptions? = null) {
)
}

internal fun NavController.navigateToOnboarding(navOptions: NavOptions?) {
navigate(route = Onboarding, navOptions)
}

private fun AnimatedContentTransitionScope<NavBackStackEntry>.enabledSlide() =
this.initialState.destination.route == LogIn::class.java.name
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.easyhz.noffice.navigation.home.screen

import kotlinx.serialization.Serializable

@Serializable
object Onboarding
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal fun NavGraphBuilder.signGraph(

internal fun NavController.navigateToLogIn() {
val navOptions = navOptions {
popUpTo([email protected].startDestinationId) {
popUpTo([email protected].id) {
inclusive = true
}
launchSingleTop = true
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions core/design-system/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,31 @@
<string name="my_page_menu_withdrawal_type_info">μ—°κ²°λœ μ†Œμ…œ 계정 정보</string>
<string name="my_page_menu_withdrawal_consent">μ•ˆλ‚΄ 사항을 ν™•μΈν•˜κ³  νšŒμ› νƒˆν‡΄μ— λ™μ˜ν•©λ‹ˆλ‹€.</string>
<string name="my_page_menu_withdrawal_button">νƒˆν‡΄ν•˜κΈ°</string>


<string name="onboarding_button_next">λ‹€μŒ</string>
<string name="onboarding_button_start">μ‹œμž‘ν•˜κΈ°</string>
<string name="onboarding_step_1_title">
μ•ˆ μ½μ–΄μ„œ λ‹΅λ‹΅ν–ˆλ˜
\n단체 μƒν™œ κ³΅μ§€λŠ” 이제 μ•ˆλ…•
</string>
<string name="onboarding_step_1_content">
쀄 λ‚˜λˆ„κΈ°, 이λͺ¨μ§€, 더 이상 ν•„μš”μ—†μ–΄μš”!
\nλ‚΄κ°€ μ›ν•˜λŠ” λ‚΄μš©λ§Œ λ‹΄μ•„μ„œ 가독성 μ’‹κ²Œ 전달할 수 μžˆμ–΄μš”
</string>
<string name="onboarding_step_2_title">
곡지와 νˆ¬λ‘λ₯Ό 뢄리해
\nν•΅μ‹¬λ§Œ 쏙 μ±™κ²¨κ°€μ„Έμš”!
</string>
<string name="onboarding_step_2_content">
νˆ¬λ‘ 탭을 ν΄λ¦­ν•΄μ„œ λ‚΄κ°€ ν•  일을 λ”μš± μ‰½κ²Œ νŒŒμ•…ν•΄μš”
</string>
<string name="onboarding_step_3_title">
동아리, μŠ€ν„°λ””, μ†Œλͺ¨μž„
\nμ–΄λ–€ 단체든 μ•Œμ°¨κ²Œ ν™œμš©ν•΄μš”
</string>
<string name="onboarding_step_3_content">
λ¦¬λ”μ—κ²ŒλŠ” λ”μš± νŽΈλ¦¬ν•œ 곡지 λ°œν–‰ 과정을,
\nλ©€λ²„μ—κ²ŒλŠ” λ³΅μž‘ν•˜μ§€ μ•Šμ€ 곡지λ₯Ό μ„ λ¬Όν• κ²Œμš”
</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ package com.easyhz.noffice.data.member.repository.user

interface UserRepository {
suspend fun getIsFirstRun(): Result<Boolean>
suspend fun setIsFirstRun(newValue: Boolean): Result<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ class UserRepositoryImpl @Inject constructor(
override suspend fun getIsFirstRun(): Result<Boolean> {
return userLocalDataSource.getFirstRun()
}

override suspend fun setIsFirstRun(newValue: Boolean): Result<Unit> = runCatching {
return@runCatching userLocalDataSource.updateFirstRun(newValue)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.easyhz.noffice.domain.home.usecase.onboarding

import com.easyhz.noffice.core.common.base.BaseUseCase
import com.easyhz.noffice.data.member.repository.user.UserRepository
import javax.inject.Inject

class SetIsFirstRunUseCase @Inject constructor(
private val userRepository: UserRepository
): BaseUseCase<Boolean, Unit>() {
override suspend fun invoke(param: Boolean): Result<Unit> {
return userRepository.setIsFirstRun(param)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ class GetSplashInfoUseCase @Inject constructor(
override suspend fun invoke(param: Unit): Result<EnterScreenType> = runCatching {
userRepository.getIsFirstRun().getOrElse {
return@runCatching EnterScreenType.ONBOARDING
}.takeIf { it }?.let {
return@runCatching EnterScreenType.ONBOARDING
}

tokenRepository.getAccessToken().getOrElse {
return@runCatching EnterScreenType.LOGIN
}.takeIf { it.isBlank() }?.let {
return@runCatching EnterScreenType.LOGIN
}

return Result.success(EnterScreenType.HOME)
EnterScreenType.HOME
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.easyhz.noffice.feature.home.component.onboarding

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.easyhz.noffice.core.design_system.theme.Grey300
import com.easyhz.noffice.core.design_system.theme.SubBody14
import com.easyhz.noffice.core.design_system.theme.Title3
import com.easyhz.noffice.core.design_system.theme.White
import com.easyhz.noffice.feature.home.util.OnboardingStep

@Composable
internal fun OnboardingItem(
modifier: Modifier = Modifier,
item: OnboardingStep
) {
Column(
modifier = modifier,
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
Column(
modifier = Modifier.padding(horizontal = 12.dp),
verticalArrangement = Arrangement.spacedBy(12.dp)
) {
Text(
text = stringResource(id = item.titleId),
style = Title3,
color = White,
lineHeight = (22 * 1.3).sp
)
Text(
modifier = Modifier.heightIn(min= 56.dp),
text = stringResource(id = item.contentId),
style = SubBody14,
color = Grey300,
lineHeight = (14 * 1.4).sp
)
}
Image(
modifier = Modifier.fillMaxWidth().weight(1f),
painter = painterResource(id = item.imageId),
contentDescription = item.name
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.easyhz.noffice.feature.home.contract.onboarding

import com.easyhz.noffice.core.common.base.UiIntent

sealed class OnboardingIntent: UiIntent() {
data class ClickButton(val index: Int): OnboardingIntent()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.easyhz.noffice.feature.home.contract.onboarding

import com.easyhz.noffice.core.common.base.UiSideEffect

sealed class OnboardingSideEffect: UiSideEffect() {
data class SlideNext(val page: Int): OnboardingSideEffect()
data object NavigateToLogin: OnboardingSideEffect()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.easyhz.noffice.feature.home.contract.onboarding

import com.easyhz.noffice.core.common.base.UiState
import com.easyhz.noffice.feature.home.util.OnboardingStep

data class OnboardingState(
val steps: List<OnboardingStep>
): UiState() {
companion object {
fun init() = OnboardingState(
steps = enumValues<OnboardingStep>().toList()
)
}
}
Loading