Skip to content

Commit

Permalink
Merge pull request #50 from everymeals/feature/bottom_sheet
Browse files Browse the repository at this point in the history
[feature/bottom_sheet] 홈화면 바텀다이얼로그 작업
  • Loading branch information
SsongSik authored Sep 5, 2023
2 parents 5952574 + 5e573d4 commit 7a89f2a
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.everymeal.presentation.components

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.everymeal.presentation.R
import com.everymeal.presentation.ui.theme.Gray600
import com.everymeal.presentation.ui.theme.Gray900

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun EveryMealMainBottomSheetDialog(
title: String,
content: String,
onClick : () -> Unit,
onDismiss: () -> Unit
) {
ModalBottomSheet(
onDismissRequest = { onDismiss() },
containerColor = Color.White,
) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 20.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 = title,
fontSize = 22.sp,
color = Gray900,
fontWeight = FontWeight.Bold,
)
Spacer(modifier = Modifier.padding(4.dp))
Text(
text = content,
fontSize = 15.sp,
color = Gray600,
fontWeight = FontWeight.Medium,
)
Spacer(modifier = Modifier.padding(10.dp))
EveryMealMainButton(
text = stringResource(R.string.univ_admin_button),
onClick = onClick,
)
Spacer(modifier = Modifier.padding(10.dp))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ import com.everymeal.presentation.base.ViewState
class HomeContract {
data class HomeState(
val uiState: LoadState = LoadState.SUCCESS,
val bottomSheetState: Boolean = false
) : ViewState

sealed class HomeEvent : ViewEvent {

data class BottomSheetStateChange(
val bottomSheetState: Boolean
) : HomeEvent()
}

sealed class HomeEffect : ViewSideEffect {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.everymeal.presentation.ui.home
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -23,6 +24,11 @@ import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand All @@ -33,8 +39,10 @@ import androidx.compose.ui.text.font.FontWeight.Companion.Bold
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import com.everymeal.presentation.R
import com.everymeal.presentation.components.EveryMealLineButton
import com.everymeal.presentation.components.EveryMealMainBottomSheetDialog
import com.everymeal.presentation.components.EveryMealRestaurantItem
import com.everymeal.presentation.components.EveryMealReviewItem
import com.everymeal.presentation.ui.theme.EveryMeal_AndroidTheme
Expand All @@ -46,7 +54,7 @@ import com.everymeal.presentation.ui.theme.Paddings

@Composable
fun HomeScreen(

homeViewModel : HomeViewModel = hiltViewModel(),
) {
val items = listOf(
Restaurant(
Expand Down Expand Up @@ -74,6 +82,21 @@ fun HomeScreen(
),
)

val homeViewState by homeViewModel.viewState.collectAsState()

if (homeViewState.bottomSheetState) {
EveryMealMainBottomSheetDialog(
title = stringResource(id = R.string.univ_admin_review_title),
content = stringResource(id = R.string.univ_admin_review_content),
onClick = {

},
onDismiss = {
homeViewModel.setEvent(HomeContract.HomeEvent.BottomSheetStateChange(false))
}
)
}

val reviewTestItem = listOf(
Review(
name = "슈니",
Expand Down Expand Up @@ -114,7 +137,9 @@ fun HomeScreen(
.fillMaxWidth(),
) {
item {
HomeMainTopLayout()
HomeMainTopLayout {
homeViewModel.setEvent(HomeContract.HomeEvent.BottomSheetStateChange(true))
}
HomeCategoryList()
Spacer(modifier = Modifier.padding(10.dp))

Expand Down Expand Up @@ -223,12 +248,20 @@ fun HomeTopAppBar() {
}

@Composable
fun HomeMainTopLayout() {
fun HomeMainTopLayout(
onClick: () -> Unit,
) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(20.dp)
.background(Gray300, RoundedCornerShape(12.dp))
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() }
) {
onClick()
}
.padding(horizontal = Paddings.extra, vertical = 14.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ class HomeViewModel @Inject constructor(
) {

override fun handleEvents(event: HomeEvent) {

when (event) {
is HomeEvent.BottomSheetStateChange -> {
updateState {
copy(
bottomSheetState = event.bottomSheetState
)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ val Gray500 = Color(0xFFB0B8C1)
val Gray600 = Color(0xFF8B95A1)
val Gray700 = Color(0xFF6B7684)
var Gray800 = Color(0xFF4E5968)
val Gray900 = Color(0xFF333D4B)

val Grey2 = Color(0xFFF2F4F6)
val Grey7 = Color(0xFF6B7684)
Expand Down
5 changes: 5 additions & 0 deletions presentation/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@
<string name="save_title">저장</string>
<string name="save_empty_description">저장한 가게가 없어요</string>

<!-- 홈화면 바텀 시트 다이얼로그 -->
<string name="univ_admin_review_title">학교 인증이 된 사용자만\n리뷰를 남길 수 있어요</string>
<string name="univ_admin_review_content">바이럴 마케팅 없는 신뢰적인 정보를 공유하기 위해\n학교 인증이 필요해요</string>
<string name="univ_admin_button">인증하러 가기</string>

</resources>

0 comments on commit 7a89f2a

Please sign in to comment.