Skip to content

Commit 521f0af

Browse files
committed
[NDGL-124] feat: CommonErrorView 추가
1 parent 685d988 commit 521f0af

4 files changed

Lines changed: 72 additions & 46 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package com.yapp.ndgl.core.ui
2+
3+
import androidx.compose.foundation.Image
4+
import androidx.compose.foundation.layout.Arrangement
5+
import androidx.compose.foundation.layout.Column
6+
import androidx.compose.foundation.layout.fillMaxWidth
7+
import androidx.compose.foundation.layout.padding
8+
import androidx.compose.foundation.layout.size
9+
import androidx.compose.material3.Text
10+
import androidx.compose.runtime.Composable
11+
import androidx.compose.ui.Alignment
12+
import androidx.compose.ui.Modifier
13+
import androidx.compose.ui.res.painterResource
14+
import androidx.compose.ui.res.stringResource
15+
import androidx.compose.ui.text.style.TextAlign
16+
import androidx.compose.ui.tooling.preview.Preview
17+
import androidx.compose.ui.unit.dp
18+
import com.yapp.ndgl.core.ui.theme.NDGLTheme
19+
20+
@Composable
21+
fun CommonErrorView(
22+
modifier: Modifier = Modifier,
23+
title: String? = null,
24+
description: String? = null,
25+
) {
26+
Column(
27+
modifier = modifier
28+
.fillMaxWidth()
29+
.padding(horizontal = 24.dp, vertical = 165.dp),
30+
verticalArrangement = Arrangement.spacedBy(16.dp),
31+
horizontalAlignment = Alignment.CenterHorizontally,
32+
) {
33+
Image(
34+
painter = painterResource(R.drawable.img_empty_browser),
35+
contentDescription = null,
36+
modifier = Modifier.size(100.dp),
37+
)
38+
Column(
39+
modifier = Modifier.fillMaxWidth(),
40+
verticalArrangement = Arrangement.spacedBy(4.dp),
41+
horizontalAlignment = Alignment.CenterHorizontally,
42+
) {
43+
Text(
44+
text = title ?: stringResource(R.string.common_error_title),
45+
color = NDGLTheme.colors.black500,
46+
textAlign = TextAlign.Center,
47+
style = NDGLTheme.typography.subtitleMdSemiBold,
48+
)
49+
Text(
50+
text = description ?: stringResource(R.string.common_error_description),
51+
color = NDGLTheme.colors.black400,
52+
textAlign = TextAlign.Center,
53+
style = NDGLTheme.typography.bodyLgRegular,
54+
)
55+
}
56+
}
57+
}
58+
59+
@Preview(showBackground = true)
60+
@Composable
61+
private fun CommonErrorViewPreview() {
62+
NDGLTheme {
63+
CommonErrorView(
64+
modifier = Modifier
65+
)
66+
}
67+
}

core/ui/src/main/res/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
<string name="common_dot_separator">•</string>
1616
<string name="common_retry">다시 시도</string>
1717
<string name="common_all">전체</string>
18+
<string name="common_err_unknown">알 수 없는 오류입니다</string>
19+
<string name="common_error_title">정보를 불러올 수 없어요</string>
20+
<string name="common_error_description">인터넷 연결 확인 후 다시 시도해 주세요</string>
1821

1922
<!-- User Guide Modal -->
2023
<string name="user_guide_modal_title">서비스 이용 전\n반드시 확인해주세요.</string>

feature/home/src/main/java/com/yapp/ndgl/feature/home/search/TemplateSearchScreen.kt

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import androidx.compose.ui.text.style.TextAlign
2424
import androidx.compose.ui.tooling.preview.Preview
2525
import androidx.compose.ui.unit.dp
2626
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
27+
import com.yapp.ndgl.core.ui.CommonErrorView
2728
import com.yapp.ndgl.core.ui.designsystem.NDGLCTAButton
2829
import com.yapp.ndgl.core.ui.designsystem.NDGLCTAButtonAttr
2930
import com.yapp.ndgl.core.ui.designsystem.NDGLSearchNavigationBar
@@ -118,7 +119,7 @@ private fun TemplateSearchScreen(
118119
)
119120
}
120121

121-
TemplateSearchState.SearchResult.Error -> item { ErrorView() }
122+
TemplateSearchState.SearchResult.Error -> item { CommonErrorView() }
122123
}
123124
}
124125

@@ -208,41 +209,6 @@ private fun EmptyResultView() {
208209
}
209210
}
210211

211-
@Composable
212-
private fun ErrorView() {
213-
Column(
214-
modifier = Modifier
215-
.fillMaxWidth()
216-
.padding(horizontal = 24.dp, vertical = 165.dp),
217-
verticalArrangement = Arrangement.spacedBy(16.dp),
218-
horizontalAlignment = Alignment.CenterHorizontally,
219-
) {
220-
Image(
221-
painter = painterResource(CoreR.drawable.img_empty_browser),
222-
contentDescription = null,
223-
modifier = Modifier.size(100.dp),
224-
)
225-
Column(
226-
modifier = Modifier.fillMaxWidth(),
227-
verticalArrangement = Arrangement.spacedBy(4.dp),
228-
horizontalAlignment = Alignment.CenterHorizontally,
229-
) {
230-
Text(
231-
text = stringResource(R.string.home_template_search_error_title),
232-
color = NDGLTheme.colors.black500,
233-
textAlign = TextAlign.Center,
234-
style = NDGLTheme.typography.subtitleMdSemiBold,
235-
)
236-
Text(
237-
text = stringResource(R.string.home_template_search_error_description),
238-
color = NDGLTheme.colors.black400,
239-
textAlign = TextAlign.Center,
240-
style = NDGLTheme.typography.bodyLgRegular,
241-
)
242-
}
243-
}
244-
}
245-
246212
@Preview(showBackground = true)
247213
@Composable
248214
private fun InitialEmptyViewPreview() {
@@ -259,14 +225,6 @@ private fun EmptyResultViewPreview() {
259225
}
260226
}
261227

262-
@Preview(showBackground = true)
263-
@Composable
264-
private fun ErrorViewPreview() {
265-
NDGLTheme {
266-
ErrorView()
267-
}
268-
}
269-
270228
@Preview(showBackground = true)
271229
@Composable
272230
private fun TemplateSearchScreenFilledPreview() {

feature/home/src/main/res/values/strings.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
<string name="home_template_search_idle_description">좋아하는 유튜버나 가고 싶은\n여행지를 검색할 수 있어요</string>
2727
<string name="home_template_search_empty_title">검색 결과가 없어요</string>
2828
<string name="home_template_search_empty_description">철자를 확인하거나\n다른 키워드로 검색해보세요.</string>
29-
<string name="home_template_search_error_title">정보를 불러올 수 없어요</string>
30-
<string name="home_template_search_error_description">인터넷 연결 확인 후 다시 시도해 주세요</string>
3129

3230
<!-- Settings -->
3331
<string name="home_settings_title">설정</string>

0 commit comments

Comments
 (0)