Skip to content

Commit d7ea0ba

Browse files
authored
Merge pull request #22 from KanuKim97/modify/home-ui
[MODIFY] Modified Home Ui
2 parents 677e7c8 + 4bd8517 commit d7ea0ba

File tree

8 files changed

+76
-102
lines changed

8 files changed

+76
-102
lines changed

app/src/main/AndroidManifest.xml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
<application
1010
android:name=".WhatsEatApplication"
1111
android:enableOnBackInvokedCallback="true"
12-
android:allowBackup="false"
1312
android:label="@string/app_name"
1413
android:largeHeap="true"
1514
android:icon="@mipmap/ic_launcher"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.example.home
2+
3+
class HomeUiTest {
4+
}

feature/home/src/androidTest/java/com/example/home/HomeViewModelInstrumentTest.kt

-39
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.example.home
2+
3+
import androidx.test.ext.junit.runners.AndroidJUnit4
4+
import org.junit.runner.RunWith
5+
6+
/**
7+
* Instrumented test, which will execute on an Android device.
8+
*
9+
* See [testing documentation](http://d.android.com/tools/testing).
10+
*/
11+
@RunWith(AndroidJUnit4::class)
12+
class HomeViewModelTest {
13+
// val mainBannerUseCaseMock = mockk<GetMainBannerUseCase>()
14+
// val gridItemUseCaseMock = mockk<GetGridItemUseCase>()
15+
//
16+
// private lateinit var homeViewModelMock: HomeViewModel
17+
//
18+
// @Before
19+
// fun initMock() {
20+
// every { mainBannerUseCaseMock("0.0, 0.0") } returns flowOf(listOf())
21+
// every { gridItemUseCaseMock("0.0, 0.0") } returns flowOf(listOf())
22+
//
23+
// homeViewModelMock = HomeViewModel(mainBannerUseCaseMock, gridItemUseCaseMock)
24+
// }
25+
//
26+
// @After
27+
// fun clearMock() {
28+
// clearMocks(mainBannerUseCaseMock, gridItemUseCaseMock)
29+
// }
30+
}

feature/home/src/main/java/com/example/home/component/HomeBanner.kt

+22-17
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.example.home.component
22

