Skip to content

Commit

Permalink
feat : 이벤트 다이어로그 컴포넌트 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
HamBP committed Jan 14, 2025
1 parent 799c22c commit 0dcc64c
Show file tree
Hide file tree
Showing 2 changed files with 146 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
package com.nexters.boolti.presentation.screen.show

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Card
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
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.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color.Companion.White
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import coil.compose.AsyncImage
import com.nexters.boolti.presentation.R
import com.nexters.boolti.presentation.component.BtCheckBox
import com.nexters.boolti.presentation.theme.BooltiTheme
import com.nexters.boolti.presentation.theme.Grey50
import com.nexters.boolti.presentation.theme.Grey95

@Composable
fun BTDialog(
imageUrl: String,
actionUrl: String?,
onDismiss: (hideToday: Boolean) -> Unit,
) {
var hideToday by rememberSaveable { mutableStateOf(false) }
val uriHandler = LocalUriHandler.current

Dialog(
properties = DialogProperties(
usePlatformDefaultWidth = false,
),
onDismissRequest = { onDismiss(hideToday) }
) {
Card(
modifier = Modifier.width(311.dp),
shape = RoundedCornerShape(8.dp),
) {
Column {
Box(
modifier = Modifier
.fillMaxWidth()
.height(360.dp)
.then(
if (actionUrl == null) {
Modifier
} else {
Modifier.clickable {
uriHandler.openUri(actionUrl)
}
}
)
) {
AsyncImage(
model = imageUrl,
contentDescription = stringResource(id = R.string.description_event_poster),
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Crop,
)
}
Row(
modifier = Modifier
.fillMaxWidth()
.height(56.dp)
.background(color = White),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
) {
Row(
modifier = Modifier
.fillMaxHeight()
.clickable(onClick = { hideToday = !hideToday })
.padding(horizontal = 20.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp),
) {
Box(
modifier = Modifier.size(24.dp),
contentAlignment = Alignment.Center,
) {
BtCheckBox(
isSelected = hideToday
)
}
Text(
text = "오늘 하루 그만 보기",
style = MaterialTheme.typography.bodyLarge.copy(color = Grey50)
)
}
Box(
modifier = Modifier
.fillMaxHeight()
.width(68.dp)
.clickable(onClick = { onDismiss(hideToday) }),
contentAlignment = Alignment.Center
) {
Text(
text = stringResource(R.string.description_close_button),
style = MaterialTheme.typography.bodyLarge.copy(color = Grey95),
textAlign = TextAlign.Center,
)
}
}
}
}
}
}

@Preview(widthDp = 360, heightDp = 760)
@Composable
fun BTDialogPreview() {
BooltiTheme {
Surface {
BTDialog(
imageUrl = "",
actionUrl = "",
onDismiss = {}
)
}
}
}
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 @@ -7,6 +7,7 @@

<string name="description_navigate_back">뒤로 가기</string>
<string name="description_poster">포스터 사진</string>
<string name="description_event_poster">이벤트 포스터</string>
<string name="description_user_thumbnail">유저 섬네일</string>
<string name="description_close_button">닫기</string>
<string name="description_toolbar_home">홈으로 이동</string>
Expand Down

0 comments on commit 0dcc64c

Please sign in to comment.