Skip to content

Commit

Permalink
refactor: 신고 컴포넌트 공통 컴포넌트로 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
rhkrwngud445 committed Jan 5, 2025
1 parent d2c550f commit 7b18480
Show file tree
Hide file tree
Showing 16 changed files with 336 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.withpeace.withpeace.feature.postdetail
package com.withpeace.withpeace.core.ui.comment

import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
Expand Down Expand Up @@ -41,10 +41,12 @@ import com.skydoves.landscapist.glide.GlideImage
import com.withpeace.withpeace.core.designsystem.theme.PretendardFont
import com.withpeace.withpeace.core.designsystem.theme.WithpeaceTheme
import com.withpeace.withpeace.core.ui.DateUiModel
import com.withpeace.withpeace.core.ui.R
import com.withpeace.withpeace.core.ui.R.drawable
import com.withpeace.withpeace.core.ui.post.CommentUiModel
import com.withpeace.withpeace.core.ui.post.CommentUserUiModel
import com.withpeace.withpeace.core.ui.post.ReportTypeUiModel
import com.withpeace.withpeace.core.ui.report.PostDetailReportBottomSheet
import com.withpeace.withpeace.core.ui.toRelativeString
import java.time.LocalDateTime

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.withpeace.withpeace.core.ui.comment

import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.withpeace.withpeace.core.designsystem.theme.WithpeaceTheme
import com.withpeace.withpeace.core.ui.R