33
import androidx.compose.foundation.ExperimentalFoundationApi
4-
import androidx.compose.foundation.background
54
import androidx.compose.foundation.layout.Arrangement
65
import androidx.compose.foundation.layout.Box
76
import androidx.compose.foundation.layout.Column
@@ -14,12 +13,9 @@ import androidx.compose.material3.Text
1413
import androidx.compose.runtime.Composable
1514
import androidx.compose.ui.Alignment
1615
import androidx.compose.ui.Modifier
17-
import androidx.compose.ui.draw.clip
1816
import androidx.compose.ui.unit.dp
1917
import com.example.designsystem.component.EatCircularProgressIndicator
2018
import com.example.designsystem.component.EatHorizontalPager
21-
import com.example.designsystem.theme.EatShape
22-
import com.example.designsystem.theme.Gray
2319
import com.example.designsystem.theme.EatTypography
2420
import com.example.home.BannerUiState
2521
import com.example.ui.BannerCard
@@ -43,24 +39,33 @@ fun HomeBanner(
4339
is BannerUiState.Init -> { }
4440
is BannerUiState.IsLoading -> { EatCircularProgressIndicator() }
4541
is BannerUiState.IsSuccess -> {
46-
val pagerState = rememberPagerState { bannerUiState.banner?.lastIndex ?: 0 }
42+
if (bannerUiState.banner.isNullOrEmpty()) {
43+
Box(
44+
modifier = modifier.fillMaxSize(),
45+
contentAlignment = Alignment.Center
46+
) {
47+
Text(
48+
text = "주변에 음식점이 없습니다!",
49+
style = EatTypography.bodyMedium
50+
)
51+
}
52+
} else {
53+
val pagerState = rememberPagerState { bannerUiState.banner.lastIndex }
4754

48-
EatHorizontalPager(
49-
pagerState = pagerState,
50-
modifier = modifier.fillMaxSize()
51-
) { index ->
52-
BannerCard(
53-
banner = bannerUiState.banner?.get(index),
54-
bannerOnClick = { bannerOnClick(bannerUiState.banner?.get(index)?.placeID ?: "") }
55-
)
55+
EatHorizontalPager(
56+
pagerState = pagerState,
57+
modifier = modifier.fillMaxSize()
58+
) { index ->
59+
BannerCard(
60+
banner = bannerUiState.banner[index],
61+
bannerOnClick = { bannerOnClick(bannerUiState.banner[index].placeID) }
62+
)
63+
}
5664
}
5765
}
5866
is BannerUiState.IsFailed -> {
5967
Box(
60-
modifier = modifier
61-
.fillMaxSize()
62-
.clip(shape = EatShape.large)
63-
.background(Gray),
68+
modifier = modifier.fillMaxSize(),
6469
contentAlignment = Alignment.Center,
6570
content = {
6671
Text(

feature/home/src/main/java/com/example/home/component/HomeItemGrid.kt

+20-23
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.example.home.component
22

3-
import androidx.compose.foundation.background
43
import androidx.compose.foundation.layout.Arrangement
54
import androidx.compose.foundation.layout.Box
65
import androidx.compose.foundation.layout.Column
@@ -10,11 +9,8 @@ import androidx.compose.material3.Text
109
import androidx.compose.runtime.Composable
1110
import androidx.compose.ui.Alignment
1211
import androidx.compose.ui.Modifier
13-
import androidx.compose.ui.draw.clip
1412
import com.example.designsystem.component.EatCircularProgressIndicator
1513
import com.example.designsystem.component.EatVerticalGrid
16-
import com.example.designsystem.theme.EatShape
17-
import com.example.designsystem.theme.Gray
1814
import com.example.designsystem.theme.EatTypography
1915
import com.example.home.ItemGridUiState
2016
import com.example.ui.GridItem
@@ -31,32 +27,33 @@ fun HomeItemGrid(
3127
horizontalAlignment = Alignment.CenterHorizontally
3228
) {
3329
when (itemGridUiState) {
34-
is ItemGridUiState.Init -> { }
30+
is ItemGridUiState.Init -> {}
3531
is ItemGridUiState.IsLoading -> { EatCircularProgressIndicator() }
3632
is ItemGridUiState.IsSuccess -> {
37-
EatVerticalGrid(
38-
modifier = modifier.fillMaxSize(),
39-
content = {
40-
itemGridUiState.item?.let { itemList ->
41-
items(
42-
items = itemList,
43-
itemContent = { item ->
44-
GridItem(
45-
gridItems = item,
46-
itemOnClick = itemOnClick
47-
)
48-
}
49-
)
33+
if (itemGridUiState.item.isNullOrEmpty()) {
34+
Box(
35+
modifier = modifier.fillMaxSize(),
36+
contentAlignment = Alignment.Center
37+
) {
38+
Text(
39+
text = "주변에 음식점이 없습니다!",
40+
style = EatTypography.bodyMedium
41+
)
42+
}
43+
} else {
44+
EatVerticalGrid(modifier = modifier.fillMaxSize()) {
45+
items(
46+
items = itemGridUiState.item,
47+
key = { item -> item.placeID }
48+
) { item ->
49+
GridItem(gridItems = item, itemOnClick = itemOnClick)
5050
}
5151
}
52-
)
52+
}
5353
}
5454
is ItemGridUiState.IsFailed -> {
5555
Box(
56-
modifier = modifier
57-
.fillMaxSize()
58-
.clip(shape = EatShape.large)
59-
.background(Gray),
56+
modifier = modifier.fillMaxSize(),
6057
contentAlignment = Alignment.Center,
6158
content = {
6259
Text(

feature/home/src/test/java/com/example/home/ExampleUnitTest.kt

-17
This file was deleted.

feature/home/src/test/java/com/example/home/ui/HomeViewModelTest.kt

-5
This file was deleted.

0 commit comments

Comments
 (0)