-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Feature/#7] time&seats screen 공통 컴포넌트 & seats 스크린 모달 구현 #8
Closed
Closed
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
37be065
UI #1 : Color.kt and Theme.kt restore
tunaunnie af635b1
UI #7 : develop common component
tunaunnie 30ec1d3
Merge branch 'develop' of https://github.com/SOPT-all/35-COLLABORATIO…
tunaunnie 53de586
UI #7 : remove unnecessary imports
tunaunnie fa672ed
UI #7 : noRippleClick() apply
tunaunnie 35b74d2
UI #7 : modifier add
tunaunnie fb6b640
UI #7 : apply typography
tunaunnie 042476f
[feature] #7 SeatScreenModal1 구현
tunaunnie 451e48f
move #7 : seats 폴더로 구현 내용 옮김
tunaunnie 964d412
feature #7 : fix datetime type
tunaunnie 50a85ee
chore #7: rm imports
tunaunnie 286aefc
chore #7: rm imports
tunaunnie 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
142 changes: 142 additions & 0 deletions
142
app/src/main/java/org/sopt/cgv/core/designsystem/component/button/ModalButton.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,142 @@ | ||
package org.sopt.cgv.core.designsystem.component.button | ||
|
||
import android.R | ||
import android.widget.Button | ||
import androidx.compose.foundation.BorderStroke | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.border | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.ComposeCompilerApi | ||
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.draw.clip | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
import org.sopt.cgv.core.designsystem.theme.Gray200 | ||
import org.sopt.cgv.core.designsystem.theme.PrimaryRed400 | ||
import org.sopt.cgv.core.designsystem.theme.White | ||
|
||
data class ButtonStyle( | ||
val backgroundColor: Color, | ||
val border: BorderStroke?, | ||
val textColor: Color, | ||
) | ||
|
||
@Composable | ||
fun getButtonStyle(buttonType: String): ButtonStyle { | ||
return remember(buttonType) { | ||
when (buttonType) { | ||
"Choice" -> ButtonStyle( | ||
backgroundColor = PrimaryRed400, | ||
border = null, | ||
textColor = White | ||
) | ||
"Back" -> ButtonStyle( | ||
backgroundColor = White, | ||
border = BorderStroke(1.dp, PrimaryRed400), | ||
textColor = PrimaryRed400 | ||
) | ||
else -> ButtonStyle( | ||
backgroundColor = PrimaryRed400, | ||
border = null, | ||
textColor = White | ||
) | ||
} | ||
} | ||
|
||
} | ||
|
||
@Composable | ||
fun ModalButton( | ||
buttonType: String, //선택 버튼인 경우 Choice, 뒤로가기인 경우 Back | ||
initialActivation: Boolean, // 처음부터 활성화 상태면 true, 활성화 조건 필요하면 false | ||
content: String, | ||
length: String, //long, half로 사용 | ||
){ | ||
|
||
var isActivated by remember { mutableStateOf(initialActivation) } | ||
val buttonStyle = getButtonStyle(buttonType) | ||
|
||
val (buttonWidth, buttonHeight) = remember(length) { | ||
when (length) { | ||
"long" -> Pair(324.dp, 54.dp) | ||
"half" -> Pair(156.dp, 54.dp) | ||
else -> Pair(324.dp, 54.dp) | ||
} | ||
} | ||
Comment on lines
+74
to
+80
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. 버튼 크기를 고정 dp로 주는 것이 아닌, 텍스트를 기준으로 horizontalPadding, verticalPadding을 주신후 나중에 스크린에서 전체 화면에서의 패딩을 조절하면 기기 대응에도 더 좋을 거 같습니당 |
||
|
||
Box( | ||
modifier = Modifier | ||
.size(width = buttonWidth, height = buttonHeight) | ||
.clip(RoundedCornerShape(12.dp)) | ||
.background(buttonStyle.backgroundColor) | ||
.then( | ||
if (buttonStyle.border != null) | ||
Modifier.border(buttonStyle.border, RoundedCornerShape(8.dp)) | ||
else | ||
Modifier | ||
) | ||
) { | ||
Row( | ||
modifier = Modifier.fillMaxSize(), | ||
verticalAlignment = Alignment.CenterVertically, | ||
horizontalArrangement = Arrangement.SpaceEvenly | ||
){ | ||
Text( | ||
text = content, | ||
color = buttonStyle.textColor | ||
) | ||
|
||
} | ||
} | ||
} | ||
|
||
|
||
|
||
@Preview | ||
@Composable | ||
fun ButtonPreview(){ | ||
Column( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(16.dp), | ||
verticalArrangement = Arrangement.spacedBy(16.dp), | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
ModalButton( | ||
buttonType = "Choice", | ||
initialActivation = true, | ||
content = "좌석선택", | ||
length = "long" | ||
) | ||
ModalButton( | ||
buttonType = "Back", | ||
initialActivation = false, | ||
content = "뒤로가기", | ||
length = "half" | ||
) | ||
ModalButton( | ||
buttonType = "Choice", | ||
initialActivation = true, | ||
content = "확인", | ||
length = "half" | ||
) | ||
} | ||
} |
122 changes: 122 additions & 0 deletions
122
app/src/main/java/org/sopt/cgv/core/designsystem/component/button/Stepper.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,122 @@ | ||
package org.sopt.cgv.core.designsystem.component.button | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
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.foundation.shape.CircleShape | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import org.sopt.cgv.R | ||
import org.sopt.cgv.core.designsystem.theme.Gray100 | ||
import org.sopt.cgv.core.designsystem.theme.Gray700 | ||
import org.sopt.cgv.core.designsystem.theme.Gray800 | ||
|
||
@Composable | ||
fun Stepper( | ||
modifier: Modifier = Modifier, | ||
initialValue: Int = 0, | ||
onValueChange: (Int) -> Unit | ||
) { | ||
var currentValue by remember { mutableStateOf(initialValue) } | ||
|
||
Row( | ||
modifier = modifier | ||
.size(height = 36.dp, width = 100.dp) | ||
.clip(RoundedCornerShape(8.dp)) | ||
.background(Gray100), | ||
) { | ||
Row( | ||
modifier = modifier | ||
.fillMaxSize() | ||
.padding(horizontal = 8.dp, vertical = 4.dp), | ||
verticalAlignment = Alignment.CenterVertically, | ||
horizontalArrangement = Arrangement.SpaceAround, | ||
){ | ||
// - 버튼 | ||
Box( | ||
modifier = Modifier | ||
.clickable { | ||
if (currentValue > 0) { | ||
currentValue-- | ||
onValueChange(currentValue) | ||
} | ||
} | ||
.size(20.dp), | ||
contentAlignment = Alignment.Center | ||
) { | ||
Icon( | ||
painter = painterResource(id = R.drawable.ic_seats_minus), | ||
contentDescription = "인원 감소", | ||
tint = Gray800, | ||
modifier = Modifier.size(20.dp) | ||
) | ||
} | ||
|
||
// 현재 값 | ||
Box( | ||
modifier = Modifier | ||
.padding(horizontal = 5.dp) | ||
.size(width = 34.dp, height = 28.dp) | ||
.background(Color.White, RoundedCornerShape(8.dp)), | ||
contentAlignment = Alignment.Center | ||
) { | ||
Text( | ||
text = currentValue.toString(), | ||
fontSize = 17.sp, | ||
color = Gray700 | ||
) | ||
} | ||
|
||
// + 버튼 | ||
Box( | ||
modifier = Modifier | ||
.clickable { | ||
currentValue++ | ||
onValueChange(currentValue) | ||
} | ||
.size(20.dp), | ||
contentAlignment = Alignment.Center | ||
) { | ||
Icon( | ||
painter = painterResource(id = R.drawable.ic_seats_plus), | ||
contentDescription = "인원 증가", | ||
tint = Gray800, | ||
modifier = Modifier.size(20.dp) // 아이콘 크기 | ||
) | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun StepperPreview() { | ||
Stepper( | ||
initialValue = 0, | ||
onValueChange = { newValue -> | ||
println("Stepper value changed: $newValue") | ||
} | ||
) | ||
} |
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.
와 컴포넌트화 이렇게까지 할 수 있네요?
저는 다 다른 버튼이라 다 만들 것 같았는데
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.
오히려 비효율적이구 헷갈리려나... 싶어서 다시 나눌까 고민중이어요 ㅎㅎㅜㅠ..