Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
package com.poti.android.core.designsystem.component.modal

import androidx.annotation.DrawableRes
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.poti.android.R
import com.poti.android.core.designsystem.component.button.ModalButtonType
import com.poti.android.core.designsystem.component.button.PotiModalButton
import com.poti.android.core.designsystem.theme.PotiTheme

/**
* 라지 모달 컴포넌트입니다. 기본 모달 컴포넌트를 래핑해, 디자인 요구사항에 따른 기본 레이아웃을 제공합니다.
*
* @param onDismissRequest 모달을 닫는 콜백입니다.
* @param title "큰 내용"에 해당하는 텍스트입니다.
* @param text "작은 내용"에 해당하는 텍스트입니다.
* @param btnText Main 버튼 텍스트입니다.
* @param onBtnClick Main 버튼 클릭 콜백입니다.
* @param modifier
* @param subBtnText Sub 버튼 텍스트입니다. lg-1일 때 사용합니다.
* @param onSubBtnClick Sub 버튼 클릭 콜백입니다. lg-1일 때 사용합니다.
* @param image 이미지 에셋 아이디입니다. lg-2일 때 사용합니다.
* @param dismissOnBackPress 시스템 뒤로가기 시 모달을 닫는 여부입니다. 기본값 true입니다.
* @param dismissOnClickOutside 모달 바깥 영역 터치 시 모달을 닫는 여부입니다. 기본값 true입니다.
* @param content 텍스트~버튼 사이 공간에 배치됩니다. lg-1일 때 사용합니다.
*
* @author
* @sample PotiLarge1Preview
*/
@Composable
fun PotiLargeModal(
onDismissRequest: () -> Unit,
title: String,
text: String,
btnText: String,
onBtnClick: () -> Unit,
modifier: Modifier = Modifier,
subBtnText: String? = null,
onSubBtnClick: (() -> Unit)? = null,
@DrawableRes image: Int? = null,
dismissOnBackPress: Boolean = true,
dismissOnClickOutside: Boolean = true,
content: (@Composable ColumnScope.() -> Unit)? = null,
) {
PotiModal(
onDismissRequest = onDismissRequest,
modifier = modifier,
dismissOnBackPress = dismissOnBackPress,
dismissOnClickOutside = dismissOnClickOutside,
) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: 이것두!!

.padding(top = 36.dp, bottom = 12.dp),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: 버튼 하나일 때는 패딩 16.dp 입니당

horizontalAlignment = Alignment.CenterHorizontally,
) {
Text(
text = title,
modifier = Modifier
.padding(bottom = 8.dp),
color = PotiTheme.colors.black,
style = PotiTheme.typography.title18sb,
)

Text(
text = text,
color = PotiTheme.colors.gray800,
style = PotiTheme.typography.body14m,
)

content?.invoke(this)

image?.let {
Image(
painter = painterResource(id = it),
contentDescription = null,
modifier = Modifier
.size(180.dp)
.padding(vertical = 24.dp),
contentScale = ContentScale.Crop,
)
}

Column {
PotiModalButton(
text = btnText,
onClick = onBtnClick,
modifier = Modifier.fillMaxWidth(),
type = ModalButtonType.MAIN,
)

if (subBtnText != null && onSubBtnClick != null) {
PotiModalButton(
text = subBtnText,
onClick = onSubBtnClick,
modifier = Modifier.fillMaxWidth(),
type = ModalButtonType.SUB_2,
)
}
Comment on lines +112 to +119
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

find . -type f -name "PotiLargeModal.kt" | head -5

Repository: team-poti/POTI-ANDROID

Length of output: 154


🏁 Script executed:

find . -type f -name "*.kt" -path "*designsystem*" | grep -i modal

Repository: team-poti/POTI-ANDROID

Length of output: 418


🏁 Script executed:

# Search for PotiModalButton definition
rg -n "fun PotiModalButton" --type=kt -A 5

Repository: team-poti/POTI-ANDROID

Length of output: 92


🏁 Script executed:

cat -n ./app/src/main/java/com/poti/android/core/designsystem/component/modal/PotiLargeModal.kt | sed -n '100,130p'

Repository: team-poti/POTI-ANDROID

Length of output: 1104


🏁 Script executed:

cat -n ./app/src/main/java/com/poti/android/core/designsystem/component/button/PotiModalButton.kt | head -50

Repository: team-poti/POTI-ANDROID

Length of output: 2419


🏁 Script executed:

# Get full view of PotiModalButton signature
cat ./app/src/main/java/com/poti/android/core/designsystem/component/button/PotiModalButton.kt | head -100

Repository: team-poti/POTI-ANDROID

Length of output: 3303


🏁 Script executed:

# Read full PotiLargeModal.kt to find function signature and parameter types
cat -n ./app/src/main/java/com/poti/android/core/designsystem/component/modal/PotiLargeModal.kt | head -80

Repository: team-poti/POTI-ANDROID

Length of output: 3734


🏁 Script executed:

# Check if there are any compilation issues or error reports in the codebase
find . -name "*.log" -o -name "build-log*" 2>/dev/null | head -5

Repository: team-poti/POTI-ANDROID

Length of output: 48


🏁 Script executed:

# Search for similar patterns with hasSubBtn or sub button handling
rg "hasSubBtn" --type-list | head -20

Repository: team-poti/POTI-ANDROID

Length of output: 455


🏁 Script executed:

# Look for other modal files that might show correct pattern
cat -n ./app/src/main/java/com/poti/android/core/designsystem/component/modal/PotiSmallModal.kt | head -80

Repository: team-poti/POTI-ANDROID

Length of output: 3679


🏁 Script executed:

# Search for actual usage patterns of PotiLargeModal to see if code compiles
rg "PotiLargeModal" -A 8 -B 2 --no-heading

Repository: team-poti/POTI-ANDROID

Length of output: 3799


🏁 Script executed:

# Check if there are gradle build files that might show compilation settings
find . -name "build.gradle.kts" -o -name "build.gradle" | head -5

Repository: team-poti/POTI-ANDROID

Length of output: 107


🏁 Script executed:

# Look at how parameters are passed when calling PotiLargeModal
rg "PotiLargeModal\(" -A 10 | head -50

Repository: team-poti/POTI-ANDROID

Length of output: 3728


nullable 타입을 non-null 파라미터에 전달하고 있습니다.

hasSubBtn 변수로 null 체크를 했지만, Kotlin의 스마트 캐스트는 직접 null 검사한 변수에만 적용됩니다. 별도 boolean 변수 검사에서는 스마트 캐스트가 동작하지 않으므로, subBtnTextString?로, onSubBtnClick(() -> Unit)?로 유지됩니다. 그런데 PotiModalButton은 각각 non-null String() -> Unit을 요구하므로 타입 불일치가 발생합니다.

아래 중 하나로 수정해주세요:

  1. 직접 null 검사로 스마트 캐스트 활성화:
if (subBtnText != null && onSubBtnClick != null) {
    PotiModalButton(
        text = subBtnText,
        onClick = onSubBtnClick,
        modifier = Modifier.fillMaxWidth(),
        type = ModalButtonType.SUB_2,
    )
}
  1. Non-null assertion (권장하지 않음):
if (hasSubBtn) {
    PotiModalButton(
        text = subBtnText!!,
        onClick = onSubBtnClick!!,
        modifier = Modifier.fillMaxWidth(),
        type = ModalButtonType.SUB_2,
    )
}
🤖 Prompt for AI Agents
In
@app/src/main/java/com/poti/android/core/designsystem/component/modal/PotiLargeModal.kt
around lines 112 - 119, The code passes nullable subBtnText and onSubBtnClick
into PotiModalButton even though it requires non-null parameters because the
smart cast on hasSubBtn doesn't apply; update the guard to directly check the
nullable variables (e.g., if (subBtnText != null && onSubBtnClick != null) {
PotiModalButton(text = subBtnText, onClick = onSubBtnClick, modifier =
Modifier.fillMaxWidth(), type = ModalButtonType.SUB_2) }) so the compiler can
smart-cast them to non-null, referencing the variables subBtnText,
onSubBtnClick, the boolean hasSubBtn, and the PotiModalButton invocation in
PotiLargeModal.kt.

}
}
}
}

