Skip to content

Commit

Permalink
Merge pull request #41 from everymeals/fix/select_screen
Browse files Browse the repository at this point in the history
[fix/select_screen] 학교 선택화면 뷰 수정
  • Loading branch information
SsongSik authored Aug 14, 2023
2 parents 3cf1ade + 9e1d06f commit 61d9f2e
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ import com.everymeal.presentation.ui.theme.EveryMeal_AndroidTheme
import com.everymeal.presentation.ui.theme.Gray100
import com.everymeal.presentation.ui.theme.Gray300
import com.everymeal.presentation.ui.theme.Gray500
import com.everymeal.presentation.ui.theme.Gray600
import com.everymeal.presentation.ui.theme.Gray800
import com.everymeal.presentation.ui.theme.Paddings

data class Item(
val Image: Int,
val name: String,
val univName: String,
val campusName: String? = null
)

@Composable
Expand All @@ -60,10 +61,12 @@ fun UnivSelectScreen(
val viewState by viewModel.viewState.collectAsState()

val items = listOf(
Item(Image = R.drawable.image_myongji, name = "명지대"),
Item(Image = R.drawable.image_sungsin, name = "성신여대"),
Item(Image = R.drawable.image_seoulwoman, name = "서울여대"),
Item(Image = R.drawable.image_konkuk, name = "건국대"),
Item(univName = "명지대", campusName = "자연캠퍼스"),
Item(univName = "명지대", campusName = "인문캠퍼스"),
Item(univName = "성신여대", campusName = "수정캠퍼스"),
Item(univName = "성신여대", campusName = "운정캠퍼스"),
Item(univName = "서울여대"),
Item(univName = "연세대학교", campusName = "서울캠퍼스"),
)

Box(
Expand All @@ -76,7 +79,13 @@ fun UnivSelectScreen(
.fillMaxSize()
.padding(horizontal = Paddings.extra)
) {
Spacer(modifier = Modifier.padding(58.dp))
Spacer(modifier = Modifier.padding(40.dp))
Image(
painter = painterResource(id = R.drawable.icon_school),
contentDescription = stringResource(R.string.icon_univ),
modifier = Modifier.size(64.dp)
)
Spacer(modifier = Modifier.padding(10.dp))
Text(
text = stringResource(R.string.univ_select_title),
style = TextStyle(
Expand All @@ -86,17 +95,20 @@ fun UnivSelectScreen(
)
Spacer(modifier = Modifier.padding(10.dp))
LazyVerticalGrid(
columns = GridCells.Fixed(3),
columns = GridCells.Fixed(2),
modifier = Modifier.weight(1f),
) {
items(items.size) { index ->
val item = items[index]
val isSelected = viewState.selectedUniv == item.name
val isSelected = viewState.selectedUniv == "${item.univName}+${item.campusName}"
UnivSelectItem(
item = item,
isSelected = isSelected,
index = index
) {
viewModel.setEvent(UnivSelectContract.UnivSelectEvent.SelectedUniv(item.name))
viewModel.setEvent(UnivSelectContract.UnivSelectEvent.SelectedUniv(
"${item.univName}+${item.campusName}")
)
}
}
}
Expand Down Expand Up @@ -154,31 +166,37 @@ fun UnivSelectScreen(

@SuppressLint("RememberReturnType")
@Composable
fun UnivSelectItem(item: Item, isSelected: Boolean, onSelectClick: (Item) -> Unit) {
fun UnivSelectItem(item: Item, isSelected: Boolean, index: Int, onSelectClick: (Item) -> Unit) {
Column(
modifier = Modifier
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() }
) { onSelectClick(item) }
.padding(Paddings.medium)
.padding(bottom = Paddings.medium, end = if(index%2==0) Paddings.medium else 0.dp)
.clip(RoundedCornerShape(Paddings.medium))
.background(if (isSelected) Gray500 else Gray100)
.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
Spacer(modifier = Modifier.padding(bottom = 10.dp))
Image(
painter = painterResource(item.Image),
contentDescription = item.name,
Modifier.size(36.dp)
)
val spacerSize = if (item.campusName == null) 17.dp else 10.dp
Spacer(modifier = Modifier.padding(spacerSize))
Text(
text = item.name,
fontSize = 14.sp,
modifier = Modifier.padding(10.dp)
text = item.univName,
fontSize = 13.sp,
fontWeight = FontWeight.Bold,
color = Gray800
)
item.campusName?.let { campusName ->
Spacer(modifier = Modifier.padding(4.dp))
Text(
text = campusName,
fontSize = 13.sp,
color = Gray600,
)
}
Spacer(modifier = Modifier.padding(spacerSize))
}
}

Expand All @@ -197,10 +215,11 @@ fun UnivSelectScreenPreview() {
fun UnivSelectScreenItemPreview() {
EveryMeal_AndroidTheme {
UnivSelectItem(item = Item(
Image = R.drawable.image_myongji,
name = "명지대학교"
univName = "명지대",
campusName = "용인캠퍼스"
),
false
false,
index = 0
) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ val Gray100 = Color(0xFFF9FAFB)
val Gray200 = Color(0xFFE5E8EB)
val Gray300 = Color(0xFFF2F4F6)
val Gray500 = Color(0xFFB0B8C1)
val Gray600 = Color(0xFF8B95A1)
var Gray800 = Color(0xFF4E5968)

val Main100 = Color(0xFFFF4848)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed presentation/src/main/res/drawable/image_konkuk.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed presentation/src/main/res/drawable/image_sungsin.png
Binary file not shown.
1 change: 1 addition & 0 deletions presentation/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<!-- 아이콘, 이미지 설명 -->
<string name="icon_chat_description">학교 신청하러가기 채팅아이콘</string>
<string name="icon_arrow_right">들어가기</string>
<string name="icon_univ">학교 선택하기 아이콘</string>

<!-- 바텀 네비게이션 텍스트 -->
<string name="bottom_nav_home">맛집</string>
Expand Down

0 comments on commit 61d9f2e

Please sign in to comment.