diff --git a/app/src/main/java/pokitmons/pokit/navigation/RootDestination.kt b/app/src/main/java/pokitmons/pokit/navigation/RootDestination.kt index 21006895..aa7f1bb6 100644 --- a/app/src/main/java/pokitmons/pokit/navigation/RootDestination.kt +++ b/app/src/main/java/pokitmons/pokit/navigation/RootDestination.kt @@ -54,8 +54,15 @@ object AddPokit { object PokitDetail { val route: String = "pokitDetail" val pokitIdArg = "pokit_id" - val routeWithArgs = "$route/{$pokitIdArg}" - var arguments = listOf(navArgument(pokitIdArg) { defaultValue = "-" }) + val pokitCountQuery = "pokit_count" + val routeWithArgs = "$route/{$pokitIdArg}?$pokitCountQuery={$pokitCountQuery}" + var arguments = listOf( + navArgument(pokitIdArg) { defaultValue = "-" }, + navArgument(pokitCountQuery) { + nullable = true + type = NavType.StringType + } + ) } object Search { diff --git a/app/src/main/java/pokitmons/pokit/navigation/RootNavHost.kt b/app/src/main/java/pokitmons/pokit/navigation/RootNavHost.kt index c9edf027..238f3b8a 100644 --- a/app/src/main/java/pokitmons/pokit/navigation/RootNavHost.kt +++ b/app/src/main/java/pokitmons/pokit/navigation/RootNavHost.kt @@ -182,7 +182,11 @@ fun RootNavHost( viewModel = viewModel, onNavigateToSearch = { navHostController.navigate(Search.route) }, onNavigateToSetting = { navHostController.navigate(Setting.route) }, - onNavigateToPokitDetail = { navHostController.navigate("${PokitDetail.route}/$it") }, + onNavigateToPokitDetail = { pokitId, linkCount -> + navHostController.navigate( + "${PokitDetail.route}/$pokitId?${PokitDetail.pokitCountQuery}=$linkCount" + ) + }, onNavigateAddLink = { navHostController.navigate(AddLink.route) }, onNavigateAddPokit = { navHostController.navigate(AddPokit.route) }, onNavigateToLinkModify = { navHostController.navigate("${AddLink.route}?${AddLink.linkIdArg}=$it") }, diff --git a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/bottomsheet/PokitBottomSheet.kt b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/bottomsheet/PokitBottomSheet.kt index dbd9e606..53bb0d50 100644 --- a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/bottomsheet/PokitBottomSheet.kt +++ b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/bottomsheet/PokitBottomSheet.kt @@ -28,6 +28,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.unit.dp import kotlinx.coroutines.launch import pokitmons.pokit.core.ui.theme.PokitTheme @@ -65,6 +66,7 @@ fun PokitBottomSheet( visibility = false } }, + shape = RectangleShape, sheetState = bottomSheetState, scrimColor = Color.Transparent, containerColor = Color.Transparent, @@ -75,7 +77,7 @@ fun PokitBottomSheet( Surface( shape = RoundedCornerShape(topStart = 20.dp, topEnd = 20.dp), color = PokitTheme.colors.backgroundBase, - shadowElevation = 20.dp + shadowElevation = 8.dp ) { Column( modifier = Modifier.fillMaxWidth() diff --git a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pooki/Pooki.kt b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pooki/Pooki.kt new file mode 100644 index 00000000..d811e8ec --- /dev/null +++ b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pooki/Pooki.kt @@ -0,0 +1,47 @@ +package pokitmons.pokit.core.ui.components.template.pooki + +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.size +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.unit.dp +import pokitmons.pokit.core.ui.R +import pokitmons.pokit.core.ui.theme.PokitTheme + +@Composable +fun Pooki( + modifier: Modifier = Modifier, + title: String, + sub: String, +) { + Box( + modifier = modifier, + contentAlignment = Alignment.Center + ) { + Column( + horizontalAlignment = Alignment.CenterHorizontally + ) { + Image( + modifier = Modifier + .size(180.dp), + painter = painterResource(id = R.drawable.pooki), + contentDescription = "pooki" + ) + + Spacer(modifier = Modifier.height(16.dp)) + + Text(text = title, style = PokitTheme.typography.title2.copy(color = PokitTheme.colors.textPrimary)) + + Spacer(modifier = Modifier.height(8.dp)) + + Text(text = sub, style = PokitTheme.typography.body2Medium.copy(color = PokitTheme.colors.textSecondary)) + } + } +} diff --git a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pooki/Preview.kt b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pooki/Preview.kt new file mode 100644 index 00000000..1a33b261 --- /dev/null +++ b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pooki/Preview.kt @@ -0,0 +1,18 @@ +package pokitmons.pokit.core.ui.components.template.pooki + +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material3.Surface +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import pokitmons.pokit.core.ui.theme.PokitTheme + +@Preview(showBackground = true) +@Composable +private fun Preview() { + PokitTheme { + Surface(modifier = Modifier.fillMaxSize()) { + Pooki(title = "저장된 포킷이 없어요!", sub = "포킷을 생성해 링크를 저장해보세요") + } + } +} diff --git a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pokkiempty/EmptyPokki.kt b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pookiempty/EmptyPooki.kt similarity index 86% rename from core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pokkiempty/EmptyPokki.kt rename to core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pookiempty/EmptyPooki.kt index 48ab6577..67d7f820 100644 --- a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pokkiempty/EmptyPokki.kt +++ b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pookiempty/EmptyPooki.kt @@ -1,11 +1,11 @@ -package pokitmons.pokit.core.ui.components.template.pokkiempty +package pokitmons.pokit.core.ui.components.template.pookiempty import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.width +import androidx.compose.foundation.layout.size import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -16,7 +16,7 @@ import pokitmons.pokit.core.ui.R import pokitmons.pokit.core.ui.theme.PokitTheme @Composable -fun EmptyPokki( +fun EmptyPooki( modifier: Modifier = Modifier, title: String, sub: String, @@ -30,9 +30,8 @@ fun EmptyPokki( ) { Image( modifier = Modifier - .height(180.dp) - .width(180.dp), - painter = painterResource(id = R.drawable.empty_pokki), + .size(180.dp), + painter = painterResource(id = R.drawable.empty_pooki), contentDescription = "empty" ) diff --git a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pokkiempty/Preview.kt b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pookiempty/Preview.kt similarity index 79% rename from core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pokkiempty/Preview.kt rename to core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pookiempty/Preview.kt index ee20afed..175f345b 100644 --- a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pokkiempty/Preview.kt +++ b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pookiempty/Preview.kt @@ -1,4 +1,4 @@ -package pokitmons.pokit.core.ui.components.template.pokkiempty +package pokitmons.pokit.core.ui.components.template.pookiempty import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.Surface @@ -12,7 +12,7 @@ import pokitmons.pokit.core.ui.theme.PokitTheme private fun Preview() { PokitTheme { Surface(modifier = Modifier.fillMaxSize()) { - EmptyPokki(title = "저장된 포킷이 없어요!", sub = "포킷을 생성해 링크를 저장해보세요") + EmptyPooki(title = "저장된 포킷이 없어요!", sub = "포킷을 생성해 링크를 저장해보세요") } } } diff --git a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pokkierror/ErrorPokki.kt b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pookierror/ErrorPokki.kt similarity index 90% rename from core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pokkierror/ErrorPokki.kt rename to core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pookierror/ErrorPokki.kt index 666fdcb1..67429cc2 100644 --- a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pokkierror/ErrorPokki.kt +++ b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pookierror/ErrorPokki.kt @@ -1,11 +1,11 @@ -package pokitmons.pokit.core.ui.components.template.pokkierror +package pokitmons.pokit.core.ui.components.template.pookierror import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.width +import androidx.compose.foundation.layout.size import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -22,9 +22,9 @@ import pokitmons.pokit.core.ui.components.atom.button.attributes.PokitButtonType import pokitmons.pokit.core.ui.theme.PokitTheme @Composable -fun ErrorPokki( +fun ErrorPooki( modifier: Modifier = Modifier, - pokkiSize: Dp = 180.dp, + pookiSize: Dp = 180.dp, title: String, sub: String, onClickRetry: (() -> Unit)? = null, @@ -38,9 +38,8 @@ fun ErrorPokki( ) { Image( modifier = Modifier - .height(pokkiSize) - .width(pokkiSize), - painter = painterResource(id = R.drawable.cry_pokki), + .size(pookiSize), + painter = painterResource(id = R.drawable.cry_pooki), contentDescription = "empty" ) diff --git a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pokkierror/Preview.kt b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pookierror/Preview.kt similarity index 74% rename from core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pokkierror/Preview.kt rename to core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pookierror/Preview.kt index e603d87c..80673356 100644 --- a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pokkierror/Preview.kt +++ b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/pookierror/Preview.kt @@ -1,4 +1,4 @@ -package pokitmons.pokit.core.ui.components.template.pokkierror +package pokitmons.pokit.core.ui.components.template.pookierror import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.Surface @@ -12,8 +12,8 @@ import pokitmons.pokit.core.ui.theme.PokitTheme private fun Preview() { PokitTheme { Surface(modifier = Modifier.fillMaxSize()) { - ErrorPokki(title = "오류가 발생했어요", sub = "조금 뒤 다시 접속해주세요", onClickRetry = null) - // ErrorPokki(title = "오류가 발생했어요", sub = "조금 뒤 다시 접속해주세요", onClickRetry = {}) + ErrorPooki(title = "오류가 발생했어요", sub = "조금 뒤 다시 접속해주세요", onClickRetry = null) + // ErrorPooki(title = "오류가 발생했어요", sub = "조금 뒤 다시 접속해주세요", onClickRetry = {}) } } } diff --git a/core/ui/src/main/res/drawable-hdpi/big_pokki.png b/core/ui/src/main/res/drawable-hdpi/big_pooki.png similarity index 100% rename from core/ui/src/main/res/drawable-hdpi/big_pokki.png rename to core/ui/src/main/res/drawable-hdpi/big_pooki.png diff --git a/core/ui/src/main/res/drawable-hdpi/cry_pokki.png b/core/ui/src/main/res/drawable-hdpi/cry_pooki.png similarity index 100% rename from core/ui/src/main/res/drawable-hdpi/cry_pokki.png rename to core/ui/src/main/res/drawable-hdpi/cry_pooki.png diff --git a/core/ui/src/main/res/drawable-hdpi/empty_pokki.png b/core/ui/src/main/res/drawable-hdpi/empty_pooki.png similarity index 100% rename from core/ui/src/main/res/drawable-hdpi/empty_pokki.png rename to core/ui/src/main/res/drawable-hdpi/empty_pooki.png diff --git a/core/ui/src/main/res/drawable-hdpi/pooki.png b/core/ui/src/main/res/drawable-hdpi/pooki.png new file mode 100644 index 00000000..8cc25883 Binary files /dev/null and b/core/ui/src/main/res/drawable-hdpi/pooki.png differ diff --git a/core/ui/src/main/res/drawable-mdpi/big_pokki.png b/core/ui/src/main/res/drawable-mdpi/big_pooki.png similarity index 100% rename from core/ui/src/main/res/drawable-mdpi/big_pokki.png rename to core/ui/src/main/res/drawable-mdpi/big_pooki.png diff --git a/core/ui/src/main/res/drawable-mdpi/cry_pokki.png b/core/ui/src/main/res/drawable-mdpi/cry_pooki.png similarity index 100% rename from core/ui/src/main/res/drawable-mdpi/cry_pokki.png rename to core/ui/src/main/res/drawable-mdpi/cry_pooki.png diff --git a/core/ui/src/main/res/drawable-mdpi/empty_pokki.png b/core/ui/src/main/res/drawable-mdpi/empty_pooki.png similarity index 100% rename from core/ui/src/main/res/drawable-mdpi/empty_pokki.png rename to core/ui/src/main/res/drawable-mdpi/empty_pooki.png diff --git a/core/ui/src/main/res/drawable-mdpi/pooki.png b/core/ui/src/main/res/drawable-mdpi/pooki.png new file mode 100644 index 00000000..a33a2181 Binary files /dev/null and b/core/ui/src/main/res/drawable-mdpi/pooki.png differ diff --git a/core/ui/src/main/res/drawable-xhdpi/big_pokki.png b/core/ui/src/main/res/drawable-xhdpi/big_pooki.png similarity index 100% rename from core/ui/src/main/res/drawable-xhdpi/big_pokki.png rename to core/ui/src/main/res/drawable-xhdpi/big_pooki.png diff --git a/core/ui/src/main/res/drawable-xhdpi/cry_pokki.png b/core/ui/src/main/res/drawable-xhdpi/cry_pooki.png similarity index 100% rename from core/ui/src/main/res/drawable-xhdpi/cry_pokki.png rename to core/ui/src/main/res/drawable-xhdpi/cry_pooki.png diff --git a/core/ui/src/main/res/drawable-xhdpi/empty_pokki.png b/core/ui/src/main/res/drawable-xhdpi/empty_pooki.png similarity index 100% rename from core/ui/src/main/res/drawable-xhdpi/empty_pokki.png rename to core/ui/src/main/res/drawable-xhdpi/empty_pooki.png diff --git a/core/ui/src/main/res/drawable-xhdpi/pooki.png b/core/ui/src/main/res/drawable-xhdpi/pooki.png new file mode 100644 index 00000000..c17d09fc Binary files /dev/null and b/core/ui/src/main/res/drawable-xhdpi/pooki.png differ diff --git a/core/ui/src/main/res/drawable-xxhdpi/big_pokki.png b/core/ui/src/main/res/drawable-xxhdpi/big_pooki.png similarity index 100% rename from core/ui/src/main/res/drawable-xxhdpi/big_pokki.png rename to core/ui/src/main/res/drawable-xxhdpi/big_pooki.png diff --git a/core/ui/src/main/res/drawable-xxhdpi/cry_pokki.png b/core/ui/src/main/res/drawable-xxhdpi/cry_pooki.png similarity index 100% rename from core/ui/src/main/res/drawable-xxhdpi/cry_pokki.png rename to core/ui/src/main/res/drawable-xxhdpi/cry_pooki.png diff --git a/core/ui/src/main/res/drawable-xxhdpi/empty_pokki.png b/core/ui/src/main/res/drawable-xxhdpi/empty_pooki.png similarity index 100% rename from core/ui/src/main/res/drawable-xxhdpi/empty_pokki.png rename to core/ui/src/main/res/drawable-xxhdpi/empty_pooki.png diff --git a/core/ui/src/main/res/drawable-xxhdpi/pooki.png b/core/ui/src/main/res/drawable-xxhdpi/pooki.png new file mode 100644 index 00000000..3fd0412c Binary files /dev/null and b/core/ui/src/main/res/drawable-xxhdpi/pooki.png differ diff --git a/core/ui/src/main/res/drawable-xxxhdpi/big_pokki.png b/core/ui/src/main/res/drawable-xxxhdpi/big_pooki.png similarity index 100% rename from core/ui/src/main/res/drawable-xxxhdpi/big_pokki.png rename to core/ui/src/main/res/drawable-xxxhdpi/big_pooki.png diff --git a/core/ui/src/main/res/drawable-xxxhdpi/cry_pokki.png b/core/ui/src/main/res/drawable-xxxhdpi/cry_pooki.png similarity index 100% rename from core/ui/src/main/res/drawable-xxxhdpi/cry_pokki.png rename to core/ui/src/main/res/drawable-xxxhdpi/cry_pooki.png diff --git a/core/ui/src/main/res/drawable-xxxhdpi/empty_pokki.png b/core/ui/src/main/res/drawable-xxxhdpi/empty_pooki.png similarity index 100% rename from core/ui/src/main/res/drawable-xxxhdpi/empty_pokki.png rename to core/ui/src/main/res/drawable-xxxhdpi/empty_pooki.png diff --git a/core/ui/src/main/res/drawable-xxxhdpi/pooki.png b/core/ui/src/main/res/drawable-xxxhdpi/pooki.png new file mode 100644 index 00000000..6a2fcade Binary files /dev/null and b/core/ui/src/main/res/drawable-xxxhdpi/pooki.png differ diff --git a/core/ui/src/main/res/values/string.xml b/core/ui/src/main/res/values/string.xml index 218ebd8d..cd43f1d7 100644 --- a/core/ui/src/main/res/values/string.xml +++ b/core/ui/src/main/res/values/string.xml @@ -31,4 +31,7 @@ 검색된 링크가 없어요 검색어를 다시 확인해주세요 + + 아직 알람이 없어요 + 리마인드 알림을 설정하세요 \ No newline at end of file diff --git a/feature/addlink/src/main/java/com/strayalpaca/addlink/AddLinkViewModel.kt b/feature/addlink/src/main/java/com/strayalpaca/addlink/AddLinkViewModel.kt index 84b04a4e..2c089666 100644 --- a/feature/addlink/src/main/java/com/strayalpaca/addlink/AddLinkViewModel.kt +++ b/feature/addlink/src/main/java/com/strayalpaca/addlink/AddLinkViewModel.kt @@ -245,7 +245,7 @@ class AddLinkViewModel @Inject constructor( val linkArg = LinkArg( id = responseLink.id, title = responseLink.title, - thumbnail = responseLink.thumbnail, + thumbnail = currentState.link.imageUrl ?: responseLink.thumbnail, domain = responseLink.domain, createdAt = responseLink.createdAt, pokitId = currentSelectedPokit.id.toInt() diff --git a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitViewModel.kt b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitViewModel.kt index 756d5e38..d032f3bd 100644 --- a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitViewModel.kt +++ b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitViewModel.kt @@ -65,6 +65,8 @@ class AddPokitViewModel @Inject constructor( private val _pokitIamges = MutableStateFlow>(emptyList()) val pokitImages: StateFlow> = _pokitIamges.asStateFlow() + private var existingPokitName: String? = null + init { initPokitList() loadPokitImages() @@ -114,6 +116,7 @@ class AddPokitViewModel @Inject constructor( state.copy(isModify = true, pokitImage = PokitImage.fromDomainPokitImage(response.result.image)) } _pokitName.update { response.result.name } + existingPokitName = response.result.name } else { postSideEffect(AddPokitSideEffect.OnNavigationBack) } @@ -137,7 +140,9 @@ class AddPokitViewModel @Inject constructor( fun savePokit() = intent { // todo 에러 코드 파싱 수정시 제거 필요 - if (pokitPaging.pagingData.value.find { it.title == pokitName.value } != null) { + val needNicknameCheck = (pokitName.value != existingPokitName) + val nicknameDuplicated = (pokitPaging.pagingData.value.find { it.title == pokitName.value } != null) + if (needNicknameCheck && nicknameDuplicated) { val errorMessage = errorMessageProvider.errorCodeToMessage(PokitErrorCode.ALREADY_USED_POKIT_NAME) reduce { state.copy(errorToastMessage = errorMessage) } return@intent diff --git a/feature/alarm/src/main/java/pokitmons/pokit/alarm/AlarmScreen.kt b/feature/alarm/src/main/java/pokitmons/pokit/alarm/AlarmScreen.kt index 14ff731d..965b327a 100644 --- a/feature/alarm/src/main/java/pokitmons/pokit/alarm/AlarmScreen.kt +++ b/feature/alarm/src/main/java/pokitmons/pokit/alarm/AlarmScreen.kt @@ -19,6 +19,10 @@ import pokitmons.pokit.alarm.components.alarmitem.AlarmItem import pokitmons.pokit.alarm.components.toolbar.Toolbar import pokitmons.pokit.alarm.model.Alarm import pokitmons.pokit.alarm.paging.SimplePagingState +import pokitmons.pokit.core.ui.components.atom.loading.LoadingProgress +import pokitmons.pokit.core.ui.components.template.pooki.Pooki +import pokitmons.pokit.core.ui.components.template.pookierror.ErrorPooki +import pokitmons.pokit.core.ui.R.string as coreString @Composable fun AlarmScreenContainer( @@ -40,7 +44,8 @@ fun AlarmScreenContainer( onClickAlarmRemove = viewModel::removeAlarm, alarms = alarms, alarmsState = alarmsState, - loadNextAlarms = viewModel::loadNextAlarms + loadNextAlarms = viewModel::loadNextAlarms, + refreshAlarms = viewModel::refreshAlarms ) } @@ -53,6 +58,7 @@ fun AlarmScreen( alarms: List = emptyList(), alarmsState: SimplePagingState = SimplePagingState.IDLE, loadNextAlarms: () -> Unit = {}, + refreshAlarms: () -> Unit = {}, ) { Column( modifier = Modifier.fillMaxSize() @@ -77,23 +83,53 @@ fun AlarmScreen( } } - LazyColumn( - modifier = Modifier - .fillMaxWidth() - .weight(1f), - state = alarmLazyColumnListState - ) { - items( - items = alarms, - key = { alarm -> alarm.id } - ) { alarm -> - AlarmItem( - modifier = Modifier.animateItemPlacement(), - alarm = alarm, - onClickAlarm = onClickAlarm, - onClickRemove = onClickAlarmRemove + when { + alarmsState == SimplePagingState.LOADING_INIT -> { + LoadingProgress( + modifier = Modifier + .fillMaxWidth() + .weight(1f) ) } + alarmsState == SimplePagingState.FAILURE_INIT -> { + ErrorPooki( + modifier = Modifier + .fillMaxWidth() + .weight(1f), + title = stringResource(id = coreString.title_error), + sub = stringResource(id = coreString.sub_error), + onClickRetry = refreshAlarms + ) + } + alarms.isEmpty() -> { + Pooki( + modifier = Modifier + .fillMaxWidth() + .weight(1f), + title = stringResource(id = coreString.title_empty_alarms), + sub = stringResource(id = coreString.sub_empty_alarms) + ) + } + else -> { + LazyColumn( + modifier = Modifier + .fillMaxWidth() + .weight(1f), + state = alarmLazyColumnListState + ) { + items( + items = alarms, + key = { alarm -> alarm.id } + ) { alarm -> + AlarmItem( + modifier = Modifier.animateItemPlacement(), + alarm = alarm, + onClickAlarm = onClickAlarm, + onClickRemove = onClickAlarmRemove + ) + } + } + } } } } diff --git a/feature/alarm/src/main/java/pokitmons/pokit/alarm/AlarmViewModel.kt b/feature/alarm/src/main/java/pokitmons/pokit/alarm/AlarmViewModel.kt index da09f4d2..8da4f137 100644 --- a/feature/alarm/src/main/java/pokitmons/pokit/alarm/AlarmViewModel.kt +++ b/feature/alarm/src/main/java/pokitmons/pokit/alarm/AlarmViewModel.kt @@ -50,6 +50,12 @@ class AlarmViewModel @Inject constructor( } } + fun refreshAlarms() { + viewModelScope.launch { + alarmPaging.refresh() + } + } + fun readAlarm(alarmId: String) { val targetAlarm = alarms.value.find { it.id == alarmId } ?: return diff --git a/feature/home/src/main/java/pokitmons/pokit/home/HomeScreen.kt b/feature/home/src/main/java/pokitmons/pokit/home/HomeScreen.kt index 86c878a0..ab29eac8 100644 --- a/feature/home/src/main/java/pokitmons/pokit/home/HomeScreen.kt +++ b/feature/home/src/main/java/pokitmons/pokit/home/HomeScreen.kt @@ -49,7 +49,7 @@ import pokitmons.pokit.home.remind.RemindScreen @Composable fun HomeScreen( viewModel: PokitViewModel, - onNavigateToPokitDetail: (String) -> Unit, + onNavigateToPokitDetail: (String, Int) -> Unit, onNavigateToSearch: () -> Unit, onNavigateToSetting: () -> Unit, onNavigateAddLink: () -> Unit, diff --git a/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitScreen.kt b/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitScreen.kt index da716fc9..0716220c 100644 --- a/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitScreen.kt +++ b/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitScreen.kt @@ -28,8 +28,8 @@ import pokitmons.pokit.core.ui.components.atom.loading.LoadingProgress import pokitmons.pokit.core.ui.components.block.pokitcard.PokitCard import pokitmons.pokit.core.ui.components.template.bottomsheet.PokitBottomSheet import pokitmons.pokit.core.ui.components.template.modifybottomsheet.ModifyBottomSheetContent -import pokitmons.pokit.core.ui.components.template.pokkiempty.EmptyPokki -import pokitmons.pokit.core.ui.components.template.pokkierror.ErrorPokki +import pokitmons.pokit.core.ui.components.template.pookiempty.EmptyPooki +import pokitmons.pokit.core.ui.components.template.pookierror.ErrorPooki import pokitmons.pokit.core.ui.components.template.removeItemBottomSheet.TwoButtonBottomSheetContent import pokitmons.pokit.core.ui.R.string as coreString @@ -37,7 +37,7 @@ import pokitmons.pokit.core.ui.R.string as coreString fun PokitScreen( modifier: Modifier = Modifier, viewModel: PokitViewModel, - onNavigateToPokitDetail: (String) -> Unit, + onNavigateToPokitDetail: (String, Int) -> Unit, onNavigateToLinkModify: (String) -> Unit, onNavigateToPokitModify: (String) -> Unit, ) { @@ -101,7 +101,7 @@ fun PokitScreen( LoadingProgress(modifier = Modifier.fillMaxSize()) } (pokitsState == SimplePagingState.FAILURE_INIT) -> { - ErrorPokki( + ErrorPooki( modifier = Modifier.fillMaxSize(), title = stringResource(id = coreString.title_error), sub = stringResource(id = coreString.sub_error), @@ -109,7 +109,7 @@ fun PokitScreen( ) } (pokits.value.isEmpty()) -> { - EmptyPokki( + EmptyPooki( modifier = Modifier.fillMaxSize(), title = stringResource(id = coreString.title_empty_pokits), sub = stringResource(id = coreString.sub_empty_pokits) @@ -131,7 +131,7 @@ fun PokitScreen( text = pokitDetail.title, linkCount = pokitDetail.count, painter = rememberAsyncImagePainter(model = pokitDetail.image.url), - onClick = { onNavigateToPokitDetail(pokitDetail.id) }, + onClick = { onNavigateToPokitDetail(pokitDetail.id, pokitDetail.count) }, onClickKebab = { viewModel.showPokitDetailOptionBottomSheet(pokitDetail) } @@ -148,7 +148,7 @@ fun PokitScreen( LoadingProgress(modifier = Modifier.fillMaxSize()) } (unCategoryLinksState == SimplePagingState.FAILURE_INIT) -> { - ErrorPokki( + ErrorPooki( modifier = Modifier.fillMaxSize(), title = stringResource(id = coreString.title_error), sub = stringResource(id = coreString.sub_error), @@ -156,7 +156,7 @@ fun PokitScreen( ) } (unCategoryLinks.value.isEmpty()) -> { - EmptyPokki( + EmptyPooki( modifier = Modifier.fillMaxSize(), title = stringResource(id = coreString.title_empty_links), sub = stringResource(id = coreString.sub_empty_links) diff --git a/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitViewModel.kt b/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitViewModel.kt index 98b4de07..edbc9059 100644 --- a/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitViewModel.kt +++ b/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitViewModel.kt @@ -24,6 +24,7 @@ import pokitmons.pokit.domain.model.link.LinksSort import pokitmons.pokit.domain.model.pokit.MAX_POKIT_COUNT import pokitmons.pokit.domain.model.pokit.PokitsSort import pokitmons.pokit.domain.usecase.link.DeleteLinkUseCase +import pokitmons.pokit.domain.usecase.link.GetLinkUseCase import pokitmons.pokit.domain.usecase.link.GetLinksUseCase import pokitmons.pokit.domain.usecase.link.SetBookmarkUseCase import pokitmons.pokit.domain.usecase.pokit.DeletePokitUseCase @@ -43,6 +44,7 @@ class PokitViewModel @Inject constructor( private val getPokitCountUseCase: GetPokitCountUseCase, private val deleteLinkUseCase: DeleteLinkUseCase, private val setBookmarkUseCase: SetBookmarkUseCase, + private val getLinkUseCase: GetLinkUseCase, ) : ViewModel() { private val _sideEffect = MutableEventFlow() @@ -56,13 +58,18 @@ class PokitViewModel @Inject constructor( LinkUpdateEvent.updatedLink.collectLatest { updatedLink -> val targetLink = linkPaging.pagingData.value.find { it.id == updatedLink.id.toString() } ?: return@collectLatest - val modifiedLink = targetLink.copy( - title = updatedLink.title, - imageUrl = updatedLink.thumbnail, - domainUrl = updatedLink.domain, - createdAt = updatedLink.createdAt - ) - linkPaging.modifyItem(modifiedLink) + val isCategoryChanged = (targetLink.pokitId != updatedLink.pokitId.toString()) + if (isCategoryChanged) { + linkPaging.deleteItem(targetLink) + } else { + val modifiedLink = targetLink.copy( + title = updatedLink.title, + imageUrl = updatedLink.thumbnail, + domainUrl = updatedLink.domain, + createdAt = updatedLink.createdAt + ) + linkPaging.modifyItem(modifiedLink) + } } } } @@ -306,6 +313,11 @@ class PokitViewModel @Inject constructor( _linkOptionBottomSheetType.update { BottomSheetType.REMOVE } } + fun showLinkRemoveBottomSheet(link: DetailLink) { + _currentSelectedLink.update { link } + _linkOptionBottomSheetType.update { BottomSheetType.REMOVE } + } + fun removeCurrentSelectedLink() { val currentSelectedLinkId = currentSelectedLink.value?.id?.toIntOrNull() ?: return viewModelScope.launch { @@ -318,6 +330,34 @@ class PokitViewModel @Inject constructor( fun showDetailLinkBottomSheet(link: DetailLink) { _currentDetailShowLink.update { link } + + viewModelScope.launch { + val response = getLinkUseCase.getLink(link.id.toInt()) + if (response is PokitResult.Success) { + val responseLink = response.result + if (_currentDetailShowLink.value?.id == responseLink.id.toString()) { + _currentDetailShowLink.update { + DetailLink( + id = responseLink.id.toString(), + title = responseLink.title, + dateString = responseLink.createdAt, + url = responseLink.data, + isRead = true, + domainUrl = responseLink.domain, + imageUrl = _currentDetailShowLink.value?.imageUrl, + memo = responseLink.memo, + bookmark = responseLink.favorites, + pokitName = responseLink.categoryName + ) + } + } + val isReadChangedLink = linkPaging.pagingData.value + .find { it.id == link.id } + ?.copy(isRead = true) ?: return@launch + + linkPaging.modifyItem(isReadChangedLink) + } + } } fun hideDetailLinkBottomSheet() { diff --git a/feature/home/src/main/java/pokitmons/pokit/home/pokit/UnclassifiedScreen.kt b/feature/home/src/main/java/pokitmons/pokit/home/pokit/UnclassifiedScreen.kt index 011e44cc..0bc81537 100644 --- a/feature/home/src/main/java/pokitmons/pokit/home/pokit/UnclassifiedScreen.kt +++ b/feature/home/src/main/java/pokitmons/pokit/home/pokit/UnclassifiedScreen.kt @@ -58,6 +58,14 @@ fun UnclassifiedScreen( } context.startActivity(Intent.createChooser(intent, "Pokit")) }, + onClickModifyLink = { + viewModel.hideDetailLinkBottomSheet() + onNavigateToLinkModify(link.id) + }, + onClickRemoveLink = { + viewModel.hideDetailLinkBottomSheet() + viewModel.showLinkRemoveBottomSheet(link) + }, onClickBookmark = viewModel::toggleBookmark ) } diff --git a/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindScreen.kt b/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindScreen.kt index bcc902c0..9395d92d 100644 --- a/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindScreen.kt +++ b/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindScreen.kt @@ -33,8 +33,8 @@ import pokitmons.pokit.core.ui.components.block.linkcard.LinkCard import pokitmons.pokit.core.ui.components.template.bottomsheet.PokitBottomSheet import pokitmons.pokit.core.ui.components.template.linkdetailbottomsheet.LinkDetailBottomSheet import pokitmons.pokit.core.ui.components.template.modifybottomsheet.ModifyBottomSheetContent -import pokitmons.pokit.core.ui.components.template.pokkiempty.EmptyPokki -import pokitmons.pokit.core.ui.components.template.pokkierror.ErrorPokki +import pokitmons.pokit.core.ui.components.template.pookiempty.EmptyPooki +import pokitmons.pokit.core.ui.components.template.pookierror.ErrorPooki import pokitmons.pokit.core.ui.components.template.removeItemBottomSheet.TwoButtonBottomSheetContent import pokitmons.pokit.core.ui.theme.PokitTheme import pokitmons.pokit.core.ui.R.string as coreString @@ -116,12 +116,20 @@ fun RemindScreen( dateString = link.dateString, onHideBottomSheet = viewModel::hideDetailLinkBottomSheet, show = true, + onClickModifyLink = { + viewModel.hideDetailLinkBottomSheet() + onNavigateToLinkModify(link.id) + }, + onClickRemoveLink = { + viewModel.hideDetailLinkBottomSheet() + viewModel.showLinkRemoveBottomSheet(link) + }, onClickBookmark = viewModel::toggleBookmark ) } if (showTotalEmpty) { - ErrorPokki( + ErrorPooki( modifier = Modifier .fillMaxWidth() .fillMaxHeight() @@ -145,11 +153,11 @@ fun RemindScreen( when (todayContentsState) { NetworkState.IDLE -> { if (todayContents.value.isEmpty()) { - ErrorPokki( + ErrorPooki( modifier = Modifier .fillMaxWidth() .height(208.dp), - pokkiSize = 140.dp, + pookiSize = 140.dp, title = stringResource(id = coreString.title_lack_of_links), sub = stringResource(id = coreString.sub_lack_of_links) ) @@ -184,11 +192,11 @@ fun RemindScreen( ) } NetworkState.ERROR -> { - ErrorPokki( + ErrorPooki( modifier = Modifier .fillMaxWidth() .height(208.dp), - pokkiSize = 140.dp, + pookiSize = 140.dp, title = stringResource(id = coreString.title_error), sub = stringResource(id = coreString.sub_error) ) @@ -232,7 +240,7 @@ fun RemindScreen( when (bookmarkContentState) { NetworkState.IDLE -> { if (bookmarkContents.value.isEmpty()) { - EmptyPokki( + EmptyPooki( modifier = Modifier .fillMaxWidth() .height(252.dp), @@ -271,11 +279,11 @@ fun RemindScreen( ) } NetworkState.ERROR -> { - ErrorPokki( + ErrorPooki( modifier = Modifier .fillMaxWidth() .height(252.dp), - pokkiSize = 140.dp, + pookiSize = 140.dp, title = stringResource(id = coreString.title_empty_favorite), sub = stringResource(id = coreString.sub_empty_favorite) ) diff --git a/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindViewModel.kt b/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindViewModel.kt index b91f1708..88254358 100644 --- a/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindViewModel.kt +++ b/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindViewModel.kt @@ -283,6 +283,13 @@ class RemindViewModel @Inject constructor( } } + fun showLinkRemoveBottomSheet(link: Link) { + _pokitOptionBottomSheetType.update { + BottomSheetType.REMOVE + } + _currentSelectedLink.update { link } + } + fun hideLinkOptionBottomSheet() { _currentSelectedLink.update { null } _pokitOptionBottomSheetType.update { null } diff --git a/feature/login/src/main/java/pokitmons/pokit/success/SignUpSuccessScreen.kt b/feature/login/src/main/java/pokitmons/pokit/success/SignUpSuccessScreen.kt index 99412fce..d1ab77d8 100644 --- a/feature/login/src/main/java/pokitmons/pokit/success/SignUpSuccessScreen.kt +++ b/feature/login/src/main/java/pokitmons/pokit/success/SignUpSuccessScreen.kt @@ -68,8 +68,8 @@ fun SignUpSuccessScreen( Image( modifier = Modifier.height(308.dp), - painter = painterResource(id = coreDrawable.big_pokki), - contentDescription = "big_pokki" + painter = painterResource(id = coreDrawable.big_pooki), + contentDescription = "big_pooki" ) Spacer(modifier = Modifier.height(16.dp)) diff --git a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt index 1dd8c7df..ef9e81dd 100644 --- a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt +++ b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt @@ -41,8 +41,8 @@ import pokitmons.pokit.core.ui.components.block.pokitlist.attributes.PokitListSt import pokitmons.pokit.core.ui.components.template.bottomsheet.PokitBottomSheet import pokitmons.pokit.core.ui.components.template.linkdetailbottomsheet.LinkDetailBottomSheet import pokitmons.pokit.core.ui.components.template.modifybottomsheet.ModifyBottomSheetContent -import pokitmons.pokit.core.ui.components.template.pokkiempty.EmptyPokki -import pokitmons.pokit.core.ui.components.template.pokkierror.ErrorPokki +import pokitmons.pokit.core.ui.components.template.pookiempty.EmptyPooki +import pokitmons.pokit.core.ui.components.template.pookierror.ErrorPooki import pokitmons.pokit.core.ui.components.template.removeItemBottomSheet.TwoButtonBottomSheetContent import pokitmons.pokit.core.ui.theme.PokitTheme import pokitmons.pokit.core.ui.R.string as coreString @@ -77,6 +77,12 @@ fun PokitDetailScreenContainer( hidePokitModifyBottomSheet = viewModel::hidePokitBottomSheet, showLinkModifyBottomSheet = viewModel::showLinkModifyBottomSheet, showLinkRemoveBottomSheet = viewModel::showLinkRemoveBottomSheet, + showLinkRemoveBottomSheetWithLink = remember { + { link -> + viewModel.hideLinkDetailBottomSheet() + viewModel.showLinkRemoveBottomSheet(link) + } + }, hideLinkModifyBottomSheet = viewModel::hideLinkBottomSheet, hideLinkDetailBottomSheet = viewModel::hideLinkDetailBottomSheet, state = state, @@ -110,6 +116,7 @@ fun PokitDetailScreen( hidePokitModifyBottomSheet: () -> Unit = {}, showLinkModifyBottomSheet: (Link) -> Unit = {}, showLinkRemoveBottomSheet: () -> Unit = {}, + showLinkRemoveBottomSheetWithLink: (Link) -> Unit = {}, hideLinkModifyBottomSheet: () -> Unit = {}, hideLinkDetailBottomSheet: () -> Unit = {}, state: PokitDetailScreenState = PokitDetailScreenState(), @@ -130,6 +137,8 @@ fun PokitDetailScreen( Column( modifier = Modifier.fillMaxSize() ) { + Spacer(modifier = Modifier.height(8.dp)) + Toolbar( onBackPressed = onBackPressed, onClickKebab = showPokitModifyBottomSheet @@ -168,7 +177,7 @@ fun PokitDetailScreen( ) } (linkListState == SimplePagingState.FAILURE_INIT) -> { - ErrorPokki( + ErrorPooki( modifier = Modifier .fillMaxWidth() .weight(1f), @@ -177,7 +186,7 @@ fun PokitDetailScreen( ) } (linkList.isEmpty()) -> { - EmptyPokki( + EmptyPooki( modifier = Modifier .fillMaxWidth() .weight(1f), @@ -238,6 +247,14 @@ fun PokitDetailScreen( } context.startActivity(Intent.createChooser(intent, "Pokit")) }, + onClickModifyLink = { + hideLinkDetailBottomSheet() + onClickLinkModify(state.currentLink.id) + }, + onClickRemoveLink = { + hideLinkDetailBottomSheet() + showLinkRemoveBottomSheetWithLink(state.currentLink) + }, onClickBookmark = onClickBookmark ) } @@ -251,7 +268,8 @@ fun PokitDetailScreen( PokitBottomSheet( onHideBottomSheet = hidePokitSelectBottomSheet, - show = state.pokitSelectBottomSheetVisible + show = state.pokitSelectBottomSheetVisible, + skipPartiallyExpanded = false ) { val lazyColumnListState = rememberLazyListState() val startPaging = remember { diff --git a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailViewModel.kt b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailViewModel.kt index 4356fb09..98ed8a19 100644 --- a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailViewModel.kt +++ b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailViewModel.kt @@ -73,12 +73,15 @@ class PokitDetailViewModel @Inject constructor( val moveToBackEvent = _moveToBackEvent.asEventFlow() init { - savedStateHandle.get("pokit_id")?.toIntOrNull()?.let { pokitId -> - linkPaging.changeOptions(categoryId = pokitId, sort = LinksSort.RECENT) + val pokitId = savedStateHandle.get("pokit_id")?.toIntOrNull() + val linkCount = savedStateHandle.get("pokit_count")?.toIntOrNull() ?: 0 + + pokitId?.let { id -> + linkPaging.changeOptions(categoryId = id, sort = LinksSort.RECENT) viewModelScope.launch { linkPaging.refresh() } - getPokit(pokitId) + getPokit(id, linkCount) } initLinkUpdateEventDetector() @@ -135,11 +138,11 @@ class PokitDetailViewModel @Inject constructor( ) } - private fun getPokit(pokitId: Int) { + private fun getPokit(pokitId: Int, linkCount: Int) { viewModelScope.launch { val response = getPokitUseCase.getPokit(pokitId) if (response is PokitResult.Success) { - _state.update { it.copy(currentPokit = Pokit.fromDomainPokit(response.result)) } + _state.update { it.copy(currentPokit = Pokit.fromDomainPokit(response.result).copy(count = linkCount)) } } } } @@ -186,6 +189,10 @@ class PokitDetailViewModel @Inject constructor( _state.update { it.copy(linkBottomSheetType = BottomSheetType.REMOVE) } } + fun showLinkRemoveBottomSheet(link: Link) { + _state.update { it.copy(linkBottomSheetType = BottomSheetType.REMOVE, currentLink = link) } + } + fun hideLinkBottomSheet() { _state.update { it.copy(linkBottomSheetType = null, currentLink = null) } } diff --git a/feature/search/src/main/java/pokitmons/pokit/search/SearchScreen.kt b/feature/search/src/main/java/pokitmons/pokit/search/SearchScreen.kt index e084ec67..0f6de2c0 100644 --- a/feature/search/src/main/java/pokitmons/pokit/search/SearchScreen.kt +++ b/feature/search/src/main/java/pokitmons/pokit/search/SearchScreen.kt @@ -20,8 +20,8 @@ import pokitmons.pokit.core.ui.components.atom.loading.LoadingProgress import pokitmons.pokit.core.ui.components.template.bottomsheet.PokitBottomSheet import pokitmons.pokit.core.ui.components.template.linkdetailbottomsheet.LinkDetailBottomSheet import pokitmons.pokit.core.ui.components.template.modifybottomsheet.ModifyBottomSheetContent -import pokitmons.pokit.core.ui.components.template.pokkiempty.EmptyPokki -import pokitmons.pokit.core.ui.components.template.pokkierror.ErrorPokki +import pokitmons.pokit.core.ui.components.template.pookiempty.EmptyPooki +import pokitmons.pokit.core.ui.components.template.pookierror.ErrorPooki import pokitmons.pokit.core.ui.components.template.removeItemBottomSheet.TwoButtonBottomSheetContent import pokitmons.pokit.core.ui.theme.PokitTheme import pokitmons.pokit.search.components.filter.FilterArea @@ -53,7 +53,7 @@ fun SearchScreenContainer( val context: Context = LocalContext.current - state.currentLink?.let { link -> + state.currentDetailLink?.let { link -> LinkDetailBottomSheet( title = link.title, memo = link.memo, @@ -68,7 +68,7 @@ fun SearchScreenContainer( onClickShareLink = { val intent = Intent(Intent.ACTION_SEND_MULTIPLE).apply { type = "text/plain" - putExtra(Intent.EXTRA_TEXT, state.currentLink?.url) + putExtra(Intent.EXTRA_TEXT, state.currentDetailLink?.url) } context.startActivity(Intent.createChooser(intent, "Pokit")) }, @@ -103,7 +103,7 @@ fun SearchScreenContainer( ModifyBottomSheetContent( onClickModify = remember { { - state.currentLink?.let { link -> + state.currentTargetLink?.let { link -> viewModel.hideLinkModifyBottomSheet() onNavigateToLinkModify(link.id) } @@ -111,7 +111,7 @@ fun SearchScreenContainer( }, onClickRemove = remember { { - state.currentLink?.let { link -> + state.currentTargetLink?.let { link -> viewModel.showLinkRemoveBottomSheet(link) } } @@ -120,7 +120,7 @@ fun SearchScreenContainer( { val intent = Intent(Intent.ACTION_SEND_MULTIPLE).apply { type = "text/plain" - putExtra(Intent.EXTRA_TEXT, state.currentLink?.url) + putExtra(Intent.EXTRA_TEXT, state.currentTargetLink?.url) } context.startActivity(Intent.createChooser(intent, "Pokit")) } @@ -231,7 +231,7 @@ fun SearchScreen( ) } (linkPagingState == SimplePagingState.FAILURE_INIT) -> { - ErrorPokki( + ErrorPooki( modifier = Modifier .fillMaxWidth() .weight(1f), @@ -241,7 +241,7 @@ fun SearchScreen( ) } (linkList.isEmpty()) -> { - EmptyPokki( + EmptyPooki( modifier = Modifier .fillMaxWidth() .weight(1f), diff --git a/feature/search/src/main/java/pokitmons/pokit/search/SearchViewModel.kt b/feature/search/src/main/java/pokitmons/pokit/search/SearchViewModel.kt index d3213924..fc205e8a 100644 --- a/feature/search/src/main/java/pokitmons/pokit/search/SearchViewModel.kt +++ b/feature/search/src/main/java/pokitmons/pokit/search/SearchViewModel.kt @@ -15,6 +15,7 @@ import kotlinx.coroutines.launch import pokitmons.pokit.core.feature.navigation.args.LinkUpdateEvent import pokitmons.pokit.domain.commom.PokitResult import pokitmons.pokit.domain.usecase.link.DeleteLinkUseCase +import pokitmons.pokit.domain.usecase.link.GetLinkUseCase import pokitmons.pokit.domain.usecase.link.SearchLinksUseCase import pokitmons.pokit.domain.usecase.link.SetBookmarkUseCase import pokitmons.pokit.domain.usecase.pokit.GetPokitsUseCase @@ -41,6 +42,7 @@ class SearchViewModel @Inject constructor( getPokitsUseCase: GetPokitsUseCase, getRecentSearchWordsUseCase: GetRecentSearchWordsUseCase, getUseRecentSearchWordsUseCase: GetUseRecentSearchWordsUseCase, + private val getLinkUseCase: GetLinkUseCase, private val deleteLinkUseCase: DeleteLinkUseCase, private val setUseRecentSearchWordsUseCase: SetUseRecentSearchWordsUseCase, private val addRecentSearchWordUseCase: AddRecentSearchWordUseCase, @@ -201,7 +203,7 @@ class SearchViewModel @Inject constructor( _state.update { state -> state.copy( linkBottomSheetType = BottomSheetType.MODIFY, - currentLink = link + currentTargetLink = link ) } } @@ -211,7 +213,7 @@ class SearchViewModel @Inject constructor( state.copy( linkBottomSheetType = BottomSheetType.REMOVE, showLinkDetailBottomSheet = false, - currentLink = link + currentTargetLink = link ) } } @@ -220,7 +222,7 @@ class SearchViewModel @Inject constructor( _state.update { state -> state.copy( linkBottomSheetType = null, - currentLink = null + currentTargetLink = null ) } } @@ -228,17 +230,30 @@ class SearchViewModel @Inject constructor( fun showLinkDetailBottomSheet(link: Link) { _state.update { state -> state.copy( - currentLink = link, + currentDetailLink = link, showLinkDetailBottomSheet = true, linkBottomSheetType = null ) } + + viewModelScope.launch { + val response = getLinkUseCase.getLink(link.id.toInt()) + if (response is PokitResult.Success && state.value.currentDetailLink?.id == link.id && state.value.showLinkDetailBottomSheet) { + _state.update { it.copy(currentDetailLink = Link.fromDomainLink(response.result).copy(imageUrl = link.imageUrl, isRead = true)) } + } + + val isReadChangedLink = linkPaging.pagingData.value + .find { it.id == link.id } + ?.copy(isRead = true) ?: return@launch + + linkPaging.modifyItem(isReadChangedLink) + } } fun hideLinkDetailBottomSheet() { _state.update { state -> state.copy( - currentLink = null, + currentDetailLink = null, showLinkDetailBottomSheet = false ) } @@ -292,7 +307,7 @@ class SearchViewModel @Inject constructor( } fun toggleBookmark() { - val currentLink = state.value.currentLink ?: return + val currentLink = state.value.currentTargetLink ?: return val currentLinkId = currentLink.id.toIntOrNull() ?: return val applyBookmarked = !currentLink.bookmark @@ -302,7 +317,7 @@ class SearchViewModel @Inject constructor( val bookmarkChangedLink = currentLink.copy(bookmark = applyBookmarked) _state.update { state -> state.copy( - currentLink = bookmarkChangedLink + currentDetailLink = bookmarkChangedLink ) } linkPaging.modifyItem(bookmarkChangedLink) @@ -311,7 +326,7 @@ class SearchViewModel @Inject constructor( } fun deleteLink() { - val currentLinkId = state.value.currentLink?.id?.toIntOrNull() ?: return + val currentLinkId = state.value.currentTargetLink?.id?.toIntOrNull() ?: return viewModelScope.launch { val response = deleteLinkUseCase.deleteLink(currentLinkId) if (response is PokitResult.Success) { diff --git a/feature/search/src/main/java/pokitmons/pokit/search/model/SearchScreenState.kt b/feature/search/src/main/java/pokitmons/pokit/search/model/SearchScreenState.kt index b7c33ebe..898a5d19 100644 --- a/feature/search/src/main/java/pokitmons/pokit/search/model/SearchScreenState.kt +++ b/feature/search/src/main/java/pokitmons/pokit/search/model/SearchScreenState.kt @@ -10,7 +10,8 @@ data class SearchScreenState( val showLinkDetailBottomSheet: Boolean = false, val linkBottomSheetType: BottomSheetType? = null, val sortRecent: Boolean = true, - val currentLink: Link? = null, + val currentTargetLink: Link? = null, + val currentDetailLink: Link? = null, ) enum class SearchScreenStep { diff --git a/feature/settings/src/main/java/pokitmons/pokit/settings/nickname/EditNicknameScreen.kt b/feature/settings/src/main/java/pokitmons/pokit/settings/nickname/EditNicknameScreen.kt index 66050beb..ddbf82f4 100644 --- a/feature/settings/src/main/java/pokitmons/pokit/settings/nickname/EditNicknameScreen.kt +++ b/feature/settings/src/main/java/pokitmons/pokit/settings/nickname/EditNicknameScreen.kt @@ -3,8 +3,10 @@ package pokitmons.pokit.settings.nickname import android.widget.Toast import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.imePadding import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable @@ -41,10 +43,11 @@ fun EditNicknameScreen( Box( modifier = Modifier - .padding(start = 20.dp, end = 20.dp, top = 20.dp, bottom = 28.dp) + .padding(start = 20.dp, end = 20.dp, bottom = 28.dp) .fillMaxSize() ) { Column { + Spacer(modifier = Modifier.height(8.dp)) NicknameHeader(onBackPressed) LabeledInput( modifier = Modifier diff --git a/feature/settings/src/main/java/pokitmons/pokit/settings/setting/SettingsScreen.kt b/feature/settings/src/main/java/pokitmons/pokit/settings/setting/SettingsScreen.kt index 74f30ece..b6cbdeb7 100644 --- a/feature/settings/src/main/java/pokitmons/pokit/settings/setting/SettingsScreen.kt +++ b/feature/settings/src/main/java/pokitmons/pokit/settings/setting/SettingsScreen.kt @@ -39,6 +39,7 @@ fun SettingsScreen( } Column(modifier = Modifier.fillMaxWidth()) { + Spacer(modifier = Modifier.height(8.dp)) SettingHeader(onBackPressed) Spacer(modifier = Modifier.height(16.dp)) Column(modifier = Modifier.fillMaxWidth()) {