diff --git a/TeamIntroduce/TeamIntroduce/Sources/Application/TeamIntroduceApp.swift b/TeamIntroduce/TeamIntroduce/Sources/Application/TeamIntroduceApp.swift index 0adc934..beafba8 100644 --- a/TeamIntroduce/TeamIntroduce/Sources/Application/TeamIntroduceApp.swift +++ b/TeamIntroduce/TeamIntroduce/Sources/Application/TeamIntroduceApp.swift @@ -13,6 +13,88 @@ struct TeamIntroduceApp: App { var body: some Scene { WindowGroup { RootView() + .modelContainer(for: TeamMember.self) { result in + // 🎯 초기 데이터 μ„€μ • + switch result { + case .success(let container): + setupInitialData(container: container) + case .failure(let error): + print("❌ SwiftData μ»¨ν…Œμ΄λ„ˆ 생성 μ‹€νŒ¨: \(error)") + } + } } } + + // MARK: - 초기 데이터 μ„€μ • + private func setupInitialData(container: ModelContainer) { + let context = container.mainContext + + // πŸ” κΈ°μ‘΄ 데이터 확인 + let descriptor = FetchDescriptor() + let existingCount = (try? context.fetch(descriptor).count) ?? 0 + + print("πŸ“Š κΈ°μ‘΄ νŒ€μ› 데이터 개수: \(existingCount)") + + // 데이터가 μ—†μœΌλ©΄ μƒ˜ν”Œ 데이터 μΆ”κ°€ + if existingCount == 0 { + print("🎯 초기 νŒ€μ› 데이터 생성 쀑...") + + let members = createMembers() + + for member in members { + context.insert(member) + print("βœ… νŒ€μ› μΆ”κ°€: \(member.name) (ID: \(member.id))") + } + + do { + try context.save() + print("πŸ’Ύ 초기 데이터 μ €μž₯ μ™„λ£Œ!") + + // μ €μž₯ ν›„ λ‹€μ‹œ 확인 + let savedCount = (try? context.fetch(descriptor).count) ?? 0 + print("πŸ“Š μ €μž₯된 νŒ€μ› 데이터 개수: \(savedCount)") + } catch { + print("❌ 데이터 μ €μž₯ μ‹€νŒ¨: \(error)") + } + } else { + print("ℹ️ κΈ°μ‘΄ 데이터가 μžˆμ–΄μ„œ μ΄ˆκΈ°ν™”λ₯Ό κ±΄λ„ˆλœλ‹ˆλ‹€.") + } + } + + // MARK: - μƒ˜ν”Œ 데이터 생성 + private func createMembers() -> [TeamMember] { + return [ + TeamMember( + name: "김민희", + imageName: "person.crop.circle", + role: "iOS Developer", + mbti: "ESTP", + introduction: "μΊ ν”„ ν›„ 되고 싢은 λ‚˜μ˜ λͺ¨μŠ΅ ν˜Ήμ€ 미래의 λ‚˜μ˜ λͺ¨μŠ΅μ„ ν•œλ§ˆλ””λ‘œ μ μ–΄λ³΄μ„Έμš”! μƒμƒν•˜κ²Œ 꿈꾸면 μ΄λ£¨μ–΄μ§„λ‹΅λ‹ˆλ‹€!", + strengths: ["UIKit", "Core Data", "Auto Layout", "Unit Testing"], + blogLink: "https://0minnie0.tistory.com/", + collaborationStyle: "μ„Έμ‹¬ν•œ κ²€ν† , λ¬Έμ„œν™” μ€‘μ‹œ, 체계적 정리, ν’ˆμ§ˆ 관리", + isLeader: true + ), + TeamMember( + name: "μ„œμ›μ§€", + imageName: "person.crop.circle.fill", + role: "iOS Developer", + mbti: "INTP", + introduction: "μ’€ 큰 기업에 μž…μ‚¬λ₯Ό ν•˜κ³  λ‹€μ–‘ν•œ ν”„λ‘œμ νŠΈλ₯΄ ν•˜κ³  μ‹ΆμŠ΅λ‹ˆλ‹€", + strengths: ["Swift", "RxSwift", "Clean Architecture", "Firebase Integration"], + blogLink: "https://velog.io/@suhwj/posts", + collaborationStyle: "창의적 λ¬Έμ œν•΄κ²°, μ‚¬μš©μž 쀑심 사고, 논리적 뢄석, 기술 연ꡬ" + ), + TeamMember( + name: "ν™μ„ν˜„", + imageName: "person.circle.fill", + role: "iOS Developer", + mbti: "ENFJ", + introduction: "μ•ˆλ…•ν•˜μ„Έμš”! 열정적인 iOS κ°œλ°œμžμž…λ‹ˆλ‹€.", + strengths: ["SwiftUI", "Combine", "Swift Concurrency", "MVVM Architecture"], + blogLink: "https://blog.example.com/hong", + collaborationStyle: "적극적 μ†Œν†΅, μ½”λ“œ 리뷰, νŒ€ 리딩, 지식 곡유" + ) + ] + } } diff --git a/TeamIntroduce/TeamIntroduce/Sources/Core/Data/Item.swift b/TeamIntroduce/TeamIntroduce/Sources/Core/Data/Item.swift deleted file mode 100644 index 2d45203..0000000 --- a/TeamIntroduce/TeamIntroduce/Sources/Core/Data/Item.swift +++ /dev/null @@ -1,18 +0,0 @@ -// -// Item.swift -// TeamIntroduce -// -// Created by Wonji Suh on 8/11/25. -// - -import Foundation -import SwiftData - -@Model -final class Item { - var timestamp: Date - - init(timestamp: Date) { - self.timestamp = timestamp - } -} diff --git a/TeamIntroduce/TeamIntroduce/Sources/Core/Data/TeamMember.swift b/TeamIntroduce/TeamIntroduce/Sources/Core/Data/TeamMember.swift new file mode 100644 index 0000000..19f516c --- /dev/null +++ b/TeamIntroduce/TeamIntroduce/Sources/Core/Data/TeamMember.swift @@ -0,0 +1,47 @@ +// +// TeamMember.swift +// TeamIntroduce +// +// Created by ν™μ„ν˜„ on 8/12/25. +// + +import Foundation +import SwiftData + +@Model +final class TeamMember: Identifiable { + var id: UUID + var name: String + var imageName: String + var role: String + var mbti: String + var introduction: String + var strengths: [String] + var blogLink: String + var collaborationStyle: String + var isLeader: Bool + + init( + id: UUID = UUID(), + name: String, + imageName: String, + role: String, + mbti: String, + introduction: String, + strengths: [String], + blogLink: String, + collaborationStyle: String, + isLeader: Bool = false + ) { + self.id = id + self.name = name + self.imageName = imageName + self.role = role + self.mbti = mbti + self.introduction = introduction + self.strengths = strengths + self.blogLink = blogLink + self.collaborationStyle = collaborationStyle + self.isLeader = isLeader + } +} diff --git a/TeamIntroduce/TeamIntroduce/Sources/Presnetaion/IntroduceMain/Coordinator/View/IntorduceCoordinatorView.swift b/TeamIntroduce/TeamIntroduce/Sources/Presnetaion/IntroduceMain/Coordinator/View/IntorduceCoordinatorView.swift index 92ae0a7..506e4b5 100644 --- a/TeamIntroduce/TeamIntroduce/Sources/Presnetaion/IntroduceMain/Coordinator/View/IntorduceCoordinatorView.swift +++ b/TeamIntroduce/TeamIntroduce/Sources/Presnetaion/IntroduceMain/Coordinator/View/IntorduceCoordinatorView.swift @@ -13,7 +13,7 @@ struct IntorduceCoordinatorView : View { var sharedModelContainer: ModelContainer = { let schema = Schema([ - Item.self, + TeamMember.self, ]) let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false) diff --git a/TeamIntroduce/TeamIntroduce/Sources/Presnetaion/IntroduceMain/View/ContentView.swift b/TeamIntroduce/TeamIntroduce/Sources/Presnetaion/IntroduceMain/View/ContentView.swift index 0a8d72b..27a3284 100644 --- a/TeamIntroduce/TeamIntroduce/Sources/Presnetaion/IntroduceMain/View/ContentView.swift +++ b/TeamIntroduce/TeamIntroduce/Sources/Presnetaion/IntroduceMain/View/ContentView.swift @@ -10,40 +10,12 @@ import SwiftData struct ContentView: View { @Environment(\.modelContext) private var modelContext - @Query private var items: [Item] + @Query private var teamMembers: [TeamMember] @EnvironmentObject private var coordinator: IntroduceCoordinator var body: some View { - ZStack { - Color.white - .edgesIgnoringSafeArea(.all) - - VStack { - Spacer() - - Text("main") - - Spacer() - - - Spacer() - .frame(height: 20) - } - } - } - - private func addItem() { - withAnimation { - let newItem = Item(timestamp: Date()) - modelContext.insert(newItem) - } - } - - private func deleteItems(offsets: IndexSet) { - withAnimation { - for index in offsets { - modelContext.delete(items[index]) - } + List(teamMembers, id: \.id) { member in + Text(member.name) } } } @@ -56,5 +28,5 @@ extension ContentView { #Preview { ContentView() - .modelContainer(for: Item.self, inMemory: true) + .modelContainer(for: TeamMember.self, inMemory: true) }