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
92 changes: 64 additions & 28 deletions Keychy/Keychy.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//
// TemplateActionButton.swift
// Keychy
//
// Created by 길지훈 on 1/22/26.
//

import SwiftUI

// MARK: - Template Action Button

/// 키링 템플릿 전용 액션 버튼
/// - 보유중이면 "만들기" 버튼 표시 (활성화)
/// - 유료이고 미보유면 구매 버튼 표시
/// - 무료이고 미보유면 "만들기" 버튼 표시 (활성화)
struct TemplateActionButton: View {
let template: KeyringTemplate
let isOwned: Bool
let onMake: () -> Void
let onPurchase: () -> Void

var body: some View {
Group {
if isOwned || template.isFree {
// 보유중이거나 무료인 경우 만들기 버튼 (활성화)
makeButton
} else {
// 유료이고 미보유인 경우 구매 버튼
purchaseButton
}
}
}

/// 만들기 버튼 (활성화)
private var makeButton: some View {
Button {
onMake()
} label: {
Text("만들기")
.typography(.suit17B)
.foregroundStyle(.white100)
.frame(maxWidth: .infinity)
.padding(.vertical, 7.5)
}
.buttonStyle(.glassProminent)
.tint(.main500)
}

/// 구매 버튼 (유료)
private var purchaseButton: some View {
Button {
onPurchase()
} label: {
HStack(spacing: 5) {
Image(.myCoinMini)
.resizable()
.scaledToFit()
.frame(width: 32)

Text("\(template.workshopPrice)")
.typography(.nanum18EB)
.foregroundStyle(.white100)
}
.frame(maxWidth: .infinity)
.frame(height: 36)
}
.buttonStyle(.glassProminent)
.tint(.black80)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ extension TemplatePreviewBody {
private var actionButton: some View {
Group {
if let template {
KeyringTemplateActionButton(
TemplateActionButton(
template: template,
isOwned: isOwned,
onMake: checkInventoryAndMake,
Expand Down
12 changes: 6 additions & 6 deletions Keychy/Keychy/Presentation/Tab/Views/WorkshopTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ struct WorkshopTab: View {
// MARK: - 공통 프리뷰
case .workshopPreview(let item):
if let template = item.base as? KeyringTemplate {
WorkshopPreview(router: router, viewModel: workshopViewModel, item: template)
WorkshopItemDetailView(router: router, viewModel: workshopViewModel, item: template)
} else if let background = item.base as? Background {
WorkshopPreview(router: router, viewModel: workshopViewModel, item: background)
WorkshopItemDetailView(router: router, viewModel: workshopViewModel, item: background)
} else if let carabiner = item.base as? Carabiner {
WorkshopPreview(router: router, viewModel: workshopViewModel, item: carabiner)
WorkshopItemDetailView(router: router, viewModel: workshopViewModel, item: carabiner)
} else if let particle = item.base as? Particle {
WorkshopPreview(router: router, viewModel: workshopViewModel, item: particle)
WorkshopItemDetailView(router: router, viewModel: workshopViewModel, item: particle)
} else if let sound = item.base as? Sound {
WorkshopPreview(router: router, viewModel: workshopViewModel, item: sound)
WorkshopItemDetailView(router: router, viewModel: workshopViewModel, item: sound)
}

// MARK: - 내 창고뷰
case .myItems:
MyItemsView(router: router)
WorkshopMyItemsView(router: router)

// MARK: - 템플릿 목록뷰
case .workshopTemplates:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,26 @@ class WorkshopViewModel {
// isWorkshopBannerLoading은 항상 true로 시작
// NukeAnimatedImageView가 GIF 로드 완료 시 자동으로 false로 변경
}


// MARK: - Initialization

/// 초기 데이터 로드 (네트워크 체크 → 카테고리 로드 → 백그라운드 프리페칭)
func initialize() async {
// 네트워크 체크
guard NetworkManager.shared.isConnected else {
hasNetworkError = true
return
}

// 1. 현재 선택된 카테고리만 먼저 로드 (빠른 초기 화면)
await fetchDataForCategory(selectedCategory)

// 2. 백그라운드에서 나머지 카테고리 프리페칭
Task.detached(priority: .background) { [weak self] in
await self?.prefetchRemainingData()
}
}

// MARK: - Firebase Methods (통합)
/// 특정 카테고리의 데이터만 가져오기
func fetchDataForCategory(_ category: String) async {
Expand Down
Loading