From aba92b7d7919c40cea7255d0e4a358197b9d8133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AA=85=EC=84=9D?= Date: Mon, 13 Jan 2025 22:58:34 +0900 Subject: [PATCH] =?UTF-8?q?[feat]=20#151=20=ED=94=84=EB=A1=9C=ED=95=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EC=A4=91=EA=B0=84=EB=8B=A8=EA=B3=84=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../setting/profileedit/ProfileEditRoute.kt | 56 +++++++++++++------ .../setting/profileedit/ProfileEditState.kt | 1 + .../profileedit/ProfileEditViewModel.kt | 21 ++++++- 3 files changed, 61 insertions(+), 17 deletions(-) diff --git a/feature/setting/src/main/java/com/record/setting/profileedit/ProfileEditRoute.kt b/feature/setting/src/main/java/com/record/setting/profileedit/ProfileEditRoute.kt index a760eee1..ae7705da 100644 --- a/feature/setting/src/main/java/com/record/setting/profileedit/ProfileEditRoute.kt +++ b/feature/setting/src/main/java/com/record/setting/profileedit/ProfileEditRoute.kt @@ -103,6 +103,8 @@ fun ProfileEditRoute( showShouldShowRationaleDialog = viewModel::showShouldShowRationaleDialog, hideExitUploadDialog = viewModel::hideUploadDialog, updateUserProfile = viewModel::updateUserProfile, + showSelectImgDialog = viewModel:: showImageDialog, + hideImageDialog = viewModel:: hideImageDialog ) } @@ -123,6 +125,8 @@ fun ProfileScreen( showShouldShowRationaleDialog: () -> Unit = {}, hideExitUploadDialog: () -> Unit = {}, updateUserProfile: () -> Unit = {}, + showSelectImgDialog: () -> Unit = {}, + hideImageDialog : () -> Unit = {} ) { val context = LocalContext.current @@ -256,22 +260,7 @@ fun ProfileScreen( .fillMaxWidth() .aspectRatio(1f) .customClickable { - if (cameraPermissionState.status.isGranted) { - isGranted = true - isSelectedImageSheetOpen() - return@customClickable - } - if (cameraPermissionState.status.shouldShowRationale) { - showShouldShowRationaleDialog() - return@customClickable - } - scope.launch { - if (!permissionState.value) { - requestPermissionLauncher.launch( - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) Manifest.permission.READ_MEDIA_VIDEO else Manifest.permission.READ_EXTERNAL_STORAGE, - ) - } - } + showSelectImgDialog() }, contentAlignment = Alignment.Center, ) { @@ -358,6 +347,41 @@ fun ProfileScreen( }, ) } + if(state.selectInfo.showDialog){ + RecordyDialog( + title = state.selectInfo.title, + subTitle = state.selectInfo.subTitle, + negativeButtonLabel = state.selectInfo.negativeButtonLabel, + positiveButtonLabel = state.selectInfo.positiveButtonLabel, + onDismissRequest = { + if (cameraPermissionState.status.isGranted) { + isGranted = true + hideImageDialog() + return@RecordyDialog + } + if (cameraPermissionState.status.shouldShowRationale) { + showShouldShowRationaleDialog() + return@RecordyDialog + } + scope.launch { + if (!permissionState.value) { + requestPermissionLauncher.launch( + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) Manifest.permission.READ_MEDIA_VIDEO else Manifest.permission.READ_EXTERNAL_STORAGE, + ) + } + } + }, + onPositiveButtonClick = { + if (cameraPermissionState.status.shouldShowRationale) { + openAppSettings(context) + return@RecordyDialog + } + hideImageDialog() + isSelectedImageSheetOpen() + }, + ) + + } SelectedImageBottomSheet( sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true), diff --git a/feature/setting/src/main/java/com/record/setting/profileedit/ProfileEditState.kt b/feature/setting/src/main/java/com/record/setting/profileedit/ProfileEditState.kt index 92cb22a9..605a4b33 100644 --- a/feature/setting/src/main/java/com/record/setting/profileedit/ProfileEditState.kt +++ b/feature/setting/src/main/java/com/record/setting/profileedit/ProfileEditState.kt @@ -21,6 +21,7 @@ data class ProfileEditState( val nicknameValidate: ValidateResult = ValidateResult.Inputting, val placeHolder: String = "", val btnEnable: Boolean = false, + val selectInfo: AlertInfo = AlertInfo(), ) : UiState sealed interface ProfileEditSideEffect : SideEffect { diff --git a/feature/setting/src/main/java/com/record/setting/profileedit/ProfileEditViewModel.kt b/feature/setting/src/main/java/com/record/setting/profileedit/ProfileEditViewModel.kt index 5c279be2..4a810e3b 100644 --- a/feature/setting/src/main/java/com/record/setting/profileedit/ProfileEditViewModel.kt +++ b/feature/setting/src/main/java/com/record/setting/profileedit/ProfileEditViewModel.kt @@ -131,6 +131,25 @@ class ProfileEditViewModel @Inject constructor( ) } + fun showImageDialog() = intent { + copy( + selectInfo = AlertInfo( + showDialog = true, + title = "", + subTitle = "영상 업로드를 할 사진을 골라주세요", + negativeButtonLabel = "기본 사진 선택", + positiveButtonLabel = "앨범에서 선택", + ), + ) + } + + fun hideImageDialog() = intent { + copy( + selectInfo = selectInfo.copy(showDialog = false), + btnEnable = true + ) + } + fun showIsSelectedImageSheetOpen() = intent { copy(isSelectedImageSheetOpen = true) } @@ -139,7 +158,7 @@ class ProfileEditViewModel @Inject constructor( copy(isSelectedImageSheetOpen = false) } - private fun nickNameRegex(nickname: String): Boolean = NICKNAME_PATTERN.matches(nickname) + private fun nickNameRegex(nickname: String): Boolean = NICKNAME_PATTERN.matches(nickname); companion object { val NICKNAME_PATTERN = Regex("^[ㄱ-ㅎ|가-힣ㅏ-ㅣ0-9_]+$")