Skip to content

Commit

Permalink
Merge pull request #59 from Team-Notitime/feat/onboarding/57-onboardi…
Browse files Browse the repository at this point in the history
…ng-ui

Feat/onboarding/57 onboarding UI
  • Loading branch information
easyhz authored Aug 12, 2024
2 parents 9475083 + 90ab63e commit 7028f16
Show file tree
Hide file tree
Showing 22 changed files with 354 additions and 18 deletions.
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(this@navigateToLogIn.graph.startDestinationId) {
popUpTo(this@navigateToLogIn.graph.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

0 comments on commit 7028f16

Please sign in to comment.