Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#159] 그룹 생성하기 완료 화면 내 링크 복사 버튼 잘림 #211

Merged
merged 9 commits into from
Aug 19, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.mashup.gabbangzip.sharedalbum.presentation.ui.groupcreation.common

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

@Composable
fun GroupCreationScaffold(
modifier: Modifier = Modifier,
contentAlignment: Alignment.Horizontal = Alignment.Start,
contentPadding: PaddingValues = PaddingValues(0.dp),
content: @Composable ColumnScope.() -> Unit,
topBar: @Composable () -> Unit = {},
bottomFloatingButton: @Composable BoxScope.() -> Unit = {},
) {
val scrollState = rememberScrollState()
GroupCreationInternals(
modifier = modifier,
topBar = topBar,
bottomFloatingButton = bottomFloatingButton,
) {
Column(
modifier = Modifier
.fillMaxSize()
.padding(contentPadding)
.verticalScroll(scrollState),
horizontalAlignment = contentAlignment,
content = content,
)
}
}

@Composable
fun GroupCreationScaffold(
modifier: Modifier = Modifier,
contentPadding: PaddingValues = PaddingValues(0.dp),
boxContent: @Composable BoxScope.() -> Unit,
topBar: @Composable () -> Unit = {},
bottomFloatingButton: @Composable BoxScope.() -> Unit = {},
) {
GroupCreationInternals(
modifier = modifier,
topBar = topBar,
bottomFloatingButton = bottomFloatingButton,
) {
Box(
modifier = Modifier.fillMaxSize().padding(contentPadding),
content = boxContent,
)
}
}

