-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[개선] 공통 모듈에서 사용할 수 있는 UI 파일 분리 #326
Closed
Closed
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cf912ad
refactor: 모서리가 둥근 이미지를 RoundedImage 컴포넌트로 분리
tmdgh1592 f049c2f
refactor: 아이콘 버튼을 RoundedToggleButton 컴포넌트로 분리
tmdgh1592 a8f20f7
refactor: RoundedImage 함수가 Modifier를 전달받지 않도록 변경
tmdgh1592 b406031
refactor: RoundedImage 함수에 border 인자 추가
tmdgh1592 0a824a2
refactor: RoundedImage가 size를 전달받도록 변경
tmdgh1592 1e07d29
refactor: RoundedImage, IconToggleButton 제거
tmdgh1592 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...system/src/main/java/com/droidknights/app/core/designsystem/component/IconToggleButton.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.droidknights.app.core.designsystem.component | ||
|
||
import androidx.annotation.DrawableRes | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconToggleButton | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.painterResource | ||
|
||
@Composable | ||
fun IconToggleButton( | ||
modifier: Modifier = Modifier, | ||
isChecked: Boolean, | ||
onCheckedChange: (Boolean) -> Unit, | ||
@DrawableRes checkedImageRes: Int, | ||
@DrawableRes uncheckedImageRes: Int | ||
) { | ||
IconToggleButton( | ||
modifier = modifier, | ||
checked = isChecked, | ||
onCheckedChange = onCheckedChange, | ||
) { | ||
Icon( | ||
painter = if (isChecked) { | ||
painterResource(id = checkedImageRes) | ||
} else { | ||
painterResource(id = uncheckedImageRes) | ||
}, | ||
contentDescription = null | ||
) | ||
} | ||
} | ||
59 changes: 59 additions & 0 deletions
59
...signsystem/src/main/java/com/droidknights/app/core/designsystem/component/RoundedImage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.droidknights.app.core.designsystem.component | ||
|
||
import androidx.compose.foundation.BorderStroke | ||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.layout.aspectRatio | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
|
||
@Composable | ||
fun RoundedImage( | ||
imageRes: Int, | ||
onClick: () -> Unit = {}, | ||
size: Dp? = null, | ||
roundSize: Dp = 16.dp, | ||
border: BorderStroke? = null, | ||
) { | ||
RoundedImage( | ||
imageRes = imageRes, | ||
onClick = onClick, | ||
width = size, | ||
height = size, | ||
roundSize = roundSize, | ||
border = border, | ||
) | ||
} | ||
|
||
@Composable | ||
fun RoundedImage( | ||
imageRes: Int, | ||
onClick: () -> Unit = {}, | ||
width: Dp? = null, | ||
height: Dp? = null, | ||
roundSize: Dp = 16.dp, | ||
border: BorderStroke? = null, | ||
) { | ||
val modifier = if (width != null && height != null) { | ||
Modifier.size(width, height) | ||
} else { | ||
Modifier.aspectRatio(1f) | ||
} | ||
|
||
Surface( | ||
onClick = onClick, | ||
shape = RoundedCornerShape(roundSize), | ||
border = border, | ||
modifier = modifier | ||
) { | ||
Image( | ||
painter = painterResource(id = imageRes), | ||
contentDescription = null | ||
) | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. width가 null이고 rounded 사이즈가 있는 상태인데 함수가 2개일 필요가 있나요? 나머지 내용은 모두 동일한 상태라서 그리고 이 버튼은 ImageButton을 뜻하는것 같은데 ... 용도와 타이틀도 안맞는것 같네요. 아마 이런 형태가 main 쪽에만 있었는데 공통화 하시면서 그대로 이동한것 같은데. 함수명으로는 click 가능한 이미지 인지이해가 어렵네요. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
마지막 줄 엔터가 저희 코드 컨벤션입니다.