Skip to content

Commit

Permalink
Merge pull request #66 from everymeals/feature/review_star_view
Browse files Browse the repository at this point in the history
[Feature/review_star_view]: 리뷰 상세 기능
  • Loading branch information
kez-lab authored Oct 16, 2023
2 parents 2c35905 + 5b4f57c commit 244d6ed
Show file tree
Hide file tree
Showing 13 changed files with 567 additions and 25 deletions.
8 changes: 6 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[versions]
agp = "8.1.1"
coil-compose = "2.4.0"
kotlin = "1.8.21"
core-ktx = "1.10.1"
junit = "4.13.2"
androidx-test-ext-junit = "1.1.5"
espresso-core = "3.5.1"
lifecycle-runtime-ktx = "2.6.1"
activity-compose = "1.7.2"
activity = "1.7.2"
compose-bom = "2023.08.00"

dagger-hilt = "2.46.1"
Expand All @@ -23,12 +24,15 @@ compose-navigation = "2.6.0"

[libraries]
agp = { module = "com.android.tools.build:gradle", version.ref = "agp" }
coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil-compose" }
core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core-ktx" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-ext-junit" }
espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso-core" }
lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle-runtime-ktx" }
activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity-compose" }
activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity" }
activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
activity-ktx = { group = "androidx.activity", name = "activity-ktx", version.ref = "activity" }
compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
ui = { group = "androidx.compose.ui", name = "ui" }
ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
Expand Down
5 changes: 5 additions & 0 deletions presentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ dependencies {
implementation(libs.core.ktx)
implementation(libs.lifecycle.runtime.ktx)
implementation(libs.activity.compose)
implementation(libs.activity)
implementation(libs.activity.ktx)
implementation(platform(libs.compose.bom))
implementation(libs.ui)
implementation(libs.ui.graphics)
Expand All @@ -78,4 +80,7 @@ dependencies {

// Navigation
implementation(libs.compose.navigation)

// Coil
implementation(libs.coil.compose)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.everymeal.presentation.components

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import com.everymeal.presentation.ui.theme.EveryMealTypography
import com.everymeal.presentation.ui.theme.Grey7
import com.everymeal.presentation.ui.theme.MONO_BLACK

@Composable
fun EveryMealDialog(
modifier: Modifier = Modifier,
title: String,
message: String,
confirmButtonText: String,
dismissButtonText: String,
onDismissRequest: () -> Unit,
onConfirmClick: () -> Unit,
onDisMissClicked: () -> Unit
) {
Dialog(
onDismissRequest = onDismissRequest,
content = {
Surface(
modifier = modifier,
shape = RoundedCornerShape(10.dp),
) {
Column(
modifier = Modifier
.padding(top = 8.dp)
.padding(16.dp)
) {
Text(
text = title,
style = EveryMealTypography.titleLarge,
color = MONO_BLACK
)
Spacer(modifier = Modifier.height(4.dp))
Text(
text = message,
style = EveryMealTypography.bodyMedium,
color = Grey7
)
Spacer(modifier = Modifier.height(24.dp))
Row {
EveryMealGreyButton(
modifier = Modifier
.weight(1f)
.padding(end = 4.dp),
onClick = onDisMissClicked,
buttonText = dismissButtonText
)
EveryMealRedButton(
modifier = Modifier
.weight(1f)
.padding(start = 4.dp),
onClick = onConfirmClick,
buttonText = confirmButtonText
)
}
}
}
}
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.everymeal.presentation.components

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
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.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.everymeal.presentation.ui.theme.Gray200
import com.everymeal.presentation.ui.theme.Grey7
import com.everymeal.presentation.ui.theme.Main100

@Composable
fun EveryMealGreyButton(
modifier: Modifier = Modifier,
buttonText: String,
onClick: () -> Unit = {}
) {
Button(
modifier = modifier,
colors = ButtonDefaults.buttonColors(
containerColor = Gray200,
contentColor = Grey7,
disabledContainerColor = Gray200,
disabledContentColor = Color.White,
),
onClick = onClick,
shape = RoundedCornerShape(12.dp),
contentPadding = PaddingValues(16.dp),
content = {
Text(
text = buttonText,
style = TextStyle(
fontSize = 16.sp,
fontWeight = FontWeight(500),
color = Grey7,
)
)
}
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.everymeal.presentation.components

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
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.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.everymeal.presentation.ui.theme.Gray200
import com.everymeal.presentation.ui.theme.Main100

@Composable
fun EveryMealRedButton(
modifier: Modifier = Modifier,
buttonText: String,
enabled: Boolean = true,
onClick: () -> Unit = {}
) {
Button(
modifier = modifier,
colors = ButtonDefaults.buttonColors(
containerColor = Main100,
contentColor = Color.White,
disabledContainerColor = Gray200,
disabledContentColor = Color.White,
),
enabled = enabled,
onClick = onClick,
shape = RoundedCornerShape(12.dp),
contentPadding = PaddingValues(16.dp),
content = {
Text(
text = buttonText,
style = TextStyle(
fontSize = 16.sp,
fontWeight = FontWeight(500),
color = Color.White,
)
)
}
)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.everymeal.presentation.ui.review

import android.util.Log
import android.widget.Toast
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.PickVisualMediaRequest
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
Expand All @@ -20,9 +25,12 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
Expand All @@ -33,21 +41,35 @@ 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.EveryMealDialog
import com.everymeal.presentation.ui.review.write.ReviewWriteScreen
import com.everymeal.presentation.ui.search.topbar.SearchBar
import com.everymeal.presentation.ui.theme.Gray600
import com.everymeal.presentation.ui.theme.Grey2
import com.everymeal.presentation.ui.theme.Grey9
import com.everymeal.presentation.ui.theme.Typography


@Composable
fun ReviewScreen(
viewModel: ReviewScreenViewModel = hiltViewModel()
) {
val pickMultipleMedia = rememberLauncherForActivityResult(
ActivityResultContracts.PickMultipleVisualMedia(10)
) {
viewModel.setEvent(ReviewEvent.OnImageSelected(it))
Log.d("ReviewScreen", "ReviewScreen: $it")
}
val viewState by viewModel.viewState.collectAsState()
val context = LocalContext.current
Scaffold(
topBar = {
ReviewTopBar()
ReviewTopBar(
title = stringResource(R.string.review_write),
onBackClicked = {

},
)
},
containerColor = Color.White
) { innerPadding ->
Expand Down Expand Up @@ -77,7 +99,18 @@ fun ReviewScreen(
viewModel.setEvent(ReviewEvent.OnReviewTextChanged(it))
},
onReviewRegisterClicked = {
// TODO 리뷰 등록
Toast.makeText(
context,
context.getString(R.string.register_review),
Toast.LENGTH_SHORT
).show()
},
onAddPhotoClicked = {
pickMultipleMedia.launch(
PickVisualMediaRequest(
ActivityResultContracts.PickVisualMedia.ImageOnly
)
)
}
)
}
Expand Down Expand Up @@ -135,7 +168,7 @@ fun ColumnScope.RestaurantType(
}

@Composable
fun ColumnScope.RestaurantName(
fun RestaurantName(
modifier: Modifier = Modifier,
viewState: ReviewState
) {
Expand Down Expand Up @@ -170,7 +203,7 @@ fun ReviewSearchBar(
fun StarRating(
modifier: Modifier = Modifier,
ratingStateList: List<State<Boolean>>,
starRatingClicked: (Int) -> Unit,
starRatingClicked: ((Int) -> Unit)? = null,
starSize: Dp = 40.dp,
) {
LazyRow(
Expand All @@ -183,7 +216,7 @@ fun StarRating(
.size(starSize)
.padding(horizontal = 1.dp)
.clickable {
starRatingClicked(index)
starRatingClicked?.invoke(index)
},
painter = if (active.value) {
painterResource(
Expand Down Expand Up @@ -214,30 +247,58 @@ fun ReviewGuideHeader(

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ReviewTopBar() {
fun ReviewTopBar(
modifier: Modifier = Modifier,
title: String,
onBackClicked: () -> Unit
) {
TopAppBar(
title = {
Text(
text = stringResource(R.string.review_write),
text = title,
style = Typography.bodySmall,
color = Grey9
)
},
actions = {
Icon(
modifier = Modifier
modifier = modifier
.size(48.dp)
.padding(12.dp)
.padding(end = 4.dp),
.padding(end = 4.dp)
.clickable(onClick = onBackClicked),
painter = painterResource(id = R.drawable.icon_x_mono),
contentDescription = null
)
}
)
}

@Composable
fun ReviewSaveDialog(
modifier: Modifier = Modifier
) {
val showDialog = remember { mutableStateOf(true) }
if (showDialog.value) {
EveryMealDialog(
modifier = modifier,
title = stringResource(R.string.review_save_dialog_title),
message = stringResource(R.string.review_save_dialog_content),
confirmButtonText = stringResource(R.string.exit),
dismissButtonText = stringResource(R.string.review_save_dialog_write_continue),
onDismissRequest = {},
onConfirmClick = {
showDialog.value = false
},
onDisMissClicked = {
showDialog.value = false
}
)
}
}

@Composable
@Preview
fun ReviewScreenPreview() {
ReviewScreen()
ReviewSaveDialog()
}
Loading

0 comments on commit 244d6ed

Please sign in to comment.