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

[Fix]#69 1차 배포 전 QA 사항 반영 #70

Merged
merged 13 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit Hold shift + click to select a range
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
11 changes: 9 additions & 2 deletions app/src/main/java/pokitmons/pokit/navigation/RootDestination.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/pokitmons/pokit/navigation/RootNavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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") },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -65,6 +66,7 @@ fun PokitBottomSheet(
visibility = false
}
},
shape = RectangleShape,
sheetState = bottomSheetState,
scrimColor = Color.Transparent,
containerColor = Color.Transparent,
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package pokitmons.pokit.core.ui.components.template.pokki

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.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 Pokki(
Copy link
Member

Choose a reason for hiding this comment

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

포끼? 요거 우리 포킷 이미지 설정하는 그 캐릭터인가? 맞다면 푸키야!!!!!!

modifier: Modifier = Modifier,
title: String,
sub: String,
) {
Box(
modifier = modifier,
contentAlignment = Alignment.Center
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally
) {
Image(
modifier = Modifier
.height(180.dp)
.width(180.dp),
Copy link
Member

Choose a reason for hiding this comment

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

height, width 같다면 size로 설정 가능하지 않나여? 아닐 수도 있음ㅋ

Copy link
Contributor Author

Choose a reason for hiding this comment

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

완전 가능! 반영 완

painter = painterResource(id = R.drawable.pokki),
contentDescription = "pokki"
)

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))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package pokitmons.pokit.core.ui.components.template.pokki

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()) {
Pokki(title = "저장된 포킷이 없어요!", sub = "포킷을 생성해 링크를 저장해보세요")
}
}
}
Binary file added core/ui/src/main/res/drawable-hdpi/pokki.png
Copy link
Member

Choose a reason for hiding this comment

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

ㅋㅋㅋㅋ 아놔 요거 맞았네 푸키입니다!!!!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

헐 왜 저렇게 적었지
이미지/UI 명 변경 완!

Copy link

Choose a reason for hiding this comment

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

머임 떡포끼임??ㅋㅋ

Copy link
Member

Choose a reason for hiding this comment

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

ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ 군침 싹 ~ ㅋ

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/ui/src/main/res/drawable-mdpi/pokki.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/ui/src/main/res/drawable-xhdpi/pokki.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/ui/src/main/res/drawable-xxhdpi/pokki.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/ui/src/main/res/drawable-xxxhdpi/pokki.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions core/ui/src/main/res/values/string.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@

<string name="title_empty_search">검색된 링크가 없어요</string>
<string name="sub_empty_search">검색어를 다시 확인해주세요</string>

<string name="title_empty_alarms">아직 알람이 없어요</string>
<string name="sub_empty_alarms">리마인드 알림을 설정하세요</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class AddPokitViewModel @Inject constructor(
private val _pokitIamges = MutableStateFlow<List<PokitImage>>(emptyList())
val pokitImages: StateFlow<List<PokitImage>> = _pokitIamges.asStateFlow()

private var existingPokitName: String? = null

init {
initPokitList()
loadPokitImages()
Expand Down Expand Up @@ -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)
}
Expand All @@ -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
Expand Down
68 changes: 52 additions & 16 deletions feature/alarm/src/main/java/pokitmons/pokit/alarm/AlarmScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.pokki.Pokki
import pokitmons.pokit.core.ui.components.template.pokkierror.ErrorPokki
import pokitmons.pokit.core.ui.R.string as coreString

@Composable
fun AlarmScreenContainer(
Expand All @@ -40,7 +44,8 @@ fun AlarmScreenContainer(
onClickAlarmRemove = viewModel::removeAlarm,
alarms = alarms,
alarmsState = alarmsState,
loadNextAlarms = viewModel::loadNextAlarms
loadNextAlarms = viewModel::loadNextAlarms,
refreshAlarms = viewModel::refreshAlarms
)
}

Expand All @@ -53,6 +58,7 @@ fun AlarmScreen(
alarms: List<Alarm> = emptyList(),
alarmsState: SimplePagingState = SimplePagingState.IDLE,
loadNextAlarms: () -> Unit = {},
refreshAlarms: () -> Unit = {},
) {
Column(
modifier = Modifier.fillMaxSize()
Expand All @@ -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 -> {
ErrorPokki(
modifier = Modifier
.fillMaxWidth()
.weight(1f),
title = stringResource(id = coreString.title_error),
sub = stringResource(id = coreString.sub_error),
onClickRetry = refreshAlarms
)
}
alarms.isEmpty() -> {
Pokki(
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
)
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<HomeSideEffect>()
Expand All @@ -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)
}
}
}
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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() {
Expand Down
Loading
Loading