From 5ec9b6f1c5f271fb3235024c325982bb0bf11535 Mon Sep 17 00:00:00 2001 From: Changyeop Lee Date: Sun, 17 Nov 2024 15:15:55 +0900 Subject: [PATCH 1/7] Fix verify loading view on VerificationPreviewScreen. --- .../board/screen/VerificationPreviewScreen.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/VerificationPreviewScreen.kt b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/VerificationPreviewScreen.kt index f87aea4..83acdf4 100644 --- a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/VerificationPreviewScreen.kt +++ b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/VerificationPreviewScreen.kt @@ -3,6 +3,8 @@ package com.goalpanzi.mission_mate.feature.board.screen import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.focusable import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize @@ -217,9 +219,12 @@ fun VerificationPreviewScreen( fun VerificationPreviewLoading() { Box( modifier = Modifier + .fillMaxSize() .background(ColorWhite_FFFFFFFF) .statusBarsPadding() .navigationBarsPadding() + .focusable() + .clickable {} ) { CircularProgressIndicator( modifier = Modifier.align(Alignment.Center) @@ -253,3 +258,13 @@ fun VerificationPreviewScreenPreview() { onClickUpload = {} ) } + +@Preview +@Composable +fun VerificationPreviewScreenLoadingPreview() { + VerificationPreviewScreen( + onClickClose = {}, + uiState = VerificationPreviewUiState.Loading, + onClickUpload = {} + ) +} From ef120d03375d06ad7ca825969f45a257e3e2b64c Mon Sep 17 00:00:00 2001 From: Changyeop Lee Date: Sun, 17 Nov 2024 15:46:50 +0900 Subject: [PATCH 2/7] Fix access token set issue on AuthTokenProvider. --- .../mission_mate/core/data/auth/AuthTokenProvider.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/data/auth/src/main/java/com/goalpanzi/mission_mate/core/data/auth/AuthTokenProvider.kt b/core/data/auth/src/main/java/com/goalpanzi/mission_mate/core/data/auth/AuthTokenProvider.kt index 034d3ce..684170f 100644 --- a/core/data/auth/src/main/java/com/goalpanzi/mission_mate/core/data/auth/AuthTokenProvider.kt +++ b/core/data/auth/src/main/java/com/goalpanzi/mission_mate/core/data/auth/AuthTokenProvider.kt @@ -2,6 +2,7 @@ package com.goalpanzi.mission_mate.core.data.auth import com.goalpanzi.mission_mate.core.datastore.datasource.AuthDataSource import com.goalpanzi.mission_mate.core.network.TokenProvider +import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.firstOrNull import javax.inject.Inject @@ -17,12 +18,10 @@ class AuthTokenProvider @Inject constructor( } override suspend fun setAccessToken(accessToken: String) { - authDataSource.setAccessToken(accessToken) + authDataSource.setAccessToken(accessToken).collect() } override suspend fun setRefreshToken(refreshToken: String) { - authDataSource.setRefreshToken(refreshToken) + authDataSource.setRefreshToken(refreshToken).collect() } - - } From bc4cd794f4fd5f7dc4447d7931a81e9b393f19e2 Mon Sep 17 00:00:00 2001 From: Changyeop Lee Date: Sun, 17 Nov 2024 15:15:55 +0900 Subject: [PATCH 3/7] Fix verify loading view on VerificationPreviewScreen. --- .../board/screen/VerificationPreviewScreen.kt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/VerificationPreviewScreen.kt b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/VerificationPreviewScreen.kt index f87aea4..55baa1d 100644 --- a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/VerificationPreviewScreen.kt +++ b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/VerificationPreviewScreen.kt @@ -3,6 +3,8 @@ package com.goalpanzi.mission_mate.feature.board.screen import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.focusable import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize @@ -217,9 +219,12 @@ fun VerificationPreviewScreen( fun VerificationPreviewLoading() { Box( modifier = Modifier - .background(ColorWhite_FFFFFFFF) + .fillMaxSize() + .background(Color.Transparent) .statusBarsPadding() .navigationBarsPadding() + .focusable() + .clickable {} ) { CircularProgressIndicator( modifier = Modifier.align(Alignment.Center) @@ -253,3 +258,13 @@ fun VerificationPreviewScreenPreview() { onClickUpload = {} ) } + +@Preview +@Composable +fun VerificationPreviewScreenLoadingPreview() { + VerificationPreviewScreen( + onClickClose = {}, + uiState = VerificationPreviewUiState.Loading, + onClickUpload = {} + ) +} From 0c3699151be2d6a54b0181bf9569d27755d2d40f Mon Sep 17 00:00:00 2001 From: Changyeop Lee Date: Sun, 17 Nov 2024 15:46:50 +0900 Subject: [PATCH 4/7] Fix access token set issue on AuthTokenProvider. --- .../mission_mate/core/data/auth/AuthTokenProvider.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/data/auth/src/main/java/com/goalpanzi/mission_mate/core/data/auth/AuthTokenProvider.kt b/core/data/auth/src/main/java/com/goalpanzi/mission_mate/core/data/auth/AuthTokenProvider.kt index 034d3ce..684170f 100644 --- a/core/data/auth/src/main/java/com/goalpanzi/mission_mate/core/data/auth/AuthTokenProvider.kt +++ b/core/data/auth/src/main/java/com/goalpanzi/mission_mate/core/data/auth/AuthTokenProvider.kt @@ -2,6 +2,7 @@ package com.goalpanzi.mission_mate.core.data.auth import com.goalpanzi.mission_mate.core.datastore.datasource.AuthDataSource import com.goalpanzi.mission_mate.core.network.TokenProvider +import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.firstOrNull import javax.inject.Inject @@ -17,12 +18,10 @@ class AuthTokenProvider @Inject constructor( } override suspend fun setAccessToken(accessToken: String) { - authDataSource.setAccessToken(accessToken) + authDataSource.setAccessToken(accessToken).collect() } override suspend fun setRefreshToken(refreshToken: String) { - authDataSource.setRefreshToken(refreshToken) + authDataSource.setRefreshToken(refreshToken).collect() } - - } From 178f1645ac3c23e275762df6549fc3ed117ac538 Mon Sep 17 00:00:00 2001 From: eshc123 <> Date: Sun, 17 Nov 2024 15:52:14 +0900 Subject: [PATCH 5/7] =?UTF-8?q?feature:=20multiple=20=ED=81=B4=EB=A6=AD=20?= =?UTF-8?q?=EB=B0=A9=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/designsystem/ext/Modifier.kt | 25 ++++++++++++++++++- .../designsystem/util/MultipleEventsCutter.kt | 25 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 core/designsystem/src/main/java/com/goalpanzi/mission_mate/core/designsystem/util/MultipleEventsCutter.kt diff --git a/core/designsystem/src/main/java/com/goalpanzi/mission_mate/core/designsystem/ext/Modifier.kt b/core/designsystem/src/main/java/com/goalpanzi/mission_mate/core/designsystem/ext/Modifier.kt index be858e3..aa43a70 100644 --- a/core/designsystem/src/main/java/com/goalpanzi/mission_mate/core/designsystem/ext/Modifier.kt +++ b/core/designsystem/src/main/java/com/goalpanzi/mission_mate/core/designsystem/ext/Modifier.kt @@ -1,9 +1,12 @@ package com.goalpanzi.mission_mate.core.designsystem.ext import android.graphics.BlurMaskFilter +import androidx.compose.foundation.LocalIndication import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier +import androidx.compose.ui.composed import androidx.compose.ui.draw.drawBehind import androidx.compose.ui.geometry.Size import androidx.compose.ui.graphics.Color @@ -11,8 +14,11 @@ import androidx.compose.ui.graphics.Paint import androidx.compose.ui.graphics.Shape import androidx.compose.ui.graphics.drawOutline import androidx.compose.ui.graphics.drawscope.drawIntoCanvas +import androidx.compose.ui.semantics.Role import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp +import com.goalpanzi.mission_mate.core.designsystem.util.MultipleEventsCutter +import com.goalpanzi.mission_mate.core.designsystem.util.get fun Modifier.dropShadow( shape: Shape, @@ -54,4 +60,21 @@ fun Modifier.clickableWithoutRipple( ) ) -} \ No newline at end of file +} + +fun Modifier.clickableSingle( + enabled: Boolean = true, + onClickLabel: String? = null, + role: Role? = null, + onClick: () -> Unit +) = composed { + val multipleEventsCutter = remember { MultipleEventsCutter.get() } + Modifier.clickable( + enabled = enabled, + onClickLabel = onClickLabel, + onClick = { multipleEventsCutter.processEvent { onClick() } }, + role = role, + indication = LocalIndication.current, + interactionSource = remember { MutableInteractionSource() } + ) +} diff --git a/core/designsystem/src/main/java/com/goalpanzi/mission_mate/core/designsystem/util/MultipleEventsCutter.kt b/core/designsystem/src/main/java/com/goalpanzi/mission_mate/core/designsystem/util/MultipleEventsCutter.kt new file mode 100644 index 0000000..15783cf --- /dev/null +++ b/core/designsystem/src/main/java/com/goalpanzi/mission_mate/core/designsystem/util/MultipleEventsCutter.kt @@ -0,0 +1,25 @@ +package com.goalpanzi.mission_mate.core.designsystem.util + + +interface MultipleEventsCutter { + fun processEvent(event: () -> Unit) + + companion object +} + +fun MultipleEventsCutter.Companion.get(): MultipleEventsCutter = + MultipleEventsCutterImpl() + +private class MultipleEventsCutterImpl : MultipleEventsCutter { + private val now: Long + get() = System.currentTimeMillis() + + private var lastEventTimeMs: Long = 0 + + override fun processEvent(event: () -> Unit) { + if (now - lastEventTimeMs >= 300L) { + event.invoke() + } + lastEventTimeMs = now + } +} From ff52af2366bbebde9c892e073614528b574b2a27 Mon Sep 17 00:00:00 2001 From: eshc123 <> Date: Sun, 17 Nov 2024 15:52:25 +0900 Subject: [PATCH 6/7] =?UTF-8?q?feature:=20=EC=82=AC=EC=A7=84=20=EC=97=85?= =?UTF-8?q?=EB=A1=9C=EB=93=9C=20=EB=8B=A4=EC=A4=91=20=ED=81=B4=EB=A6=AD=20?= =?UTF-8?q?=EB=B0=A9=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../board/screen/VerificationPreviewScreen.kt | 63 +++++++++++++------ 1 file changed, 44 insertions(+), 19 deletions(-) diff --git a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/VerificationPreviewScreen.kt b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/VerificationPreviewScreen.kt index 83acdf4..c0d9cdf 100644 --- a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/VerificationPreviewScreen.kt +++ b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/VerificationPreviewScreen.kt @@ -1,11 +1,14 @@ package com.goalpanzi.mission_mate.feature.board.screen +import android.content.Context +import android.net.Uri import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.clickable import androidx.compose.foundation.focusable import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.BoxScope import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth @@ -25,6 +28,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment @@ -52,6 +56,8 @@ import com.goalpanzi.mission_mate.core.designsystem.component.StableImage import com.goalpanzi.mission_mate.core.designsystem.theme.ColorBlack_FF000000 import com.goalpanzi.mission_mate.core.designsystem.theme.ColorWhite_FFFFFFFF import com.goalpanzi.mission_mate.core.designsystem.theme.MissionMateTypography +import com.goalpanzi.mission_mate.core.designsystem.util.MultipleEventsCutter +import com.goalpanzi.mission_mate.core.designsystem.util.get import com.goalpanzi.mission_mate.feature.board.R import com.goalpanzi.mission_mate.feature.board.model.CharacterUiModel import com.goalpanzi.mission_mate.feature.board.util.ImageCompressor @@ -76,10 +82,12 @@ fun VerificationPreviewRoute( UploadEvent.Loading -> { showProgress = true } + UploadEvent.Success -> { showProgress = false onUploadSuccess() } + UploadEvent.Error -> { showProgress = false } @@ -94,7 +102,7 @@ fun VerificationPreviewRoute( ) if (showProgress) { - ProgressBar() + ProgressBar() } } @@ -190,31 +198,48 @@ fun VerificationPreviewScreen( ) } } - - 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) + UploadButton( + context = context, + filePath = uiState.imageUrl.toUri(), + onClickUpload = { + } - ) { - Text( - text = stringResource(id = R.string.upload), - style = MissionMateTypography.body_xl_bold, - color = ColorWhite_FFFFFFFF - ) - } + ) } } } } } +@Composable +fun BoxScope.UploadButton( + context: Context, + filePath: Uri, + onClickUpload: (File) -> Unit +) { + val multipleEventsCutter = remember { MultipleEventsCutter.get() } + MissionMateButton( + modifier = Modifier + .align(Alignment.BottomCenter) + .padding(horizontal = 24.dp, vertical = 36.dp) + .fillMaxWidth() + .navigationBarsPadding(), + buttonType = 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 + ) + } +} + @Composable fun VerificationPreviewLoading() { Box( From d5c1cf0da96b769e385f35f15a61a1f04fa0270b Mon Sep 17 00:00:00 2001 From: eshc123 <> Date: Sun, 17 Nov 2024 15:54:20 +0900 Subject: [PATCH 7/7] =?UTF-8?q?feature:=20=EC=82=AC=EC=A7=84=20=EC=97=85?= =?UTF-8?q?=EB=A1=9C=EB=93=9C=20=EB=8B=A4=EC=A4=91=20=ED=81=B4=EB=A6=AD=20?= =?UTF-8?q?=EB=B0=A9=EC=A7=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/board/screen/VerificationPreviewScreen.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/VerificationPreviewScreen.kt b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/VerificationPreviewScreen.kt index 6e53f10..95b4480 100644 --- a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/VerificationPreviewScreen.kt +++ b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/VerificationPreviewScreen.kt @@ -28,6 +28,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment