Skip to content

Commit

Permalink
feat: 업로드 버튼 로딩
Browse files Browse the repository at this point in the history
  • Loading branch information
eshc123 committed Dec 20, 2024
1 parent 47044e0 commit b00001d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ fun VerificationPreviewRoute(
showProgress = true
}
UploadEvent.Success -> {
showProgress = false
onUploadSuccess()
}
UploadEvent.Error -> {
Expand All @@ -99,18 +98,16 @@ fun VerificationPreviewRoute(
}

VerificationPreviewScreen(
isUploading = showProgress,
onClickClose = onClickClose,
uiState = uiState,
onClickUpload = viewModel::uploadImage
)

if (showProgress) {
ProgressBar()
}
}

@Composable
fun VerificationPreviewScreen(
isUploading: Boolean,
onClickClose: () -> Unit,
uiState: VerificationPreviewUiState,
onClickUpload: (File) -> Unit
Expand Down Expand Up @@ -147,30 +144,6 @@ fun VerificationPreviewScreen(
contentScale = ContentScale.Fit,
filterQuality = FilterQuality.None
)



MissionMateButton(
modifier = Modifier
.align(Alignment.BottomCenter)
.padding(horizontal = 24.dp, vertical = 36.dp)
.fillMaxWidth()
.navigationBarsPadding(),
buttonType = MissionMateButtonType.ACTIVE,
onClick = {
val file = ImageCompressor.getCompressedImage(
context,
uiState.imageUrl.toUri()
)
onClickUpload(file)
}
) {
Text(
text = stringResource(id = R.string.upload),
style = MissionMateTypography.body_xl_bold,
color = ColorWhite_FFFFFFFF
)
}
}
if (isVisibleSpacer) {
Spacer(
Expand Down Expand Up @@ -245,6 +218,7 @@ fun VerificationPreviewScreen(
UploadButton(
context = context,
filePath = uiState.imageUrl.toUri(),
isUploading = isUploading,
onClickUpload = onClickUpload
)
}
Expand All @@ -257,6 +231,7 @@ fun VerificationPreviewScreen(
fun BoxScope.UploadButton(
context: Context,
filePath: Uri,
isUploading: Boolean,
onClickUpload: (File) -> Unit
) {
val multipleEventsCutter = remember { MultipleEventsCutter.get() }
Expand All @@ -266,19 +241,27 @@ fun BoxScope.UploadButton(
.padding(horizontal = 24.dp, vertical = 36.dp)
.fillMaxWidth()
.navigationBarsPadding(),
buttonType = MissionMateButtonType.ACTIVE,
buttonType = if(isUploading) MissionMateButtonType.DISABLED else MissionMateButtonType.ACTIVE,
onClick = {
multipleEventsCutter.processEvent {
val file = ImageCompressor.getCompressedImage(context, filePath)
onClickUpload(file)
}
}
) {
Text(
text = stringResource(id = R.string.upload),
style = MissionMateTypography.body_xl_bold,
color = ColorWhite_FFFFFFFF
)
if(isUploading){
CircularProgressIndicator(
modifier = Modifier.size(24.dp),
color = ColorWhite_FFFFFFFF,
strokeWidth = 3.dp
)
}else {
Text(
text = stringResource(id = R.string.upload),
style = MissionMateTypography.body_lg_bold,
color = ColorWhite_FFFFFFFF
)
}
}
}

Expand Down Expand Up @@ -317,6 +300,7 @@ fun ProgressBar() {
@Composable
fun VerificationPreviewScreenPreview() {
VerificationPreviewScreen(
isUploading = false,
onClickClose = {},
uiState = VerificationPreviewUiState.Success(
characterUiModel = CharacterUiModel.RABBIT,
Expand All @@ -331,6 +315,7 @@ fun VerificationPreviewScreenPreview() {
@Composable
fun VerificationPreviewScreenLoadingPreview() {
VerificationPreviewScreen(
isUploading = false,
onClickClose = {},
uiState = VerificationPreviewUiState.Loading,
onClickUpload = {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.goalpanzi.mission_mate.feature.board.screen

import android.util.Log
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
Expand Down Expand Up @@ -87,3 +88,4 @@ sealed interface UploadEvent {
data object Success : UploadEvent
data object Error : UploadEvent
}

0 comments on commit b00001d

Please sign in to comment.