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 @@ -57,7 +57,9 @@ sealed interface ExploreRoute : Route {

sealed interface MyPageRoute : Route {
@Serializable
data object GainedCouponScreen : MyPageRoute
data class GainedCouponScreen(
val characterName: String,
) : MyPageRoute

@Serializable
data class AvailableCouponScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ fun OrbDiaryEmpty(
modifier: Modifier = Modifier,
) {
val emptyCharacterImage = when (characterName) {
"루미" -> R.drawable.img_diary_empty_rumi
"레디" -> R.drawable.img_diary_empty_ready
else -> R.drawable.img_diary_empty_nova
"루미" -> R.drawable.img_empty_rumi
"레디" -> R.drawable.img_empty_ready
else -> R.drawable.img_empty_nova
}

Column(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ internal fun MainNavHost(
navigateToBack = navigator::popBackStackIfNotMainTabRoute,
)
myPageNavGraph(
navigateToGainedCoupon = {
navigator.navigateToGainedCoupon()
},
navigateToGainedCoupon = navigator::navigateToGainedCoupon
,
navigateToAvailableCouponDetail = { id, name, couponImageUrl, description, placeId ->
navigator.navigateToAvailableCouponDetail(
id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,10 @@ internal class MainNavigator(
navController.navigateToMyPage(mainTabNavOptions)
}

fun navigateToGainedCoupon() {
navController.navigateToGainedCoupon()
fun navigateToGainedCoupon(
characterName: String
) {
navController.navigateToGainedCoupon(characterName = characterName)
}

fun navigateToAvailableCouponDetail(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import com.teamoffroad.feature.mypage.presentation.AnnouncementDetailScreen
import com.teamoffroad.feature.mypage.presentation.AnnouncementScreen
import com.teamoffroad.feature.mypage.presentation.AvailableCouponDetailScreen
import com.teamoffroad.feature.mypage.presentation.CharacterDetailScreen
import com.teamoffroad.feature.mypage.presentation.diaryTime.DiaryTimeScreen
import com.teamoffroad.feature.mypage.presentation.GainedCharacterScreen
import com.teamoffroad.feature.mypage.presentation.GainedCouponScreen
import com.teamoffroad.feature.mypage.presentation.GainedEmblemsScreen
import com.teamoffroad.feature.mypage.presentation.MyPageScreen
import com.teamoffroad.feature.mypage.presentation.SettingScreen
import com.teamoffroad.feature.mypage.presentation.SupportScreen
import com.teamoffroad.feature.mypage.presentation.diaryTime.DiaryTimeScreen

fun NavController.navigateToMyPage(navOptions: NavOptions) {
navigate(MainTabRoute.MyPage, navOptions)
Expand All @@ -28,8 +28,10 @@ fun NavController.navigateToGainedCharacter() {
navigate(MyPageRoute.GainedCharacter)
}

fun NavController.navigateToGainedCoupon() {
navigate(MyPageRoute.GainedCouponScreen)
fun NavController.navigateToGainedCoupon(
characterName: String
) {
navigate(MyPageRoute.GainedCouponScreen(characterName = characterName))
}

fun NavController.navigateToAvailableCouponDetail(
Expand Down Expand Up @@ -96,7 +98,7 @@ fun NavController.navigateToDiaryTime() {

fun NavGraphBuilder.myPageNavGraph(
navigateToGainedCharacter: () -> Unit,
navigateToGainedCoupon: () -> Unit,
navigateToGainedCoupon: (String) -> Unit,
navigateToAvailableCouponDetail: (Int, String, String, String, Int) -> Unit,
navigateToGainedEmblems: () -> Unit,
navigateToSetting: () -> Unit,
Expand Down Expand Up @@ -125,8 +127,13 @@ fun NavGraphBuilder.myPageNavGraph(
GainedCharacterScreen(navigateToCharacterDetail, navigateToBack)
}

composable<MyPageRoute.GainedCouponScreen> {
GainedCouponScreen(navigateToAvailableCouponDetail, navigateToBack)
composable<MyPageRoute.GainedCouponScreen> { backStackEntry ->
val characterName = backStackEntry.toRoute<MyPageRoute.GainedCouponScreen>().characterName
GainedCouponScreen(
characterName = characterName,
navigateToAvailableCouponDetail = navigateToAvailableCouponDetail,
navigateToMyPage = navigateToBack
)
}

composable<MyPageRoute.AvailableCouponScreen> { backStackEntry ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import com.teamoffroad.offroad.feature.mypage.R

@Composable
internal fun GainedCouponScreen(
characterName: String,
navigateToAvailableCouponDetail: (Int, String, String, String, Int) -> Unit,
navigateToMyPage: () -> Unit,
backgroundColor: Color = Main1,
Expand Down Expand Up @@ -64,6 +65,7 @@ internal fun GainedCouponScreen(
}
Spacer(modifier = Modifier.padding(vertical = 10.dp))
GainedCouponViewPager(
characterName = characterName,
availableCouponListState = viewModel.availableCouponListState.collectAsStateWithLifecycle(),
usedCouponListState = viewModel.usedCouponListState.collectAsStateWithLifecycle(),
availableCouponsCount = viewModel.availableCouponsCount.collectAsState().value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.teamoffroad.core.designsystem.component.actionBarPadding
import com.teamoffroad.core.designsystem.theme.ListBg
import com.teamoffroad.core.designsystem.theme.OffroadTheme
import com.teamoffroad.feature.mypage.presentation.component.AcquireCharacter
import com.teamoffroad.feature.mypage.presentation.component.AcquireCoupon
import com.teamoffroad.feature.mypage.presentation.component.AcquireEmblem
Expand All @@ -36,7 +34,7 @@ import com.teamoffroad.feature.mypage.presentation.component.UserSettings
@Composable
internal fun MyPageScreen(
navigateToGainedCharacter: () -> Unit,
navigateToGainedCoupon: () -> Unit,
navigateToGainedCoupon: (String) -> Unit,
navigateToGainedEmblems: () -> Unit,
navigateToSetting: () -> Unit,
navigateToDiary: (Boolean, String) -> Unit,
Expand Down Expand Up @@ -83,7 +81,12 @@ internal fun MyPageScreen(
)
UserDiary(
modifier = Modifier.padding(top = 8.dp),
navigateToUserDiary = { navigateToDiary(!newDiaryExist, myPageViewModel.characterName.value) }
navigateToUserDiary = {
navigateToDiary(
!newDiaryExist,
myPageViewModel.characterName.value
)
}
)
Row(
modifier = Modifier
Expand All @@ -106,7 +109,7 @@ internal fun MyPageScreen(
.aspectRatio(150f / 124f)
) {
AcquireCoupon(
navigateToGainedCoupon
navigateToAcquireCoupon = { navigateToGainedCoupon(myPageViewModel.characterName.value) }
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,21 @@ import com.teamoffroad.offroad.feature.mypage.R.drawable

@Composable
fun AvailableCouponItems(
emptyCharacterImage: Int,
availableCouponsCount: Int,
coupons: List<UserAvailableCoupons.AvailableCoupons>,
navigateToAvailableCouponDetail: (Int, String, String, String, Int) -> Unit,
getUserCoupons: (Boolean, Int) -> Unit,
) {

if (availableCouponsCount == 0) {
Column(
modifier = Modifier
.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally
) {
Image(
painter = painterResource(id = R.drawable.img_my_page_empty),
painter = painterResource(id = emptyCharacterImage),
contentDescription = "empty available coupon",
modifier = Modifier
.padding(start = 110.dp, top = 132.dp, end = 110.dp)
Expand Down Expand Up @@ -165,6 +167,7 @@ private fun AvailableCouponItem(

@Composable
fun UsedCouponItems(
emptyCharacterImage: Int,
usedCouponsCount: Int,
coupons: List<UserUsedCoupons.UsedCoupons>,
getUserCoupons: (Boolean, Int) -> Unit,
Expand All @@ -176,7 +179,7 @@ fun UsedCouponItems(
horizontalAlignment = Alignment.CenterHorizontally
) {
Image(
painter = painterResource(id = R.drawable.img_my_page_empty),
painter = painterResource(id = emptyCharacterImage),
contentDescription = "empty used coupon",
modifier = Modifier
.padding(start = 110.dp, top = 132.dp, end = 110.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import kotlinx.coroutines.launch

@Composable
fun GainedCouponViewPager(
characterName: String,
availableCouponListState: State<AvailableCouponListUiState>,
usedCouponListState: State<UsedCouponListUiState>,
availableCouponsCount: Int,
Expand All @@ -50,6 +51,12 @@ fun GainedCouponViewPager(
getUserAvailableCoupons: (Boolean, Int) -> Unit,
getUserUsedCoupons: (Boolean, Int) -> Unit,
) {
val emptyCharacterImage = when (characterName) {
"루미" -> com.teamoffroad.offroad.core.designsystem.R.drawable.img_empty_rumi
"레디" -> com.teamoffroad.offroad.core.designsystem.R.drawable.img_empty_ready
else -> com.teamoffroad.offroad.core.designsystem.R.drawable.img_empty_nova
}

val tabTitles = listOf(
stringResource(id = R.string.my_page_gained_coupon_available),
stringResource(id = R.string.my_page_gained_coupon_used)
Expand Down Expand Up @@ -118,13 +125,15 @@ fun GainedCouponViewPager(
) { page ->
when (page) {
0 -> AvailableCouponItems(
emptyCharacterImage = emptyCharacterImage,
availableCouponsCount,
coupons = availableCoupons,
navigateToAvailableCouponDetail = navigateToAvailableCouponDetail,
getUserAvailableCoupons,
)

1 -> UsedCouponItems(
emptyCharacterImage = emptyCharacterImage,
usedCouponsCount,
coupons = usedCoupons,
getUserUsedCoupons,
Expand Down