From 257e2767d133f8a5db5fc2c320aabb3c6b430204 Mon Sep 17 00:00:00 2001 From: yonghanJu Date: Mon, 21 Oct 2024 22:05:00 +0900 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=EA=B2=8C=EC=8B=9C=EA=B8=80=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1=20=EC=8B=9C=20=ED=82=A4=EB=B3=B4=EB=93=9C?= =?UTF-8?q?=EA=B0=80=20=ED=99=94=EB=A9=B4=20=EA=B0=80=EB=A6=AC=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../screens/mypage/addpost/PostingScreen.kt | 221 +++++++++--------- 1 file changed, 116 insertions(+), 105 deletions(-) diff --git a/presentation/src/main/java/com/whyranoid/presentation/screens/mypage/addpost/PostingScreen.kt b/presentation/src/main/java/com/whyranoid/presentation/screens/mypage/addpost/PostingScreen.kt index deb7878..aeeb8c2 100644 --- a/presentation/src/main/java/com/whyranoid/presentation/screens/mypage/addpost/PostingScreen.kt +++ b/presentation/src/main/java/com/whyranoid/presentation/screens/mypage/addpost/PostingScreen.kt @@ -11,7 +11,6 @@ import androidx.compose.foundation.border 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.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer @@ -23,6 +22,9 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.foundation.layout.wrapContentSize +import androidx.compose.foundation.layout.wrapContentWidth +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.BasicTextField @@ -44,6 +46,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import androidx.compose.ui.focus.onFocusChanged import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.SolidColor import androidx.compose.ui.platform.LocalContext @@ -98,124 +101,132 @@ fun PostingScreen(runningHistory: RunningHistory, finish: () -> Unit) { val viewModel = koinViewModel() val isUploading = viewModel.uploadingState.collectAsStateWithLifecycle() - Column( + val listState = rememberLazyListState() + + LazyColumn( modifier = Modifier .fillMaxWidth() + .padding(bottom = 80.dp) .wrapContentHeight(), + state = listState, verticalArrangement = Arrangement.Top, ) { - Box( - Modifier - .fillMaxWidth() - .padding(horizontal = 20.dp) - .padding(top = 20.dp), - ) { - Text( - style = WalkieTypography.Title, - text = "새 게시물", - modifier = Modifier - .align(Alignment.Center) - .padding(bottom = 24.dp), - ) - } + item { + Box( + Modifier + .fillMaxWidth() + .padding(horizontal = 20.dp) + .padding(top = 20.dp), + ) { + Text( + style = WalkieTypography.Title, + text = "새 게시물", + modifier = Modifier + .align(Alignment.Center) + .padding(bottom = 24.dp), + ) + } - Row( - modifier = Modifier.padding(horizontal = 20.dp), - horizontalArrangement = Arrangement.spacedBy(12.dp), - ) { - SimpleDateFormat("yyyy/MM/dd HH:mm").format(Date(runningHistory.finishedAt)).split(' ') - .forEach { - Row( - horizontalArrangement = Arrangement.Center, - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier - .padding(bottom = 12.dp) - .weight(1f) - .height(40.dp) - .clip(RoundedCornerShape(12.dp)) - .background(WalkieColor.GrayDefault), - ) { - Text(text = it, style = WalkieTypography.SubTitle) + Row( + modifier = Modifier.padding(horizontal = 20.dp), + horizontalArrangement = Arrangement.spacedBy(12.dp), + ) { + SimpleDateFormat("yyyy/MM/dd HH:mm").format(Date(runningHistory.finishedAt)) + .split(' ') + .forEach { + Row( + horizontalArrangement = Arrangement.Center, + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier + .padding(bottom = 12.dp) + .weight(1f) + .height(40.dp) + .clip(RoundedCornerShape(12.dp)) + .background(WalkieColor.GrayDefault), + ) { + Text(text = it, style = WalkieTypography.SubTitle) + } } - } - } + } - var runningHistoryState by remember { mutableStateOf(runningHistory) } + var runningHistoryState by remember { mutableStateOf(runningHistory) } - Map(runningHistoryState, textVisibleState, isUploading.value, text) + Map(runningHistoryState, textVisibleState, isUploading.value, text) - Row( - horizontalArrangement = Arrangement.SpaceAround, - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier - .padding(horizontal = 20.dp) - .align(Alignment.End) - .wrapContentSize(), - ) { - if (photoEditState) { - Text("앨범", style = WalkieTypography.SubTitle) - Spacer(Modifier.weight(1f)) - } - Icon( + Row( + horizontalArrangement = Arrangement.SpaceAround, + verticalAlignment = Alignment.CenterVertically, modifier = Modifier - .clickable { - textVisibleState = when (textVisibleState) { - TextVisibleState.WHITE -> TextVisibleState.BLACK - TextVisibleState.BLACK -> TextVisibleState.HIDE - TextVisibleState.HIDE -> TextVisibleState.WHITE + .padding(horizontal = 20.dp) + .fillMaxWidth() + .wrapContentWidth(Alignment.End) + .wrapContentHeight(), + ) { + if (photoEditState) { + Text("앨범", style = WalkieTypography.SubTitle) + Spacer(Modifier.weight(1f)) + } + Icon( + modifier = Modifier + .clickable { + textVisibleState = when (textVisibleState) { + TextVisibleState.WHITE -> TextVisibleState.BLACK + TextVisibleState.BLACK -> TextVisibleState.HIDE + TextVisibleState.HIDE -> TextVisibleState.WHITE + } } - } - .size(48.dp) - .clip(CircleShape) - .padding(12.dp), - painter = painterResource(id = R.drawable.ic_timer), - contentDescription = "textVisible", - tint = WalkieColor.GrayDefault, - ) - Icon( - modifier = Modifier - .clickable { - photoEditState = photoEditState.not() - } - .size(48.dp) - .clip(CircleShape) - .padding(12.dp), - painter = painterResource(id = R.drawable.ic_gallery), - contentDescription = "gallery", - tint = WalkieColor.GrayDefault, - ) - } + .size(48.dp) + .clip(CircleShape) + .padding(12.dp), + painter = painterResource(id = R.drawable.ic_timer), + contentDescription = "textVisible", + tint = WalkieColor.GrayDefault, + ) + Icon( + modifier = Modifier + .clickable { + photoEditState = photoEditState.not() + } + .size(48.dp) + .clip(CircleShape) + .padding(12.dp), + painter = painterResource(id = R.drawable.ic_gallery), + contentDescription = "gallery", + tint = WalkieColor.GrayDefault, + ) + } - val focusManager = LocalFocusManager.current + val focusManager = LocalFocusManager.current - if (photoEditState) { - GalleryGrid( - column = 3, - onImageSelected = { uri -> - runningHistoryState = runningHistoryState.copy(bitmap = uri.toString()) - }, - onPermissionDismiss = { - photoEditState = false - } - ) - } else { - BasicTextField( - keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }), - keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Done), - modifier = Modifier - .padding(horizontal = 20.dp) - .fillMaxWidth() - .height(92.dp) - .background(Color.White) - .border(1.dp, WalkieColor.GrayDefault, RoundedCornerShape(12.dp)) - .padding(8.dp), - value = text, - onValueChange = { - text = it - }, - singleLine = false, - cursorBrush = SolidColor(MaterialTheme.colorScheme.primary), - ) + if (photoEditState) { + GalleryGrid( + column = 3, + onImageSelected = { uri -> + runningHistoryState = runningHistoryState.copy(bitmap = uri.toString()) + }, + onPermissionDismiss = { + photoEditState = false + } + ) + } else { + BasicTextField( + keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }), + keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Done), + modifier = Modifier + .padding(horizontal = 20.dp) + .fillMaxWidth() + .height(92.dp) + .background(Color.White) + .border(1.dp, WalkieColor.GrayDefault, RoundedCornerShape(12.dp)) + .padding(8.dp), + value = text, + onValueChange = { + text = it + }, + singleLine = false, + cursorBrush = SolidColor(MaterialTheme.colorScheme.primary), + ) + } } }