@Preview
@Composable
private fun PotiLarge1Preview() {
PotiTheme {
PotiLargeModal(
onDismissRequest = {},
title = "큰 내용",
text = "작은 내용",
btnText = "확인",
onBtnClick = {},
modifier = Modifier
.padding(horizontal = 32.dp),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: 이거 large 모달일 경우 옆에 패딩 36.dp 고 small 모달일 경우는 32.dp 인데 지금 모달 나눠서 만들었으니까 컴포넌트에 고정시키는게 나을 것 같아요

subBtnText = "넘어갈래요",
onSubBtnClick = {},
) {
Box(
modifier = Modifier
.height(184.dp),
)
}
}
}

@Preview
@Composable
private fun PotiLarge2Preview() {
PotiTheme {
PotiLargeModal(
onDismissRequest = {},
title = "큰 내용",
text = "작은 내용",
btnText = "확인",
onBtnClick = {},
modifier = Modifier
.padding(horizontal = 32.dp),
image = R.drawable.ic_launcher_background,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package com.poti.android.core.designsystem.component.modal

import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import androidx.compose.ui.window.DialogWindowProvider
import com.poti.android.core.designsystem.component.button.PotiFloatingButton
import com.poti.android.core.designsystem.component.button.PotiModalButton
import com.poti.android.core.designsystem.theme.PotiTheme

/**
* 기본 모달 컴포넌트입니다.
*
* @param onDismissRequest 모달을 닫는 콜백입니다.
* @param modifier
* @param dismissOnBackPress 시스템 뒤로가기 시 모달을 닫는 여부입니다. 기본값 true입니다.
* @param dismissOnClickOutside 모달 바깥 영역 터치 시 모달을 닫는 여부입니다. 기본값 true입니다.
* @param content
*
* @author 도연
* @sample PotiModalPreview
*/
@Composable
internal fun PotiModal(
onDismissRequest: () -> Unit,
modifier: Modifier = Modifier,
dismissOnBackPress: Boolean = true,
dismissOnClickOutside: Boolean = true,
content: @Composable () -> Unit,
) {
val dialogProperties = remember(dismissOnBackPress, dismissOnClickOutside) {
DialogProperties(
dismissOnBackPress = dismissOnBackPress,
dismissOnClickOutside = dismissOnClickOutside,
usePlatformDefaultWidth = false,
)
}

Dialog(
onDismissRequest = onDismissRequest,
properties = dialogProperties,
) {
val dialogWindow = (LocalView.current.parent as DialogWindowProvider).window

dialogWindow.setDimAmount(0.4f)

dialogWindow.decorView.setBackgroundColor(
Color.parseColor("#000000"),
)

dialogWindow.setBackgroundDrawable(
ColorDrawable(Color.TRANSPARENT),
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: 이 코드는 리컴포지션 때마다 계속 실행되기 때문에 컴포저블 안에 그냥 쓰면 안 돼요. SideEffect 블록으로 감싸서 사용해주세요!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: 이 코드는 왜 사용한 건가요??

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

안써주면 Surface 모서리 깎은 부분/패딩이 검정색이 되더라구욤,,
image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

어라랏 저는 안 뜨는데??

SideEffect {
     dialogWindow?.setDimAmount(0.4f)
}

이렇게 해도 뒤에 배경 안 나와요

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        dialogWindow.decorView.setBackgroundColor(
            Color.parseColor("#000000"),
        )

검은 배경 이 코드 때문이엇음! 고로 필요없는 코드가 맞앗슴다


Surface(
modifier = modifier,
shape = RoundedCornerShape(12.dp),
color = PotiTheme.colors.white,
) {
content()
}
}
}

@Preview
@Composable
private fun PotiModalPreview() {
var showModal by remember { mutableStateOf(false) }

PotiTheme {
if (showModal) {
PotiModal(
modifier = Modifier.padding(10.dp),
onDismissRequest = { showModal = false },
) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(all = 40.dp),
verticalArrangement = Arrangement.spacedBy(20.dp),
) {
Text(
text = "거래는 어땠나요?\n별점으로 간단히 평가해주세요",
modifier = Modifier
.padding(all = 20.dp)
.fillMaxWidth(),
)

PotiModalButton(
text = "버튼",
onClick = {},
)
}
}
}

Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center,
) {
PotiFloatingButton(
onClick = { showModal = true },
)
}
}
}
Loading