Skip to content

Commit

Permalink
Merge pull request #32 from Nexters/feature/fix-navigation
Browse files Browse the repository at this point in the history
Feature/fix navigation
  • Loading branch information
eshc123 authored Aug 14, 2024
2 parents 6558937 + 790a90d commit 1fed30c
Show file tree
Hide file tree
Showing 16 changed files with 91 additions and 67 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ android {
buildTypes {
release {
signingConfig = signingConfigs.getByName("release")
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.goalpanzi.mission_mate.core.designsystem.component

import android.annotation.SuppressLint
import androidx.annotation.StringRes
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
Expand Down Expand Up @@ -35,6 +37,7 @@ import com.goalpanzi.mission_mate.core.designsystem.theme.ColorGray3_FF727484
import com.goalpanzi.mission_mate.core.designsystem.theme.ColorWhite_FFFFFFFF
import com.goalpanzi.mission_mate.core.designsystem.theme.MissionMateTypography

@SuppressLint("UnrememberedMutableInteractionSource")
@Composable
fun MissionMateDialog(
@StringRes titleId: Int,
Expand Down Expand Up @@ -102,7 +105,7 @@ fun MissionMateDialog(
modifier = Modifier
.padding(top = 20.dp)
.clickable(
interactionSource = null,
interactionSource = MutableInteractionSource(),
indication = null,
onClick = onDismissRequest
),
Expand All @@ -117,6 +120,7 @@ fun MissionMateDialog(
}


@SuppressLint("UnrememberedMutableInteractionSource")
@Composable
fun MissionMateDialog(
onDismissRequest: () -> Unit,
Expand Down Expand Up @@ -170,7 +174,7 @@ fun MissionMateDialog(
modifier = Modifier
.padding(top = 20.dp)
.clickable(
interactionSource = null,
interactionSource = MutableInteractionSource(),
indication = null,
onClick = onDismissRequest
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ package com.goalpanzi.mission_mate.feature.board
import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavOptions
import androidx.navigation.NavType
import androidx.navigation.compose.composable
import androidx.navigation.toRoute
import androidx.navigation.navArgument
import com.goalpanzi.mission_mate.core.navigation.RouteModel
import com.goalpanzi.mission_mate.feature.board.screen.BoardRoute
import com.goalpanzi.mission_mate.feature.onboarding.navigateToOnboarding

internal const val missionIdArg = "missionId"


fun NavController.navigateToBoard(
missionId: Long,
Expand All @@ -18,17 +21,19 @@ fun NavController.navigateToBoard(
}
}
) {
this.navigate(RouteModel.Board(missionId = missionId),navOptions = navOptions)
this.navigate("RouteModel.Board" + "/${missionId}",navOptions = navOptions)
}

fun NavGraphBuilder.boardNavGraph(
onNavigateOnboarding: () -> Unit,
onClickSetting : () -> Unit
) {
composable<RouteModel.Board> { navBackStackEntry ->
val missionId = navBackStackEntry.toRoute<RouteModel.Board>().missionId
composable(
"RouteModel.Board/{$missionIdArg}",
arguments = listOf(navArgument(missionIdArg) { type = NavType.LongType })
) { navBackStackEntry ->
// val missionId = navBackStackEntry.toRoute<RouteModel.Board>().missionId
BoardRoute(
missionId = missionId,
onNavigateOnboarding = onNavigateOnboarding,
onClickSetting = onClickSetting
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ import kotlinx.coroutines.launch

@Composable
fun BoardRoute(
missionId : Long,
onNavigateOnboarding : () -> Unit,
onClickSetting : () -> Unit,
modifier: Modifier = Modifier,
Expand All @@ -77,9 +76,9 @@ fun BoardRoute(
}

LaunchedEffect(key1 = Unit) {
viewModel.getMissionBoards(missionId)
viewModel.getMission(missionId)
viewModel.getMissionVerification(missionId)
viewModel.getMissionBoards()
viewModel.getMission()
viewModel.getMissionVerification()

launch {
viewModel.deleteMissionResultEvent.collect {
Expand All @@ -106,7 +105,7 @@ fun BoardRoute(
isShownDeleteMissionDialog = false
},
onClickOk = {
viewModel.deleteMission(missionId)
viewModel.deleteMission()
}
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.goalpanzi.mission_mate.feature.board.screen

import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.goalpanzi.mission_mate.core.domain.usecase.DeleteMissionUseCase
Expand All @@ -26,9 +27,12 @@ class BoardViewModel @Inject constructor(
private val getMissionUseCase: GetMissionUseCase,
private val getMissionBoardsUseCase: GetMissionBoardsUseCase,
private val getMissionVerificationsUseCase: GetMissionVerificationsUseCase,
private val deleteMissionUseCase: DeleteMissionUseCase
private val deleteMissionUseCase: DeleteMissionUseCase,
savedStateHandle: SavedStateHandle
) : ViewModel() {

private val missionId : Long = savedStateHandle.get<Long>("missionId")!!

private val _deleteMissionResultEvent = MutableSharedFlow<Boolean>()
val deleteMissionResultEvent: SharedFlow<Boolean> = _deleteMissionResultEvent.asSharedFlow()

Expand All @@ -45,7 +49,7 @@ class BoardViewModel @Inject constructor(
val missionVerificationUiModel: StateFlow<MissionVerificationUiModel> =
_missionVerificationUiModel.asStateFlow()

fun getMissionBoards(missionId: Long) {
fun getMissionBoards() {
viewModelScope.launch {
_missionBoardUiModel.emit(MissionBoardUiModel.Loading)

Expand All @@ -67,7 +71,7 @@ class BoardViewModel @Inject constructor(
}
}

fun getMission(missionId: Long) {
fun getMission() {
viewModelScope.launch {
getMissionUseCase(missionId).catch {
_missionUiModel.emit(MissionUiModel.Error)
Expand All @@ -85,7 +89,7 @@ class BoardViewModel @Inject constructor(
}
}

fun getMissionVerification(missionId: Long) {
fun getMissionVerification() {
viewModelScope.launch {
getMissionVerificationsUseCase(missionId).catch {
_missionVerificationUiModel.emit(MissionVerificationUiModel.Error)
Expand All @@ -103,7 +107,7 @@ class BoardViewModel @Inject constructor(
}
}

fun deleteMission(missionId: Long) {
fun deleteMission() {
viewModelScope.launch {
deleteMissionUseCase(missionId)
.catch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import androidx.navigation.compose.composable
import com.goalpanzi.mission_mate.core.navigation.RouteModel

fun NavController.navigateToLogin() {
this.navigate(RouteModel.Login) {
this.navigate("RouteModel.Login") {
popUpTo(this@navigateToLogin.graph.id){
inclusive = true
}
Expand All @@ -16,7 +16,7 @@ fun NavController.navigateToLogin() {
fun NavGraphBuilder.loginNavGraph(
onLoginSuccess: (isProfileSet: Boolean) -> Unit
) {
composable<RouteModel.Login> {
composable("RouteModel.Login") {
LoginRoute(
onLoginSuccess = onLoginSuccess
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ fun LoginScreen(
.wrapContentHeight()
.padding(top = 175.dp)
.background(color = Color.White, shape = RoundedCornerShape(30.dp))
.padding(horizontal = 12.dp, vertical = 6.dp)
.clip(RoundedCornerShape(30.dp))
.clickable(onClick = onGoogleLoginClick),
.clickable(onClick = onGoogleLoginClick)
.padding(horizontal = 12.dp, vertical = 6.dp),
contentAlignment = Alignment.CenterStart
) {
Image(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import javax.inject.Inject

@HiltViewModel
class LoginViewModel @Inject constructor(
private val loginUseCase: LoginUseCase
private val loginUseCase: LoginUseCase,
) : ViewModel() {

private val _eventFlow = MutableSharedFlow<LoginEvent>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ class MainActivity : ComponentActivity() {
MainScreen(
navigator = navigator,
startDestination = if (isNewUser) {
RouteModel.Login
"RouteModel.Login"
} else {
if (user == null) {
RouteModel.Profile.Create
"RouteModel.Profile.Create"
} else {
RouteModel.Onboarding
"RouteModel.Onboarding"
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.goalpanzi.mission_mate.core.navigation.RouteModel
@Composable
internal fun MainScreen(
navigator: MainNavigator = rememberMainNavigator(),
startDestination: RouteModel
startDestination: String
) {
MainScreenContent(
navigator = navigator,
Expand All @@ -22,7 +22,7 @@ internal fun MainScreen(
@Composable
private fun MainScreenContent(
navigator: MainNavigator,
startDestination: RouteModel,
startDestination: String,
modifier: Modifier = Modifier
) {
Scaffold(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import com.luckyoct.feature.setting.navigation.settingNavGraph
internal fun MainNavHost(
modifier: Modifier = Modifier,
navigator: MainNavigator,
startDestination: RouteModel,
startDestination: String,
padding: PaddingValues
) {
Box(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ fun NavController.navigateToOnboarding(
}
}
) {
this.navigate(RouteModel.Onboarding,navOptions = navOptions)
this.navigate("RouteModel.Onboarding",navOptions = navOptions)
}

fun NavController.navigateToBoardSetup() {
this.navigate(OnboardingRouteModel.BoardSetup)
this.navigate("OnboardingRouteModel.BoardSetup")
}

fun NavController.navigateToBoardSetupSuccess(
Expand All @@ -32,11 +32,11 @@ fun NavController.navigateToBoardSetupSuccess(
}
}
) {
this.navigate(OnboardingRouteModel.BoardSetupSuccess,navOptions = navOptions)
this.navigate("OnboardingRouteModel.BoardSetupSuccess",navOptions = navOptions)
}

fun NavController.navigateToInvitationCode() {
this.navigate(OnboardingRouteModel.InvitationCode)
this.navigate("OnboardingRouteModel.InvitationCode")
}

fun NavGraphBuilder.onboardingNavGraph(
Expand All @@ -45,7 +45,7 @@ fun NavGraphBuilder.onboardingNavGraph(
onClickSetting: () -> Unit,
onNavigateMissionBoard : (Long) -> Unit
) {
composable<RouteModel.Onboarding> {
composable("RouteModel.Onboarding") {
OnboardingRoute(
onClickBoardSetup = onClickBoardSetup,
onClickInvitationCode = onClickInvitationCode,
Expand All @@ -59,7 +59,7 @@ fun NavGraphBuilder.boardSetupNavGraph(
onSuccess: () -> Unit,
onBackClick: () -> Unit
) {
composable<OnboardingRouteModel.BoardSetup> {
composable("OnboardingRouteModel.BoardSetup") {
BoardSetupRoute(
onSuccess = onSuccess,
onBackClick = onBackClick
Expand All @@ -70,7 +70,7 @@ fun NavGraphBuilder.boardSetupNavGraph(
fun NavGraphBuilder.boardSetupSuccessNavGraph(
onClickStart: () -> Unit
) {
composable<OnboardingRouteModel.BoardSetupSuccess> {
composable("OnboardingRouteModel.BoardSetupSuccess") {
BoardSetupSuccessScreen(
onClickStart = onClickStart
)
Expand All @@ -81,7 +81,7 @@ fun NavGraphBuilder.invitationCodeNavGraph(
onBackClick: () -> Unit,
onNavigateMissionBoard: (Long) -> Unit,
) {
composable<OnboardingRouteModel.InvitationCode> {
composable("OnboardingRouteModel.InvitationCode") {
InvitationCodeRoute(
onBackClick = onBackClick,
onNavigateMissionBoard = onNavigateMissionBoard
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.goalpanzi.mission_mate.feature.onboarding.screen.boardsetup

import android.annotation.SuppressLint
import android.widget.Toast
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.fillMaxSize
Expand Down Expand Up @@ -49,6 +52,8 @@ import com.goalpanzi.mission_mate.feature.onboarding.util.styledTextWithHighligh
import java.time.DayOfWeek
import java.time.LocalDate

@SuppressLint("UnrememberedMutableInteractionSource")
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun BoardSetupRoute(
onSuccess : () -> Unit,
Expand Down Expand Up @@ -125,7 +130,7 @@ fun BoardSetupRoute(

BoardSetupScreen(
modifier = Modifier.clickable(
null,
MutableInteractionSource(),
null,
onClick = {
keyboardController?.hide()
Expand Down Expand Up @@ -168,6 +173,7 @@ fun BoardSetupRoute(
)
}

@OptIn(ExperimentalFoundationApi::class)
@Composable
fun BoardSetupScreen(
currentStep: BoardSetupStep,
Expand Down
Loading

0 comments on commit 1fed30c

Please sign in to comment.