Skip to content

Commit

Permalink
[FEATURE] #79 홈 화면(포킷/미분류)에서 데이터가 없을 때 포킷 추가하기, 링크 추가하기 버튼 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
l5x5l committed Oct 30, 2024
1 parent 85b8a10 commit fa0369b
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package pokitmons.pokit.core.ui.components.template.pookiempty

import androidx.compose.foundation.Image
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
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.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import pokitmons.pokit.core.ui.R
Expand All @@ -20,6 +25,7 @@ fun EmptyPooki(
modifier: Modifier = Modifier,
title: String,
sub: String,
button: EmptyPookiButton? = null
) {
Box(
modifier = modifier,
Expand All @@ -42,6 +48,25 @@ fun EmptyPooki(
Spacer(modifier = Modifier.height(8.dp))

Text(text = sub, style = PokitTheme.typography.body2Medium.copy(color = PokitTheme.colors.textSecondary))

button?.let { buttonInfo ->
Spacer(modifier = Modifier.height(20.dp))

Text(
modifier = Modifier.clip(shape = RoundedCornerShape(8.dp))
.clickable { buttonInfo.onClick() }
.border(
shape = RoundedCornerShape(8.dp),
width = 1.dp,
color = PokitTheme.colors.borderSecondary
)
.padding(vertical = 10.dp, horizontal = 16.dp),
text = buttonInfo.text,
style = PokitTheme.typography.label2Regular.copy(color = PokitTheme.colors.textPrimary)
)
}
}
}
}

data class EmptyPookiButton(val text: String, val onClick: () -> Unit)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import pokitmons.pokit.core.ui.theme.PokitTheme
private fun Preview() {
PokitTheme {
Surface(modifier = Modifier.fillMaxSize()) {
EmptyPooki(title = "저장된 포킷이 없어요!", sub = "포킷을 생성해 링크를 저장해보세요")
EmptyPooki(
title = "저장된 포킷이 없어요!",
sub = "포킷을 생성해 링크를 저장해보세요",
button = EmptyPookiButton("포킷 추가하기", {})
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ fun HomeScreen(
modifier = Modifier.padding(padding),
onNavigateToPokitDetail = onNavigateToPokitDetail,
onNavigateToLinkModify = onNavigateToLinkModify,
onNavigateToPokitModify = onNavigateToPokitModify
onNavigateToPokitModify = onNavigateToPokitModify,
onNavigateToAddLink = { onNavigateAddLink(null) },
onNavigateToAddPokit = onNavigateAddPokit
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ 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.pookiempty.EmptyPooki
import pokitmons.pokit.core.ui.components.template.pookiempty.EmptyPookiButton
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
import pokitmons.pokit.home.R.string as stringResource

@Composable
fun PokitScreen(
Expand All @@ -40,6 +42,8 @@ fun PokitScreen(
onNavigateToPokitDetail: (String, Int) -> Unit,
onNavigateToLinkModify: (String) -> Unit,
onNavigateToPokitModify: (String) -> Unit,
onNavigateToAddLink: () -> Unit,
onNavigateToAddPokit: () -> Unit,
) {
val pokits = viewModel.pokits.collectAsState()
val pokitsState by viewModel.pokitsState.collectAsState()
Expand Down Expand Up @@ -112,7 +116,11 @@ fun PokitScreen(
EmptyPooki(
modifier = Modifier.fillMaxSize(),
title = stringResource(id = coreString.title_empty_pokits),
sub = stringResource(id = coreString.sub_empty_pokits)
sub = stringResource(id = coreString.sub_empty_pokits),
button = EmptyPookiButton(
text = stringResource(id = stringResource.title_add_pokit),
onClick = onNavigateToAddPokit
)
)
}
else -> {
Expand Down Expand Up @@ -159,7 +167,11 @@ fun PokitScreen(
EmptyPooki(
modifier = Modifier.fillMaxSize(),
title = stringResource(id = coreString.title_empty_links),
sub = stringResource(id = coreString.sub_empty_links)
sub = stringResource(id = coreString.sub_empty_links),
button = EmptyPookiButton(
text = stringResource(id = stringResource.title_add_link),
onClick = onNavigateToAddLink
)
)
}
else -> {
Expand Down
3 changes: 3 additions & 0 deletions feature/home/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@

<string name="toast_cannot_create_pokit">최대 30개의 포킷을 생성할 수 있습니다.\n포킷을 삭제한 뒤에 추가해주세요.</string>
<string name="toast_add_copied_link">복사한 링크 저장하기\n%s</string>

<string name="title_add_pokit">포킷 추가하기</string>
<string name="title_add_link">링크 추가하기</string>
</resources>

0 comments on commit fa0369b

Please sign in to comment.