-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor/#42 버튼 컴포넌트들 수정 #44
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,9 +28,14 @@ struct CherrishButton: View { | |
|
|
||
| var body: some View { | ||
| Button(action: action) { | ||
| Text(title) | ||
| .typography(.title2_sb_16) | ||
| .foregroundStyle(type.textColor(for: state)) | ||
| HStack{ | ||
| Spacer() | ||
| Text(title) | ||
| .typography(.title2_sb_16) | ||
| .foregroundStyle(type.textColor(for: state)) | ||
| Spacer() | ||
| } | ||
|
|
||
| } | ||
| .buttonStyle(CherrishButtonStyle(state: state, type: type)) | ||
| .disabled(type.isDisabled(for: state)) | ||
|
|
@@ -44,29 +49,17 @@ struct CherrishButtonStyle: ButtonStyle { | |
|
|
||
| func makeBody(configuration: Configuration) -> some View { | ||
| configuration.label | ||
| .frame( | ||
| width: configuration.isPressed ? type.width * 0.95 : type.width, | ||
| height: configuration.isPressed ? type.height * 0.95 : type.height | ||
| ) | ||
| .frame(height: type.height) | ||
| .background(type.backgroundColor(for: state)) | ||
| .clipShape(RoundedRectangle(cornerRadius: configuration.isPressed | ||
| ? type.cornerRadius * 0.95 | ||
| : type.cornerRadius)) | ||
| .scaleEffect(configuration.isPressed ? 0.95 : 1.0) | ||
| } | ||
|
Comment on lines
50
to
58
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. 🧹 Nitpick | 🔵 Trivial
♻️ cornerRadius 조정 제거 제안 func makeBody(configuration: Configuration) -> some View {
configuration.label
.frame(height: type.height)
.background(type.backgroundColor(for: state))
- .clipShape(RoundedRectangle(cornerRadius: configuration.isPressed
- ? type.cornerRadius * 0.95
- : type.cornerRadius))
+ .clipShape(RoundedRectangle(cornerRadius: type.cornerRadius))
.scaleEffect(configuration.isPressed ? 0.95 : 1.0)
}🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
|
|
||
| extension CherrishButtonType { | ||
|
|
||
| var width: CGFloat { | ||
| switch self { | ||
| case .next: return 326 | ||
| case .confirm: return 126 | ||
| case .save: return 278 | ||
| case .addEvent: return 196 | ||
| } | ||
| } | ||
|
|
||
| var height: CGFloat { | ||
| switch self { | ||
| case .save: return 44 | ||
|
|
@@ -113,3 +106,69 @@ extension CherrishButtonType { | |
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| struct CherrishButtonPreviewWrapper: View { | ||
|
Contributor
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. 요기한번만 지워주세용!!
Contributor
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. 해줘! |
||
|
|
||
| @State private var nextState: ButtonState = .normal | ||
| @State private var activeNextState: ButtonState = .active | ||
| @State private var dummyState: ButtonState = .active | ||
|
|
||
| var body: some View { | ||
| VStack(spacing: 16) { | ||
|
|
||
| // NEXT - 비활성 | ||
| CherrishButton( | ||
| title: "다음", | ||
| type: .next, | ||
| state: $nextState | ||
| ) { | ||
| print("Next (normal)") | ||
| } | ||
|
|
||
| // NEXT - 활성 | ||
| CherrishButton( | ||
| title: "다음", | ||
| type: .next, | ||
| state: $activeNextState | ||
| ) { | ||
| print("Next (active)") | ||
| } | ||
| .padding(CGFloat(8)) | ||
|
|
||
| // CONFIRM | ||
| CherrishButton( | ||
| title: "확인", | ||
| type: .confirm, | ||
| state: $dummyState | ||
| ) { | ||
| print("Confirm") | ||
| } | ||
|
|
||
| // SAVE | ||
| CherrishButton( | ||
| title: "등록하기", | ||
| type: .save, | ||
| state: $dummyState | ||
| ) { | ||
| print("Save") | ||
| } | ||
|
|
||
| // ADD EVENT | ||
| CherrishButton( | ||
| title: "다운타임 없이 일정 추가", | ||
| type: .addEvent, | ||
| state: $dummyState | ||
| ) { | ||
| print("Add Event") | ||
| } | ||
| } | ||
| .padding() | ||
| .background(Color.gray100) | ||
| } | ||
| } | ||
| #Preview { | ||
| CherrishButtonPreviewWrapper() | ||
| } | ||
|
Comment on lines
+111
to
+172
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. 🧹 Nitpick | 🔵 Trivial 프리뷰 래퍼 추가가 좋습니다. 모든 버튼 타입과 상태를 테스트할 수 있는 프리뷰 래퍼가 개발에 유용합니다. 다만 Line 137의 🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,14 +16,15 @@ struct SelectionChip: View { | |
| Text(title) | ||
| .typography(.body1_m_14) | ||
| .foregroundStyle(isSelected ? .gray800 : .gray700) | ||
| .frame(width: 148, height: 80) | ||
| .background(isSelected ? .red200 : .gray0) | ||
| .overlay( | ||
| RoundedRectangle(cornerRadius: 10) | ||
| .stroke(isSelected ? .red500 : .gray500, lineWidth: 1) | ||
| ) | ||
| .onTapGesture { | ||
| isSelected.toggle() | ||
| } | ||
| .frame(maxWidth: .infinity) | ||
| .frame(height: 80) | ||
| .background(isSelected ? .red200 : .gray0) | ||
| .overlay( | ||
| RoundedRectangle(cornerRadius: 10) | ||
| .stroke(isSelected ? .red500 : .gray500, lineWidth: 1) | ||
| ) | ||
|
Comment on lines
+19
to
+25
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. 배경 색상에 라운드 처리가 누락되었습니다.
🔧 배경에 라운드 처리를 적용하는 수정안 .frame(maxWidth: .infinity)
.frame(height: 80)
- .background(isSelected ? .red200 : .gray0)
+ .background(
+ RoundedRectangle(cornerRadius: 10)
+ .fill(isSelected ? .red200 : .gray0)
+ )
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(isSelected ? .red500 : .gray500, lineWidth: 1)
)🤖 Prompt for AI Agents |
||
| .onTapGesture { | ||
| isSelected.toggle() | ||
| } | ||
| } | ||
| } | ||
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.
와