Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.unit.dp
import com.byeboo.app.R
import com.byeboo.app.core.designsystem.type.CustomSnackBarType
import com.byeboo.app.core.designsystem.ui.theme.ByeBooTheme

@Composable
fun CustomSnackBar(
message: String,
iconType: CustomSnackBarType,
modifier: Modifier = Modifier,
) {
Row(
Expand All @@ -35,7 +36,7 @@ fun CustomSnackBar(
verticalAlignment = Alignment.CenterVertically,
) {
Icon(
imageVector = ImageVector.vectorResource(id = R.drawable.ic_alert),
imageVector = ImageVector.vectorResource(id = iconType.icon),
contentDescription = "알림",
tint = Color.Unspecified,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.byeboo.app.core.designsystem.component.snackbar

import androidx.compose.material3.SnackbarDuration
import androidx.compose.material3.SnackbarVisuals
import com.byeboo.app.core.designsystem.type.CustomSnackBarType

class CustomSnackBarVisuals(
override val message: String,
val type: CustomSnackBarType,
override val actionLabel: String? = null,
override val withDismissAction: Boolean = false,
override val duration: SnackbarDuration = SnackbarDuration.Short,
) : SnackbarVisuals
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.byeboo.app.core.designsystem.event

import androidx.compose.runtime.staticCompositionLocalOf
import com.byeboo.app.core.designsystem.type.CustomSnackBarType

val LocalSnackBarTrigger =
staticCompositionLocalOf<(String) -> Unit> {
staticCompositionLocalOf<(String, CustomSnackBarType) -> Unit> {
error("No SnackBar provided")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.byeboo.app.core.designsystem.type

import androidx.annotation.DrawableRes
import com.byeboo.app.R

enum class CustomSnackBarType(
@DrawableRes val icon: Int,
) {
ALERT(
icon = R.drawable.ic_alert,
),

SUCCESS(
icon = R.drawable.ic_success,
),
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fun UserInfoRoute(
when (effect) {
is UserInfoSideEffect.NavigateToLoading -> navigateToLoading()
is UserInfoSideEffect.ShowSnackBar -> {
showSnackBar(effect.message)
showSnackBar(effect.message, effect.iconType)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.byeboo.app.presentation.auth.userinfo

import com.byeboo.app.core.designsystem.type.CustomSnackBarType
import com.byeboo.app.domain.model.auth.Feeling
import com.byeboo.app.domain.model.auth.NicknameValidationResult
import com.byeboo.app.domain.model.auth.QuestStyle
Expand All @@ -17,5 +18,6 @@ sealed interface UserInfoSideEffect {

data class ShowSnackBar(
val message: String,
val iconType: CustomSnackBarType,
) : UserInfoSideEffect
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.byeboo.app.presentation.auth.userinfo

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.byeboo.app.core.designsystem.type.CustomSnackBarType
import com.byeboo.app.core.util.MixpanelUtil
import com.byeboo.app.domain.model.auth.Feeling
import com.byeboo.app.domain.model.auth.NicknameValidationResult
Expand Down Expand Up @@ -147,7 +148,10 @@ class UserInfoViewModel
} else {
hasSubmitted = false
_sideEffect.emit(
UserInfoSideEffect.ShowSnackBar("서버에 연결할 수 없습니다. 잠시 후 시도해 주세요."),
UserInfoSideEffect.ShowSnackBar(
"서버에 연결할 수 없습니다. 잠시 후 시도해 주세요.",
CustomSnackBarType.ALERT,
),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fun HomeRoute(
is HomeSideEffect.NavigateToOffboardingCompletedGuide -> navigateToOffboardingCompletedGuide()
is HomeSideEffect.NavigateToOffboardingNewJourney -> navigateToOffboardingNewJourney()
is HomeSideEffect.ShowSnackBar -> {
showSnackBar(effect.message)
showSnackBar(effect.message, effect.iconType)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.byeboo.app.presentation.home

import com.byeboo.app.core.designsystem.type.CustomSnackBarType
import com.byeboo.app.core.model.quest.QuestType
import com.byeboo.app.domain.model.home.HomeStatus

Expand Down Expand Up @@ -32,5 +33,6 @@ sealed interface HomeSideEffect {

data class ShowSnackBar(
val message: String,
val iconType: CustomSnackBarType,
) : HomeSideEffect
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.byeboo.app.presentation.home

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.byeboo.app.core.designsystem.type.CustomSnackBarType
import com.byeboo.app.core.util.MixpanelUtil
import com.byeboo.app.domain.model.JourneyStatusType
import com.byeboo.app.domain.model.home.HomeStatus
Expand Down Expand Up @@ -78,7 +79,10 @@ class HomeViewModel
if (!errorMessage.contains("HTTP 404")) {
hasError = true
_sideEffect.emit(
HomeSideEffect.ShowSnackBar("서버에 연결할 수 없습니다. 잠시 후 시도해 주세요."),
HomeSideEffect.ShowSnackBar(
message = "서버에 연결할 수 없습니다. 잠시 후 시도해 주세요.",
iconType = CustomSnackBarType.ALERT,
),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fun HomeAmuletRoute(
viewModel.sideEffect.collect { effect ->
when (effect) {
is HomeAmuletSideEffect.NavigateToHomeOnboarding -> navigateToHomeOnboarding()
is HomeAmuletSideEffect.ShowSnackBar -> showSnackBar(effect.message)
is HomeAmuletSideEffect.ShowSnackBar -> showSnackBar(effect.message, effect.iconType)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.byeboo.app.presentation.home.homeamulet

import com.byeboo.app.R
import com.byeboo.app.core.designsystem.type.CustomSnackBarType

data class HomeAmuletState(
val journey: AmuletType = AmuletType.EMOTION_FACE,
Expand All @@ -13,6 +14,7 @@ sealed interface HomeAmuletSideEffect {

data class ShowSnackBar(
val message: String,
val iconType: CustomSnackBarType,
) : HomeAmuletSideEffect
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.byeboo.app.presentation.home.homeamulet

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.byeboo.app.core.designsystem.type.CustomSnackBarType
import com.byeboo.app.core.util.MixpanelUtil
import com.byeboo.app.domain.repository.auth.UserRepository
import com.byeboo.app.domain.repository.quest.QuestStateRepository
Expand Down Expand Up @@ -68,7 +69,10 @@ class HomeAmuletViewModel
)
}.onFailure {
_sideEffect.emit(
HomeAmuletSideEffect.ShowSnackBar("서버에 연결할 수 없습니다. 잠시 후 시도해 주세요."),
HomeAmuletSideEffect.ShowSnackBar(
message = "서버에 연결할 수 없습니다. 잠시 후 시도해 주세요.",
iconType = CustomSnackBarType.ALERT,
),
)
}
}
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/com/byeboo/app/presentation/main/MainNavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,21 @@ fun MainNavHost(
navOptions = clearStackNavOptions,
)
},
navigateToQuestCommonAnswer = { answerId ->
navigator.navigateToQuestCommonAnswer(
answerId = answerId,
navOptions = clearStackNavOptions,
)
},
navigateToQuestMyAnswers = {
navigator.navigateToQuestMyAnswers(navOptions = clearStackNavOptions)
},
navigateToQuestMyAnswerDetail = { answerId ->
navigator.navigateToQuestMyAnswerDetail(
answerId = answerId,
navOptions = clearStackNavOptions,
)
},
navigateUp = navigator::navigateUp,
paddingValues = paddingValues,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import com.byeboo.app.presentation.quest.behavior.navigation.navigateToQuestBeha
import com.byeboo.app.presentation.quest.behavior.navigation.navigateToQuestBehaviorComplete
import com.byeboo.app.presentation.quest.navigation.Quest
import com.byeboo.app.presentation.quest.navigation.navigateToQuest
import com.byeboo.app.presentation.quest.navigation.navigateToQuestCommonAnswer
import com.byeboo.app.presentation.quest.navigation.navigateToQuestMyAnswerDetail
import com.byeboo.app.presentation.quest.navigation.navigateToQuestMyAnswers
import com.byeboo.app.presentation.quest.navigation.navigateToQuestReview
import com.byeboo.app.presentation.quest.navigation.navigateToQuestStart
import com.byeboo.app.presentation.quest.navigation.navigateToQuestTip
Expand Down Expand Up @@ -198,6 +201,24 @@ class MainNavigator(
navController.navigateToQuestBehaviorComplete(questId = questId, navOptions = navOptions)
}

fun navigateToQuestCommonAnswer(
answerId: Long,
navOptions: NavOptions? = null,
) {
navController.navigateToQuestCommonAnswer(answerId = answerId, navOptions = navOptions)
}

fun navigateToQuestMyAnswers(navOptions: NavOptions? = null) {
navController.navigateToQuestMyAnswers(navOptions = navOptions)
}

fun navigateToQuestMyAnswerDetail(
answerId: Long,
navOptions: NavOptions? = null,
) {
navController.navigateToQuestMyAnswerDetail(answerId = answerId, navOptions = navOptions)
}

fun navigateToQuestReview(
questId: Long,
navOptions: NavOptions? = null,
Expand Down
15 changes: 12 additions & 3 deletions app/src/main/java/com/byeboo/app/presentation/main/MainScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.navOptions
import com.byeboo.app.core.designsystem.component.backhandler.ByeBooBackHandler
import com.byeboo.app.core.designsystem.component.snackbar.CustomSnackBar
import com.byeboo.app.core.designsystem.component.snackbar.CustomSnackBarVisuals
import com.byeboo.app.core.designsystem.event.LocalSnackBarTrigger
import com.byeboo.app.core.designsystem.type.CustomSnackBarType
import com.byeboo.app.core.designsystem.ui.theme.ByeBooTheme
import com.byeboo.app.core.util.screenHeightDp
import com.byeboo.app.core.util.screenWidthDp
Expand All @@ -46,12 +48,17 @@ fun MainScreen(
val status by viewModel.journeyStatus.collectAsStateWithLifecycle()
val isMoveToQuestHome by viewModel.questHomeNavigation.collectAsStateWithLifecycle()

val onShowSnackBar: (String) -> Unit = { message ->
val onShowSnackBar: (String, CustomSnackBarType) -> Unit = { message, type ->
scope.launch {
snackBarHostState.currentSnackbarData?.dismiss()
val job =
launch {
snackBarHostState.showSnackbar(message)
snackBarHostState.showSnackbar(
CustomSnackBarVisuals(
message = message,
type = type,
),
)
}
delay(3000L)
job.cancel()
Expand Down Expand Up @@ -130,7 +137,9 @@ fun MainScreen(
.padding(horizontal = screenWidthDp(24.dp))
.padding(bottom = snackBarBottomInset),
) { snackBar ->
CustomSnackBar(message = snackBar.visuals.message)
val customVisuals = snackBar.visuals as? CustomSnackBarVisuals
val iconType = customVisuals?.type ?: CustomSnackBarType.ALERT
CustomSnackBar(message = snackBar.visuals.message, iconType = iconType)
}
},
bottomBar = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ fun MyPageRoute(
is MyPageSideEffect.NavigateToTutorial -> navigateToTutorial()
is MyPageSideEffect.NavigateToSplash -> navigateToSplash()
is MyPageSideEffect.NavigateToBlockedUsers -> navigateToBlockedUsers()
is MyPageSideEffect.ShowSnackBar -> showSnackBar(effect.message)
is MyPageSideEffect.ShowSnackBar -> showSnackBar(effect.message, effect.iconType)
}
}
}
Expand Down Expand Up @@ -498,7 +498,6 @@ private fun ByeBooUniverseSection(
style = ByeBooTheme.typography.body2,
)
}

Spacer(modifier = Modifier.height(screenHeightDp(12.dp)))
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.byeboo.app.presentation.mypage

import androidx.compose.runtime.Immutable
import com.byeboo.app.core.designsystem.type.CustomSnackBarType

@Immutable
data class MyPageState(
Expand Down Expand Up @@ -38,5 +39,6 @@ sealed interface MyPageSideEffect {

data class ShowSnackBar(
val message: String,
val iconType: CustomSnackBarType,
) : MyPageSideEffect
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.byeboo.app.presentation.mypage
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.byeboo.app.BuildConfig
import com.byeboo.app.core.designsystem.type.CustomSnackBarType
import com.byeboo.app.core.util.MixpanelUtil
import com.byeboo.app.domain.repository.auth.UserRepository
import com.byeboo.app.domain.repository.fcm.FcmTokenRepository
Expand Down Expand Up @@ -190,7 +191,10 @@ class MyPageViewModel
_sideEffect.emit(MyPageSideEffect.NavigateToSplash)
}.onFailure {
_sideEffect.emit(
MyPageSideEffect.ShowSnackBar(message = "서버에 연결할 수 없습니다. 잠시 후 시도해 주세요."),
MyPageSideEffect.ShowSnackBar(
message = "서버에 연결할 수 없습니다. 잠시 후 시도해 주세요.",
iconType = CustomSnackBarType.ALERT,
),
)
}
}
Expand All @@ -206,7 +210,10 @@ class MyPageViewModel
_sideEffect.emit(MyPageSideEffect.NavigateToSplash)
}.onFailure {
_sideEffect.emit(
MyPageSideEffect.ShowSnackBar(message = "서버에 연결할 수 없습니다. 잠시 후 시도해 주세요."),
MyPageSideEffect.ShowSnackBar(
message = "서버에 연결할 수 없습니다. 잠시 후 시도해 주세요.",
iconType = CustomSnackBarType.ALERT,
),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fun BlockedUsersRoute(
viewModel.sideEffect.collect { effect ->
when (effect) {
is BlockedUsersSideEffect.NavigateUp -> navigateUp()
is BlockedUsersSideEffect.ShowSnackBar -> showSnackBar(effect.message)
is BlockedUsersSideEffect.ShowSnackBar -> showSnackBar(effect.message, effect.iconType)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.byeboo.app.presentation.mypage.blockedusers

import androidx.compose.runtime.Immutable
import com.byeboo.app.core.designsystem.type.CustomSnackBarType
import com.byeboo.app.presentation.mypage.type.User
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
Expand All @@ -16,5 +17,6 @@ sealed interface BlockedUsersSideEffect {

data class ShowSnackBar(
val message: String,
val iconType: CustomSnackBarType,
) : BlockedUsersSideEffect
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fun EditProfileRoute(
viewModel.sideEffect.collect { effect ->
when (effect) {
is EditProfileSideEffect.NavigateToMyPage -> navigateToMyPage()
is EditProfileSideEffect.ShowSnackBar -> showSnackBar(effect.message)
is EditProfileSideEffect.ShowSnackBar -> showSnackBar(effect.message, effect.iconType)
}
}
}
Expand Down
Loading