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

Feature/#52 , #56 뒤로가기 필요한 페이지에 GsTopAppBar 로 뒤로가기 가능한 탑바로 변경 & Navigation Stack 핸들링 하는 코드 삽입 #68

Merged
merged 1 commit into from
May 19, 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
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,20 @@ fun InputMenuScreen(
val shouldNavigate by inputMenuViewModel.shouldNavigateState.collectAsState()

Scaffold(
topBar = { GsTopAppBar(title = if (isEditMode) "메뉴 수정" else "메뉴 입력 (2/2)") },
topBar = {
GsTopAppBar(
title = if (isEditMode) "메뉴 수정" else "메뉴 입력 (2/2)",
hasLeftIcon = true,
onNavigationClick = {
navController.navigate(Screen.Setting.route) {
launchSingleTop = true
popUpTo(Screen.Setting.route) {
inclusive = false
}
}
},
)
},
) { paddingValues ->
Column(
modifier =
Expand Down Expand Up @@ -82,7 +95,12 @@ fun InputMenuScreen(
inputMenuViewModel.onEvent(InputMenuUiEvent.SendMenus)
if (shouldNavigate) {
val toNavigate = if (isEditMode) Screen.Setting else Screen.Main
navController.navigate(toNavigate.route)
navController.navigate(toNavigate.route) {
launchSingleTop = true
popUpTo(toNavigate.route) {
inclusive = false
}
}
}
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import com.erica.gamsung.core.presentation.Screen
import com.erica.gamsung.core.presentation.component.GsTopAppBar
import com.erica.gamsung.post.domain.ScheduleState
import com.erica.gamsung.post.presentation.utils.formatDate
import com.erica.gamsung.post.presentation.utils.formatTime
Expand Down Expand Up @@ -84,7 +85,22 @@ fun PostStatusScreen(
else -> true
}
} ?: listOf()
Scaffold {
Scaffold(
topBar = {
GsTopAppBar(
title = "",
hasLeftIcon = true,
onNavigationClick = {
navController.navigate(Screen.Main.route) {
launchSingleTop = true
popUpTo(navController.graph.startDestinationId) {
inclusive = false
}
}
},
)
},
) {
Column(
modifier =
Modifier
Expand All @@ -93,12 +109,6 @@ fun PostStatusScreen(
.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
) {
// Spacer(
// modifier =
// Modifier
// .fillMaxWidth()
// .size(75.dp),
// )
TitleTextSection(text = "발행 중인 글 목록")
StatusFilterButtons(selectedStatus = selectedStatus) { status ->
selectedStatus = status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ fun PreviewPost(
bottomBar = {
OneButtonSection(
modifier = Modifier.padding(vertical = 8.dp),
onClick = { navController.navigate(Screen.SelectNewPost.route) },
onClick = {
navController.navigate(Screen.SelectNewPost.route) {
launchSingleTop = true
}
},
)
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import kotlin.math.absoluteValue
@OptIn(
ExperimentalFoundationApi::class,
)
@Suppress("MagicNumber")
@Suppress("MagicNumber", "LongMethod")
@Preview
@Composable
fun SelectPostScreen(
Expand All @@ -82,7 +82,11 @@ fun SelectPostScreen(
val imgBitmap by postViewModel.imgBitMap.observeAsState()
val confirmAndNavigate = {
postViewModel.confirmPostData(reservationId, content, imgBitmap)
navController.navigate(Screen.PostsStatus.route)
navController.navigate(Screen.PostsStatus.route) {
popUpTo(navController.graph.startDestinationId) {
inclusive = false
}
}
Comment on lines +85 to +89
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

지금 메인화면이 네비게이션 그래프의 시작점이라서 메인화면 빼고 백스택에서 제거하는 거는 현재는 문제 없거든.

만약에 내가 로그인 화면을 네비게이션 그래프 시작점으로 추후에 두게 된다면 navController.graph.startDestinationId가 로그인 화면 가리킬 수도 있을 것 같아서 이 부분들은 인지하고 내가 나중에 같이 수정해볼게.

}
val setContent = { c: String ->
postViewModel.setContent(c)
Expand Down Expand Up @@ -113,7 +117,19 @@ fun SelectPostScreen(
})

Scaffold(
topBar = { GsTopAppBar(title = "글 선택 페이지") },
topBar = {
GsTopAppBar(
title = "글 선택 페이지",
hasLeftIcon = true,
onNavigationClick = {
navController.navigate(Screen.PostsStatus.route) {
popUpTo(navController.graph.startDestinationId) {
inclusive = false
}
}
},
)
},
content = { padding ->
Column(
modifier =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import java.time.DayOfWeek
import java.time.format.TextStyle
import java.util.Locale

@Suppress("LongMethod")
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun InputStoreScreen(
Expand All @@ -58,7 +59,20 @@ fun InputStoreScreen(
val inputStoreState by storeViewModel.inputStoreState.collectAsState()

Scaffold(
topBar = { GsTopAppBar(title = if (isEditMode) "식당 정보 수정" else "식당 정보 입력 (1/2)") },
topBar = {
GsTopAppBar(
title = if (isEditMode) "식당 정보 수정" else "식당 정보 입력 (1/2)",
hasLeftIcon = true,
onNavigationClick = {
navController.navigate(Screen.Setting.route) {
launchSingleTop = true
popUpTo(Screen.Setting.route) {
inclusive = false
}
}
},
)
},
) { paddingValues ->
Column(
modifier =
Expand Down Expand Up @@ -99,7 +113,12 @@ fun InputStoreScreen(
onClick = {
storeViewModel.onEvent(InputStoreUiEvent.SendStore)
val toNavigate = if (isEditMode) Screen.Setting else Screen.InputMenu(isEditMode = false)
navController.navigate(toNavigate.route)
navController.navigate(toNavigate.route) {
launchSingleTop = true
popUpTo(toNavigate.route) {
inclusive = false
}
}
},
enabled = inputStoreState.isValid,
isEditMode = isEditMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import androidx.compose.ui.unit.sp
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavHostController
import androidx.navigation.compose.rememberNavController
import com.erica.gamsung.core.presentation.Screen
import com.erica.gamsung.core.presentation.component.GsButton
import com.erica.gamsung.core.presentation.component.GsTopAppBar

@Suppress("magicnumber")
@Preview
Expand All @@ -35,7 +37,15 @@ fun MyCalendarScreen(
// 현재 달에 대한 초기 선택된 날짜 리스트 (예: 오늘)
// selectedDatesMap[currentMonth] = listOf(LocalDate.now())

Scaffold {
Scaffold(
topBar = {
GsTopAppBar(
title = "날짜 선택",
hasLeftIcon = true,
onNavigationClick = { navController.navigate(Screen.Main.route) },
)
},
) {
Column(
modifier =
Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ fun UploadTimeConfirmScreen(navController: NavHostController = rememberNavContro
horizontalAlignment = Alignment.CenterHorizontally,
) {
Spacer(modifier = Modifier.weight(1f))
ContentSection(modifier = Modifier.weight(2f), onClickEvent = { navController.navigate(Screen.Main.route) })
ContentSection(modifier = Modifier.weight(2f), onClickEvent = {
navController.navigate(Screen.Main.route) {
launchSingleTop = true
popUpTo(navController.graph.startDestinationId) {
inclusive = true
}
}
})
Spacer(modifier = Modifier.weight(1f))
}
}
Expand Down
Loading