Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions StockMate/StockMate/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ struct ContentView: View {
Text("임시 화면")
}
.padding()
HStack(spacing: 20) {
Image(systemName: "gearshape")
.font(.system(size: 40))
.foregroundColor(.blue)

Image(systemName: "lightbulb")
.font(.system(size: 40))
.foregroundColor(.cyan)
}
}
}

Expand Down
128 changes: 128 additions & 0 deletions StockMate/StockMate/app/core/components/CartCard.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
//
// CartCard.swift
// StockMate
//
// Created by Admin on 10/27/25.
//

import SwiftUI

struct CartCard: View {
let item: CartItem
let quantity: Int
let onIncrease: () -> Void
let onDecrease: () -> Void
let onAddToCart: (() -> Void)?
let onRemoveFromCart: () -> Void

var body: some View {
VStack(alignment: .leading, spacing: 6) {
Text(item.categoryName ?? "")
.font(.system(size: 12, weight: .semibold))
.foregroundColor(.black)

Divider().frame(height: 0.2).background(Color.textGray2)

HStack(alignment: .center, spacing: 12) {
AsyncImage(url: URL(string: item.image ?? "")) { image in
image.resizable().scaledToFit()
} placeholder: {
Color.gray.opacity(0.2)
}
.frame(width: 64, height: 64)
.cornerRadius(10)

VStack(alignment: .leading, spacing: 6) {
Text(item.brand ?? "")
.font(.system(size: 14, weight: .bold))
.foregroundColor(.black)
.lineLimit(2)

Text("\((item.trim ?? "")) / \((item.model ?? ""))")
.font(.system(size: 13))
.foregroundColor(.gray)
.lineLimit(1)

Text("\(item.price ?? 0)원")
.font(.system(size: 13, weight: .semibold))
.foregroundColor(.black)

// Text("\(item.trim) / \(item.model)")
// .font(.system(size: 13))
// .foregroundColor(.gray)
//
// Text("\(item.price)원")
// .font(.system(size: 13, weight: .semibold))
// .foregroundColor(.black)
}

Spacer()

// 🪄 수량에 따른 3단계 분기
if quantity == 0 {
if let onAddToCart = onAddToCart {
Button(action: onAddToCart) {
Image(systemName: "cart.badge.plus")
.font(.system(size: 18))
.foregroundColor(.Primary)
.padding(10)
.background(Color.Primary.opacity(0.1))
.clipShape(Circle())
}
}
} else if quantity == 1 {
HStack(spacing: 10) {
Button(action: onRemoveFromCart) {
Image(systemName: "trash")
.font(.system(size: 14, weight: .bold))
.foregroundColor(.red)
}

Text("1")
.font(.system(size: 15, weight: .semibold))
.frame(width: 24)

Button(action: onIncrease) {
Image(systemName: "plus")
.font(.system(size: 14, weight: .bold))
.foregroundColor(.Primary)
}
}
.padding(.vertical, 6)
.padding(.horizontal, 10)
.background(Color.white)
.cornerRadius(10)
.shadow(color: .black.opacity(0.05), radius: 4, x: 0, y: 4)

} else {
HStack(spacing: 10) {
Button(action: onDecrease) {
Image(systemName: "minus")
.font(.system(size: 14, weight: .bold))
.foregroundColor(.gray)
}

Text("\(quantity)")
.font(.system(size: 15, weight: .semibold))
.frame(width: 24)

Button(action: onIncrease) {
Image(systemName: "plus")
.font(.system(size: 14, weight: .bold))
.foregroundColor(.Primary)
}
}
.padding(.vertical, 6)
.padding(.horizontal, 10)
.background(Color.white)
.cornerRadius(10)
.shadow(color: .black.opacity(0.05), radius: 4, x: 0, y: 4)
}
}
}
.padding()
.background(Color.white)
.cornerRadius(14)
.shadow(color: .black.opacity(0.05), radius: 4, x: 0, y: 4)
}
}
86 changes: 86 additions & 0 deletions StockMate/StockMate/app/core/components/CartInfoCard.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
//
// CartInfoCard.swift
// StockMate
//
// Created by Admin on 10/27/25.
//

import SwiftUI

struct CartInfoCard: View {
let item: CartItem
let quantity: Int

var body: some View {
VStack(alignment: .leading, spacing: 6) {
Text(item.categoryName ?? "")
.font(.system(size: 12, weight: .semibold))
.foregroundColor(.black)

Divider().frame(height: 0.2).background(Color.textGray2)

HStack(alignment: .center, spacing: 12) {
AsyncImage(url: URL(string: item.image ?? "")) { image in
image.resizable().scaledToFit()
} placeholder: {
Color.gray.opacity(0.2)
}
.frame(width: 64, height: 64)
.cornerRadius(10)


VStack(alignment: .leading, spacing: 6) {
Text(item.brand ?? "")
.font(.system(size: 14, weight: .bold))
.foregroundColor(.black)
.lineLimit(2)

HStack{
Text("\((item.trim ?? "")) / \((item.model ?? ""))")
.font(.system(size: 13))
.foregroundColor(.gray)
.lineLimit(1)

Spacer()

Text("\((item.price ?? 0) * item.amount)원")
.font(.system(size: 13, weight: .semibold))
.foregroundColor(.black)
.lineLimit(1)

}
Text("\(item.price ?? 0)원 / \(item.amount)개")
.font(.system(size: 13))
.foregroundColor(.gray)
.lineLimit(1)
}
}
}
.padding()
.background(Color.white)
.cornerRadius(14)
// .shadow(color: .black.opacity(0.05), radius: 4, x: 0, y: 4)
}
}

#Preview {
CartInfoCard(
item: CartItem(
cartItemId: 1,
partId: 101,
amount: 2,
partName: "실린더 어셈블리 브레이크 마스터",
categoryName: "엔진/미션",
brand: "실린더 어셈블리 브레이크 마스터",
model: "아반떼 MD",
trim: "중형",
price: 60000,
stock: 30,
image: ""
),
quantity: 2
)
.previewLayout(.sizeThatFits)
.padding()
.background(Color.Light)
}
50 changes: 50 additions & 0 deletions StockMate/StockMate/app/core/components/CartSummaryBar.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// CartSummaryBar.swift
// StockMate
//
// Created by Admin on 10/26/25.
//

import Foundation
import SwiftUI

struct CartSummaryBar: View {
@ObservedObject var cartVM: CartViewModel

var body: some View {
VStack {
Spacer()

if let cart = cartVM.cart,
!cart.items.isEmpty {
NavigationLink(destination: OrderCartView(cartViewModel: cartVM)) {
HStack(spacing: 12) {
Circle()
.fill(Color.white)
.frame(width: 20, height: 20)
.overlay(
Text("\(cart.items.count)")
.font(.system(size: 11, weight: .bold))
.foregroundColor(.Primary)
)

Text("장바구니 보기")
.font(.system(size: 16, weight: .bold))
.foregroundColor(.white)

Spacer()

Text("\(cart.totalPrice ?? 0)원")
.font(.system(size: 16, weight: .semibold))
.foregroundColor(.white)
}
.padding(.horizontal, 30)
.frame(height: 60)
.background(Color.Primary)
.clipShape(RoundedCorner(radius: 16, corners: [.topLeft, .topRight]))
}
}
}
.ignoresSafeArea(edges: .bottom)
}
}
Loading
Loading