@Composable
fun CommentSize(
commentSize: Int,
) {
Row(
modifier = Modifier.padding(horizontal = WithpeaceTheme.padding.BasicHorizontalPadding),
verticalAlignment = Alignment.CenterVertically,
) {
Icon(
painter = painterResource(id = R.drawable.ic_chat),
contentDescription = "댓글 개수",
modifier = Modifier.padding(end = 4.dp),
)
Text(
text = "$commentSize",
style = WithpeaceTheme.typography.caption,
)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.withpeace.withpeace.feature.postdetail
package com.withpeace.withpeace.core.ui.comment

import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
Expand Down Expand Up @@ -27,6 +27,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.unit.dp
import com.withpeace.withpeace.core.designsystem.theme.WithpeaceTheme
import com.withpeace.withpeace.core.ui.R

@Composable
fun RegisterCommentSection(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.withpeace.withpeace.core.ui.report

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Text
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.RectangleShape
import com.withpeace.withpeace.core.designsystem.theme.WithpeaceTheme
import com.withpeace.withpeace.core.designsystem.ui.WithPeaceBackButtonTopAppBar
import com.withpeace.withpeace.core.ui.post.ReportTypeUiModel

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun PostDetailReportBottomSheet(
isPostReport: Boolean,
id: Long,
onDismissRequest: () -> Unit,
onClickReportType: (id: Long, ReportTypeUiModel) -> Unit,
) {
val bottomSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
ModalBottomSheet(
contentWindowInsets = { WindowInsets(0, 0, 0, 0) },
containerColor = WithpeaceTheme.colors.SystemWhite,
onDismissRequest = onDismissRequest,
sheetState = bottomSheetState,
shape = RectangleShape,
) {
Column(
modifier = Modifier.fillMaxSize(),
) {
WithPeaceBackButtonTopAppBar(
onClickBackButton = onDismissRequest,
title = {
Text(text = "신고하는 이유를 선택해주세요", style = WithpeaceTheme.typography.title1)
},
)
HorizontalDivider(Modifier.padding(horizontal = WithpeaceTheme.padding.BasicHorizontalPadding))
Column(
modifier = Modifier
.fillMaxWidth(),
) {
ReportTypeUiModel.entries.forEach { reportTypeUiModel ->
ReportTypeItem(
isPostReport = isPostReport,
id = id,
reportTypeUiModel = reportTypeUiModel,
onClickReportType = onClickReportType,
onDismissRequest = onDismissRequest,
)
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package com.withpeace.withpeace.core.ui.report

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
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.layout.wrapContentSize
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.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import com.withpeace.withpeace.core.designsystem.theme.WithpeaceTheme
import com.withpeace.withpeace.core.ui.R

@Composable
fun ReportDialog(
title: String,
onClickReportButton: () -> Unit,
onDismissRequest: () -> Unit,
) {
Dialog(onDismissRequest = onDismissRequest) {
Column(
modifier = Modifier
.background(
WithpeaceTheme.colors.SystemWhite,
RoundedCornerShape(10.dp),
)
.wrapContentSize(),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Text(
modifier = Modifier.padding(top = 24.dp, bottom = 16.dp),
text = title,
style = WithpeaceTheme.typography.title2,
)
Row {
Button(
modifier = Modifier
.padding(start = 16.dp, end = 4.dp)
.weight(1f),
onClick = { onDismissRequest() },
shape = RoundedCornerShape(10.dp),
border = BorderStroke(width = 1.dp, color = WithpeaceTheme.colors.MainPurple),
colors = ButtonDefaults.buttonColors(containerColor = WithpeaceTheme.colors.SystemWhite),
) {
Text(
text = stringResource(R.string.delete_cancel),
style = WithpeaceTheme.typography.caption,
color = WithpeaceTheme.colors.MainPurple,
)
}
Button(
modifier = Modifier
.padding(start = 4.dp, end = 16.dp)
.weight(1f),
onClick = {
onClickReportButton()
onDismissRequest()
},
shape = RoundedCornerShape(10.dp),
colors = ButtonDefaults.buttonColors(containerColor = WithpeaceTheme.colors.MainPurple),
) {
Text(
text = "신고하기",
style = WithpeaceTheme.typography.caption,
color = WithpeaceTheme.colors.SystemWhite,
)
}
}
Spacer(modifier = Modifier.height(16.dp))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.withpeace.withpeace.core.ui.report

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.withpeace.withpeace.core.designsystem.theme.WithpeaceTheme
import com.withpeace.withpeace.core.ui.post.ReportTypeUiModel

@Composable
fun ReportTypeItem(
modifier: Modifier = Modifier,
isPostReport: Boolean,
id: Long,
reportTypeUiModel: ReportTypeUiModel,
onClickReportType: (id: Long, ReportTypeUiModel) -> Unit,
onDismissRequest: () -> Unit,
) {
var showReportDialog by rememberSaveable {
mutableStateOf(false)
}
val title = if (isPostReport) reportTypeUiModel.postTitle else reportTypeUiModel.commentTitle
Column(
modifier = modifier.clickable {
showReportDialog = true
}.padding(horizontal = WithpeaceTheme.padding.BasicHorizontalPadding),
) {
Text(
text = title,
style = WithpeaceTheme.typography.body,
modifier = Modifier.padding(start = 4.dp, top = 16.dp, bottom = 16.dp),
)
HorizontalDivider()
}
if (showReportDialog) {
ReportDialog(
title = title,
onClickReportButton = {
onClickReportType(id, reportTypeUiModel)
onDismissRequest()
},
onDismissRequest = { showReportDialog = false },
)
}
}
9 changes: 9 additions & 0 deletions core/ui/src/main/res/drawable/ic_chat.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:pathData="M15.27,15.703L13.156,15.008L12.786,15.19C11.936,15.608 10.991,15.831 10,15.831C6.69,15.831 4,13.262 4,10.408C4,7.555 6.69,4.986 10,4.986C13.31,4.986 16,7.555 16,10.408C16,11.473 15.61,12.554 14.893,13.477L14.548,13.921L15.271,15.702L15.27,15.703ZM15.977,16.975C16.067,17.004 16.165,17.008 16.257,16.985C16.35,16.962 16.434,16.914 16.499,16.845C16.565,16.777 16.609,16.691 16.627,16.599C16.645,16.507 16.635,16.411 16.6,16.324L15.688,14.076C16.52,13.001 17,11.716 17,10.408C17,7.141 14,4 10,4C6,4 3,7.141 3,10.408C3,13.676 6,16.817 10,16.817C11.122,16.82 12.229,16.565 13.233,16.071L15.977,16.973V16.975Z"
android:fillColor="#000000"/>
</vector>
9 changes: 9 additions & 0 deletions core/ui/src/main/res/drawable/ic_complain.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M11.308,4.333V3.667C11.308,3.49 11.381,3.32 11.51,3.195C11.64,3.07 11.816,3 12,3C12.184,3 12.36,3.07 12.49,3.195C12.619,3.32 12.692,3.49 12.692,3.667V4.333C12.692,4.51 12.619,4.68 12.49,4.805C12.36,4.93 12.184,5 12,5C11.816,5 11.64,4.93 11.51,4.805C11.381,4.68 11.308,4.51 11.308,4.333ZM18.231,7C18.322,7 18.412,6.983 18.496,6.949C18.58,6.916 18.656,6.867 18.721,6.805L19.413,6.138C19.543,6.013 19.616,5.844 19.616,5.667C19.616,5.49 19.543,5.32 19.413,5.195C19.283,5.07 19.107,5 18.923,5C18.739,5 18.563,5.07 18.433,5.195L17.741,5.862C17.644,5.955 17.578,6.074 17.551,6.203C17.524,6.333 17.538,6.467 17.591,6.589C17.643,6.71 17.732,6.815 17.846,6.888C17.96,6.961 18.094,7 18.231,7ZM5.279,6.805C5.409,6.93 5.586,7 5.769,7C5.953,7 6.129,6.93 6.259,6.805C6.389,6.68 6.462,6.51 6.462,6.333C6.462,6.156 6.389,5.987 6.259,5.862L5.567,5.195C5.437,5.07 5.261,5 5.077,5C4.893,5 4.717,5.07 4.587,5.195C4.457,5.32 4.384,5.49 4.384,5.667C4.384,5.844 4.457,6.013 4.587,6.138L5.279,6.805ZM12.808,9.009C12.718,8.994 12.626,8.996 12.537,9.015C12.447,9.034 12.363,9.07 12.288,9.121C12.214,9.172 12.15,9.236 12.101,9.311C12.053,9.386 12.02,9.469 12.005,9.556C11.99,9.642 11.993,9.731 12.014,9.817C12.034,9.903 12.073,9.984 12.126,10.055C12.179,10.127 12.247,10.187 12.325,10.233C12.403,10.28 12.49,10.31 12.58,10.324C14.221,10.59 15.462,12.027 15.462,13.667C15.462,13.844 15.535,14.013 15.664,14.138C15.794,14.263 15.97,14.333 16.154,14.333C16.337,14.333 16.514,14.263 16.643,14.138C16.773,14.013 16.846,13.844 16.846,13.667C16.846,11.383 15.109,9.381 12.807,9.009H12.808ZM21,17.667V19.667C21,20.02 20.854,20.359 20.594,20.61C20.335,20.86 19.983,21 19.615,21H4.385C4.017,21 3.665,20.86 3.406,20.61C3.146,20.359 3,20.02 3,19.667V17.667C3,17.313 3.146,16.974 3.406,16.724C3.665,16.474 4.017,16.333 4.385,16.333V13.667C4.385,12.699 4.583,11.741 4.97,10.847C5.356,9.954 5.922,9.143 6.636,8.461C7.349,7.78 8.195,7.241 9.126,6.875C10.057,6.51 11.053,6.326 12.058,6.333C16.225,6.363 19.615,9.691 19.615,13.75V16.333C19.983,16.333 20.335,16.474 20.594,16.724C20.854,16.974 21,17.313 21,17.667ZM5.769,16.333H18.231V13.75C18.231,10.417 15.457,7.691 12.048,7.667H12C10.347,7.667 8.763,8.299 7.594,9.424C6.426,10.549 5.769,12.075 5.769,13.667V16.333ZM19.615,19.667V17.667H4.385V19.667H19.615Z"
android:fillColor="#000000"/>
</vector>
9 changes: 9 additions & 0 deletions core/ui/src/main/res/drawable/ic_delete.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M10,5.25V5.5H14V5.25C14,4.72 13.789,4.211 13.414,3.836C13.039,3.461 12.53,3.25 12,3.25C11.47,3.25 10.961,3.461 10.586,3.836C10.211,4.211 10,4.72 10,5.25ZM8.75,5.5V5.25C8.75,4.388 9.092,3.561 9.702,2.952C10.311,2.342 11.138,2 12,2C12.862,2 13.689,2.342 14.298,2.952C14.908,3.561 15.25,4.388 15.25,5.25V5.5H20.875C21.041,5.5 21.2,5.566 21.317,5.683C21.434,5.8 21.5,5.959 21.5,6.125C21.5,6.291 21.434,6.45 21.317,6.567C21.2,6.684 21.041,6.75 20.875,6.75H19.417L18.417,18.678C18.34,19.584 17.927,20.428 17.258,21.043C16.589,21.659 15.713,22 14.804,22H9.196C8.287,22 7.411,21.658 6.742,21.043C6.073,20.428 5.66,19.584 5.584,18.678L4.584,6.75H3.125C2.959,6.75 2.8,6.684 2.683,6.567C2.566,6.45 2.5,6.291 2.5,6.125C2.5,5.959 2.566,5.8 2.683,5.683C2.8,5.566 2.959,5.5 3.125,5.5H8.75ZM6.83,18.573C6.879,19.167 7.15,19.72 7.588,20.123C8.027,20.526 8.601,20.75 9.196,20.75H14.804C15.4,20.75 15.974,20.526 16.412,20.123C16.85,19.72 17.121,19.167 17.171,18.573L18.162,6.75H5.838L6.83,18.573ZM10.75,10.125C10.75,10.043 10.734,9.962 10.702,9.886C10.671,9.81 10.625,9.741 10.567,9.683C10.509,9.625 10.44,9.579 10.364,9.548C10.288,9.516 10.207,9.5 10.125,9.5C10.043,9.5 9.962,9.516 9.886,9.548C9.81,9.579 9.741,9.625 9.683,9.683C9.625,9.741 9.579,9.81 9.548,9.886C9.516,9.962 9.5,10.043 9.5,10.125V17.375C9.5,17.457 9.516,17.538 9.548,17.614C9.579,17.69 9.625,17.759 9.683,17.817C9.741,17.875 9.81,17.921 9.886,17.952C9.962,17.984 10.043,18 10.125,18C10.207,18 10.288,17.984 10.364,17.952C10.44,17.921 10.509,17.875 10.567,17.817C10.625,17.759 10.671,17.69 10.702,17.614C10.734,17.538 10.75,17.457 10.75,17.375V10.125ZM13.875,9.5C14.22,9.5 14.5,9.78 14.5,10.125V17.375C14.5,17.541 14.434,17.7 14.317,17.817C14.2,17.934 14.041,18 13.875,18C13.709,18 13.55,17.934 13.433,17.817C13.316,17.7 13.25,17.541 13.25,17.375V10.125C13.25,9.78 13.53,9.5 13.875,9.5Z"
android:fillColor="#000000"/>
</vector>
13 changes: 13 additions & 0 deletions core/ui/src/main/res/drawable/ic_edit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M15,6L18,9M13,20H21M5,16L4.081,19.677C4.044,19.823 4.177,19.956 4.323,19.919L8,19L19.586,7.414C19.961,7.039 20.172,6.531 20.172,6C20.172,5.47 19.961,4.961 19.586,4.586L19.414,4.414C19.039,4.039 18.53,3.829 18,3.829C17.47,3.829 16.961,4.039 16.586,4.414L5,16Z"
android:strokeLineJoin="round"
android:strokeWidth="1.5"
android:fillColor="#00000000"
android:strokeColor="#000000"
android:strokeLineCap="round"/>
</vector>
9 changes: 9 additions & 0 deletions core/ui/src/main/res/drawable/ic_hide.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M3.818,6.988L4.865,6L18.545,19.004L17.506,20L14.986,17.604C14.045,17.9 13.047,18.056 12,18.056C7.909,18.056 4.415,15.637 3,12.222C3.565,10.853 4.465,9.648 5.61,8.691L3.818,6.988ZM12,9.889C12.651,9.889 13.275,10.135 13.736,10.572C14.196,11.01 14.455,11.603 14.455,12.222C14.455,12.487 14.408,12.75 14.316,13L11.182,10.021C11.445,9.933 11.721,9.889 12,9.889ZM12,6.389C16.091,6.389 19.584,8.808 21,12.222C20.332,13.835 19.198,15.234 17.727,16.259L16.566,15.147C17.697,14.403 18.609,13.396 19.216,12.222C18.555,10.939 17.528,9.858 16.252,9.101C14.977,8.345 13.503,7.944 12,7.944C11.108,7.944 10.233,8.084 9.415,8.333L8.155,7.143C9.333,6.661 10.634,6.389 12,6.389ZM4.784,12.222C5.445,13.506 6.472,14.587 7.748,15.343C9.023,16.099 10.497,16.5 12,16.5C12.564,16.5 13.121,16.446 13.636,16.337L11.771,14.556C11.202,14.498 10.67,14.256 10.265,13.871C9.861,13.486 9.606,12.981 9.545,12.44L6.764,9.788C5.954,10.449 5.275,11.273 4.784,12.222Z"
android:fillColor="#000000"/>
</vector>
15 changes: 15 additions & 0 deletions core/ui/src/main/res/drawable/ic_more.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M10.5,6C10.5,6.828 11.172,7.5 12,7.5C12.828,7.5 13.5,6.828 13.5,6C13.5,5.172 12.828,4.5 12,4.5C11.172,4.5 10.5,5.172 10.5,6Z"
android:fillColor="#696969"/>
<path
android:pathData="M10.5,12C10.5,12.828 11.172,13.5 12,13.5C12.828,13.5 13.5,12.828 13.5,12C13.5,11.172 12.828,10.5 12,10.5C11.172,10.5 10.5,11.172 10.5,12Z"
android:fillColor="#696969"/>
<path
android:pathData="M10.5,18C10.5,18.828 11.172,19.5 12,19.5C12.828,19.5 13.5,18.828 13.5,18C13.5,17.172 12.828,16.5 12,16.5C11.172,16.5 10.5,17.172 10.5,18Z"
android:fillColor="#696969"/>
</vector>
9 changes: 9 additions & 0 deletions core/ui/src/main/res/drawable/ic_send.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M14.414,10.685L11.228,15.146C11.191,15.197 11.169,15.257 11.163,15.32C11.157,15.382 11.167,15.446 11.193,15.503L13.406,20.353C13.606,20.803 14.255,20.773 14.41,20.305L18.979,6.601C19.011,6.506 19.015,6.404 18.992,6.307C18.969,6.21 18.92,6.121 18.849,6.05C18.778,5.98 18.69,5.93 18.592,5.907C18.495,5.884 18.393,5.888 18.299,5.92L4.594,10.489C4.126,10.645 4.096,11.294 4.547,11.493L9.397,13.705C9.454,13.731 9.517,13.742 9.58,13.736C9.643,13.73 9.703,13.707 9.754,13.671L14.214,10.484C14.242,10.464 14.276,10.455 14.31,10.458C14.344,10.46 14.376,10.475 14.4,10.499C14.424,10.523 14.439,10.555 14.442,10.589C14.444,10.623 14.435,10.657 14.415,10.685L14.414,10.685Z"
android:fillColor="#000000"/>
</vector>
Loading

0 comments on commit 7b18480

Please sign in to comment.