-
Notifications
You must be signed in to change notification settings - Fork 0
[Feature] 장바구니 ui 구현 #11
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
39 changes: 39 additions & 0 deletions
39
AppleStoreProductKiosk/Features/ShoppingCart/CartView.swift
This file contains hidden or 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,39 @@ | ||
| // | ||
| // CartView.swift | ||
| // AppleStoreProductKiosk | ||
| // | ||
| // Created by 김민희 on 9/16/25. | ||
| // | ||
|
|
||
| import SwiftUI | ||
|
|
||
| struct CartView: View { | ||
| @State var item = CartItem() | ||
| var body: some View { | ||
| VStack(spacing: 0) { | ||
| CartHeaderView() | ||
|
|
||
| Divider() | ||
|
|
||
| ScrollView { | ||
| VStack(spacing: 15) { | ||
| CartItemRowView(item: $item) | ||
| } | ||
| .padding(.horizontal, 20) | ||
| .padding(.vertical, 30) | ||
| } | ||
| .scrollIndicators(.hidden) | ||
|
|
||
| Divider() | ||
|
|
||
| CartSummaryView(item: $item) | ||
| .padding(.vertical, 20) | ||
|
|
||
| CartActionButtonsView() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #Preview { | ||
| CartView() | ||
| } |
49 changes: 49 additions & 0 deletions
49
AppleStoreProductKiosk/Features/ShoppingCart/Components/CartActionButtonsView.swift
This file contains hidden or 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,49 @@ | ||
| // | ||
| // CartActionButtonsView.swift | ||
| // AppleStoreProductKiosk | ||
| // | ||
| // Created by 김민희 on 9/17/25. | ||
| // | ||
|
|
||
| import SwiftUI | ||
|
|
||
| struct CartActionButtonsView: View { | ||
| var body: some View { | ||
| Grid(horizontalSpacing: 12) { | ||
| GridRow { | ||
| Button { | ||
| //전체 취소 | ||
| } label: { | ||
| Text("전체 취소") | ||
| .font(.system(size: 15, weight: .regular)) | ||
| .foregroundStyle(.black) | ||
| .frame(maxWidth: .infinity) | ||
| .padding(10) | ||
| .overlay { | ||
| Capsule(style: .continuous) | ||
| .stroke(.black.opacity(0.2), lineWidth: 1) | ||
| } | ||
| } | ||
| .gridCellColumns(4) | ||
|
|
||
| Button { | ||
| //결제하기 | ||
| } label: { | ||
| Text("결제하기") | ||
| .font(.system(size: 15, weight: .semibold)) | ||
| .foregroundStyle(.white) | ||
| .frame(maxWidth: .infinity) | ||
| .padding(10) | ||
| .background(.blue) | ||
| .clipShape(.capsule(style: .continuous)) | ||
| } | ||
| .gridCellColumns(6) | ||
| } | ||
| } | ||
| .padding(.horizontal, 20) | ||
| } | ||
| } | ||
|
|
||
| #Preview { | ||
| CartActionButtonsView() | ||
| } | ||
37 changes: 37 additions & 0 deletions
37
AppleStoreProductKiosk/Features/ShoppingCart/Components/CartHeaderView.swift
This file contains hidden or 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,37 @@ | ||
| // | ||
| // CartHeaderView.swift | ||
| // AppleStoreProductKiosk | ||
| // | ||
| // Created by 김민희 on 9/16/25. | ||
| // | ||
|
|
||
| import SwiftUI | ||
|
|
||
| struct CartHeaderView: View { | ||
| @Environment(\.dismiss) var dismiss | ||
|
|
||
| var body: some View { | ||
| HStack(spacing: 0) { | ||
| Text("장바구니") | ||
| .font(.system(size: 20, weight: .bold)) | ||
| Spacer() | ||
|
|
||
| Button { | ||
| dismiss() | ||
| } label: { | ||
| Image(systemName: "xmark") | ||
| .foregroundColor(.black) | ||
| .font(.system(size: 15)) | ||
| .padding(8) | ||
| .background(.gray.opacity(0.15)) | ||
| .clipShape(Circle()) | ||
| } | ||
| } | ||
| .padding(.horizontal, 20) | ||
| .padding(.vertical, 25) | ||
| } | ||
| } | ||
|
|
||
| #Preview { | ||
| CartHeaderView() | ||
| } |
108 changes: 108 additions & 0 deletions
108
AppleStoreProductKiosk/Features/ShoppingCart/Components/CartItemRowView.swift
This file contains hidden or 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,108 @@ | ||
| // | ||
| // CartItemRowView.swift | ||
| // AppleStoreProductKiosk | ||
| // | ||
| // Created by 김민희 on 9/16/25. | ||
| // | ||
|
|
||
| import SwiftUI | ||
|
|
||
| //TODO: 데이터 작업할 때 없앨예정 | ||
| struct CartItem { | ||
| let name: String = "iphone17 pro" | ||
| let price: Int = 1000000 | ||
| let imageName: String = "iphone17pro" | ||
| var quantity: Int = 2 | ||
| } | ||
|
|
||
| struct CartItemRowView: View { | ||
| @Binding var item: CartItem | ||
|
|
||
| var body: some View { | ||
| HStack(spacing: 0) { | ||
| Image(item.imageName) | ||
| .resizable() | ||
| .scaledToFit() | ||
| .frame(width: 80, height: 80) | ||
| .cornerRadius(10) | ||
|
|
||
| Spacer() | ||
| .frame(width: 20) | ||
|
|
||
| VStack(alignment: .leading, spacing: 10) { | ||
| Text(item.name) | ||
| .font(.system(size: 17, weight: .semibold)) | ||
|
|
||
| Text("₩\(item.price)") | ||
| .font(.system(size: 14, weight: .regular)) | ||
| .foregroundStyle(.black.opacity(0.7)) | ||
|
|
||
| Text("소계: ₩\(item.price * item.quantity)") | ||
| .font(.system(size: 12, weight: .regular)) | ||
| .foregroundStyle(.blue) | ||
| } | ||
|
|
||
| Spacer() | ||
|
|
||
| HStack(spacing: 13) { | ||
| if item.quantity > 1 { | ||
| Button { | ||
| item.quantity -= 1 | ||
| } label: { | ||
| Image(systemName: "minus") | ||
| .font(.system(size: 15)) | ||
| .padding(12) | ||
| .foregroundStyle(.black) | ||
| .background(.white) | ||
| .clipShape(Circle()) | ||
| .overlay( | ||
| Circle() | ||
| .stroke(.gray.opacity(0.3), lineWidth: 0.7) | ||
| ) | ||
| } | ||
| } else { | ||
| Button { | ||
| //삭제 | ||
| } label: { | ||
| Image(systemName: "trash") | ||
| .font(.system(size: 13)) | ||
| .padding(8) | ||
| .foregroundStyle(.red) | ||
| .background(.white) | ||
| .clipShape(Circle()) | ||
| .overlay( | ||
| Circle() | ||
| .stroke(.gray.opacity(0.3), lineWidth: 0.7) | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| Text("\(item.quantity)").frame(minWidth: 20) | ||
|
|
||
| Button { | ||
| item.quantity += 1 | ||
| } label: { | ||
| Image(systemName: "plus") | ||
| .font(.system(size: 15)) | ||
| .padding(7) | ||
| .foregroundStyle(.black) | ||
| .background(.white) | ||
| .clipShape(Circle()) | ||
| .overlay( | ||
| Circle() | ||
| .stroke(.gray.opacity(0.3), lineWidth: 0.7) | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| .padding(.horizontal, 10) | ||
| .padding(.vertical, 20) | ||
| .background(.gray.opacity(0.05)) | ||
| .clipShape(RoundedRectangle(cornerRadius: 14)) | ||
| } | ||
| } | ||
|
|
||
| #Preview { | ||
| @State var item = CartItem(quantity: 1) | ||
| CartItemRowView(item: $item) | ||
| } |
41 changes: 41 additions & 0 deletions
41
AppleStoreProductKiosk/Features/ShoppingCart/Components/CartSummaryView.swift
This file contains hidden or 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,41 @@ | ||
| // | ||
| // CartSummaryView.swift | ||
| // AppleStoreProductKiosk | ||
| // | ||
| // Created by 김민희 on 9/17/25. | ||
| // | ||
|
|
||
| import SwiftUI | ||
|
|
||
| struct CartSummaryView: View { | ||
| @Binding var item: CartItem | ||
|
|
||
| var body: some View { | ||
| HStack(spacing: 0) { | ||
| VStack(alignment: .leading, spacing: 10) { | ||
| Text("상품 개수") | ||
| .font(.system(size: 14, weight: .regular)) | ||
| .foregroundStyle(.black.opacity(0.7)) | ||
| Text("총 결제금액") | ||
| .font(.system(size: 18, weight: .semibold)) | ||
| } | ||
|
|
||
| Spacer() | ||
|
|
||
| VStack(alignment: .trailing, spacing: 10) { | ||
| Text("\(item.quantity)개") | ||
| .font(.system(size: 14, weight: .semibold)) | ||
| Text("₩\(item.price * item.quantity)") | ||
| .font(.system(size: 20, weight: .bold)) | ||
| .foregroundStyle(.blue) | ||
| } | ||
|
|
||
| } | ||
| .padding(.horizontal, 20) | ||
| } | ||
| } | ||
|
|
||
| #Preview { | ||
| @State var item = CartItem() | ||
| CartSummaryView(item: $item) | ||
| } |
21 changes: 21 additions & 0 deletions
21
AppleStoreProductKiosk/Resources/Assets.xcassets/iphone17pro.imageset/Contents.json
This file contains hidden or 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,21 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "filename" : "iphone17pro.jpeg", | ||
| "idiom" : "universal", | ||
| "scale" : "1x" | ||
| }, | ||
| { | ||
| "idiom" : "universal", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "idiom" : "universal", | ||
| "scale" : "3x" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "author" : "xcode", | ||
| "version" : 1 | ||
| } | ||
| } |
Binary file added
BIN
+60.6 KB
...oreProductKiosk/Resources/Assets.xcassets/iphone17pro.imageset/iphone17pro.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
오 Grid
HStack이 아닌 Grid로 하신 이유가 있으실까요 ?
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.
아래 버튼 두개가 화면의 4:6 비율로 차지하고있는데
그 부분을 .gridCellColumns(4) / .gridCellColumns(6) 을 사용해서 만드려고 Grid 사용했습니다!