@Composable
private fun GroupCreationInternals(
modifier: Modifier = Modifier,
topBar: @Composable () -> Unit = {},
bottomFloatingButton: @Composable BoxScope.() -> Unit = {},
content: @Composable () -> Unit,
) {
Column(modifier = modifier) {
topBar()
Box(modifier = Modifier.weight(1f)) {
content()
Box(
modifier = Modifier.align(Alignment.BottomCenter),
content = bottomFloatingButton,
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package com.mashup.gabbangzip.sharedalbum.presentation.ui.groupcreation.complete

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Spacer
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.wrapContentHeight
Expand All @@ -12,6 +14,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.ClipboardManager
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
Expand All @@ -30,6 +33,7 @@ import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicNormalButton
import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicProgressBar
import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicTextOnlyTopBar
import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.model.PicSnackbarType
import com.mashup.gabbangzip.sharedalbum.presentation.ui.groupcreation.common.GroupCreationScaffold
import com.mashup.gabbangzip.sharedalbum.presentation.ui.groupcreation.common.ThumbnailCardFrame
import com.mashup.gabbangzip.sharedalbum.presentation.ui.groupcreation.complete.model.GroupCreationResult

Expand All @@ -39,86 +43,108 @@ fun GroupCreationCompleteScreen(
onNextButtonClicked: () -> Unit,
showSnackBarMessage: (type: PicSnackbarType, message: String) -> Unit,
) {
val clipboardManager = LocalClipboardManager.current
val copyLinkMessage = stringResource(id = R.string.button_copy_link_message)
val invitationMessage = stringResource(id = R.string.invitation_message)
val playStoreUrl = stringResource(id = R.string.play_store_url)
val appStoreUrl = stringResource(id = R.string.app_store_url)
Column {
PicTextOnlyTopBar(
modifier = Modifier
.background(Gray0Alpha80)
.padding(top = 20.dp),
titleText = stringResource(id = R.string.complete),
)
Column(
modifier = Modifier
.weight(1f),
horizontalAlignment = Alignment.CenterHorizontally,
) {
GroupCreationScaffold(
contentAlignment = Alignment.CenterHorizontally,
topBar = {
PicTextOnlyTopBar(
modifier = Modifier
.background(Gray0Alpha80)
.padding(top = 20.dp),
titleText = stringResource(id = R.string.complete),
)
PicProgressBar(
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
.padding(top = 3.dp, bottom = 32.dp, start = 16.dp, end = 16.dp),
.padding(top = 3.dp, start = 16.dp, end = 16.dp),
level = 4,
total = 4f,
)
Text(
},
bottomFloatingButton = {
PicButton(
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
.padding(bottom = 16.dp),
text = stringResource(id = R.string.group_complete_title),
style = PicTypography.headBold18,
color = Gray80,
textAlign = TextAlign.Center,
.padding(start = 22.dp, end = 22.dp, bottom = 16.dp),
text = stringResource(id = R.string.complete),
isRippleClickable = true,
onButtonClicked = onNextButtonClicked,
)
if (groupCreationResult != null) {
ThumbnailCard(
modifier = Modifier.size(310.dp, 420.dp),
groupCreationResult = groupCreationResult,
)
} else {
EmptyThumbnailCard()
}
Text(
},
content = {
GroupCreationCompleteContent(
clipboardManager = LocalClipboardManager.current,
copyLinkMessage = stringResource(id = R.string.button_copy_link_message),
invitationMessage = stringResource(id = R.string.invitation_message),
playStoreUrl = stringResource(id = R.string.play_store_url),
appStoreUrl = stringResource(id = R.string.app_store_url),
groupCreationResult = groupCreationResult,
showSnackBarMessage = showSnackBarMessage,
)
Spacer(
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
.padding(top = 16.dp, bottom = 8.dp),
text = stringResource(id = R.string.group_complete_contents),
style = PicTypography.bodyMedium14,
color = Gray60,
textAlign = TextAlign.Center,
.height(60.dp),
)
PicNormalButton(
text = stringResource(id = R.string.button_copy_link),
isRippleClickable = true,
backgroundColor = Gray40,
contentColor = Gray80,
iconRes = R.drawable.ic_link,
onButtonClicked = {
groupCreationResult?.invitationCode?.let { invitationCode ->
showSnackBarMessage(PicSnackbarType.CHECK, copyLinkMessage)
clipboardManager.setText(
AnnotatedString(
invitationMessage.format(playStoreUrl, appStoreUrl, invitationCode),
),
)
}
},
)
}
PicButton(
modifier = Modifier
.fillMaxWidth()
.padding(start = 22.dp, end = 22.dp, bottom = 16.dp),
text = stringResource(id = R.string.complete),
isRippleClickable = true,
onButtonClicked = onNextButtonClicked,
},
)
}

@Composable
private fun ColumnScope.GroupCreationCompleteContent(
groupCreationResult: GroupCreationResult?,
clipboardManager: ClipboardManager,
copyLinkMessage: String,
invitationMessage: String,
playStoreUrl: String,
appStoreUrl: String,
showSnackBarMessage: (type: PicSnackbarType, message: String) -> Unit,
) {
Text(
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
.padding(top = 32.dp, bottom = 16.dp),
text = stringResource(id = R.string.group_complete_title),
style = PicTypography.headBold18,
color = Gray80,
textAlign = TextAlign.Center,
)
if (groupCreationResult != null) {
ThumbnailCard(
modifier = Modifier.size(310.dp, 420.dp),
groupCreationResult = groupCreationResult,
)
} else {
EmptyThumbnailCard()
}
Text(
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
.padding(top = 16.dp, bottom = 8.dp),
text = stringResource(id = R.string.group_complete_contents),
style = PicTypography.bodyMedium14,
color = Gray60,
textAlign = TextAlign.Center,
)
PicNormalButton(
text = stringResource(id = R.string.button_copy_link),
isRippleClickable = true,
backgroundColor = Gray40,
contentColor = Gray80,
iconRes = R.drawable.ic_link,
onButtonClicked = {
groupCreationResult?.invitationCode?.let { invitationCode ->
showSnackBarMessage(PicSnackbarType.CHECK, copyLinkMessage)
clipboardManager.setText(
AnnotatedString(
invitationMessage.format(playStoreUrl, appStoreUrl, invitationCode),
),
)
}
},
)
}

@Composable
Expand All @@ -141,8 +167,12 @@ private fun ThumbnailCard(
}

@Composable
private fun EmptyThumbnailCard() {
Box(modifier = Modifier.size(310.dp, 420.dp))
private fun ColumnScope.EmptyThumbnailCard() {
Box(
modifier = Modifier
.size(310.dp, 420.dp)
.align(Alignment.CenterHorizontally),
)
}

@Preview(showBackground = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ fun GroupCreationIntroScreen(

@Preview(showBackground = true)
@Composable
private fun GroupCreationFirstScreenPreview() {
private fun GroupCreationIntroScreenPreview() {
GroupCreationIntroScreen(
onClickEnterByCodeButton = {},
onClickNextButton = {},
Expand Down
Loading
Loading