Skip to content

Commit

Permalink
[feat] #151 프로필 수정 중간단계 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
cacaocoffee committed Jan 13, 2025
1 parent d271ba4 commit aba92b7
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ fun ProfileEditRoute(
showShouldShowRationaleDialog = viewModel::showShouldShowRationaleDialog,
hideExitUploadDialog = viewModel::hideUploadDialog,
updateUserProfile = viewModel::updateUserProfile,
showSelectImgDialog = viewModel:: showImageDialog,
hideImageDialog = viewModel:: hideImageDialog
)
}

Expand All @@ -123,6 +125,8 @@ fun ProfileScreen(
showShouldShowRationaleDialog: () -> Unit = {},
hideExitUploadDialog: () -> Unit = {},
updateUserProfile: () -> Unit = {},
showSelectImgDialog: () -> Unit = {},
hideImageDialog : () -> Unit = {}
) {
val context = LocalContext.current

Expand Down Expand Up @@ -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,
) {
Expand Down Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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_]+$")
Expand Down

0 comments on commit aba92b7

Please sign in to comment.