diff --git a/Code Drop_Team 11/.DS_Store b/Code Drop_Team 11/.DS_Store index 346f8c7..3455e5e 100644 Binary files a/Code Drop_Team 11/.DS_Store and b/Code Drop_Team 11/.DS_Store differ diff --git a/Code Drop_Team 11/Code Drop_Team 11.xcodeproj/project.pbxproj b/Code Drop_Team 11/Code Drop_Team 11.xcodeproj/project.pbxproj index 89d7425..419293d 100644 --- a/Code Drop_Team 11/Code Drop_Team 11.xcodeproj/project.pbxproj +++ b/Code Drop_Team 11/Code Drop_Team 11.xcodeproj/project.pbxproj @@ -19,6 +19,8 @@ 6B7453442C1D062B000C2955 /* DetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B7453402C1D062B000C2955 /* DetailView.swift */; }; 6B7453452C1D062B000C2955 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B7453412C1D062B000C2955 /* HomeView.swift */; }; 6B7453462C1D062B000C2955 /* ListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B7453422C1D062B000C2955 /* ListView.swift */; }; + 6B93108A2C1D19CD00A1F361 /* RouterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B9310892C1D19CD00A1F361 /* RouterModel.swift */; }; + 6B93108C2C1D1DBB00A1F361 /* EndView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B93108B2C1D1DBB00A1F361 /* EndView.swift */; }; 89937B5C2C1CC06D00ED70E3 /* NotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89937B5B2C1CC06D00ED70E3 /* NotificationManager.swift */; }; 89937B5F2C1CCED800ED70E3 /* News.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89937B5E2C1CCED800ED70E3 /* News.swift */; }; 89937B612C1CCF8000ED70E3 /* AllNews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89937B602C1CCF8000ED70E3 /* AllNews.swift */; }; @@ -60,6 +62,8 @@ 6B7453402C1D062B000C2955 /* DetailView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetailView.swift; sourceTree = ""; }; 6B7453412C1D062B000C2955 /* HomeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = ""; }; 6B7453422C1D062B000C2955 /* ListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListView.swift; sourceTree = ""; }; + 6B9310892C1D19CD00A1F361 /* RouterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RouterModel.swift; sourceTree = ""; }; + 6B93108B2C1D1DBB00A1F361 /* EndView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EndView.swift; sourceTree = ""; }; 89937B5B2C1CC06D00ED70E3 /* NotificationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationManager.swift; sourceTree = ""; }; 89937B5E2C1CCED800ED70E3 /* News.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = News.swift; sourceTree = ""; }; 89937B602C1CCF8000ED70E3 /* AllNews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllNews.swift; sourceTree = ""; }; @@ -94,6 +98,7 @@ 6B7452FB2C1CB36B000C2955 = { isa = PBXGroup; children = ( + 6B9310892C1D19CD00A1F361 /* RouterModel.swift */, 6B7453432C1D062B000C2955 /* Views */, 6B7453062C1CB36B000C2955 /* Code Drop_Team 11 */, 6B7453172C1CB36C000C2955 /* Code Drop_Team 11Tests */, @@ -160,6 +165,7 @@ 6B7453402C1D062B000C2955 /* DetailView.swift */, 6B7453412C1D062B000C2955 /* HomeView.swift */, 6B7453422C1D062B000C2955 /* ListView.swift */, + 6B93108B2C1D1DBB00A1F361 /* EndView.swift */, ); path = Views; sourceTree = ""; @@ -311,10 +317,12 @@ 89937B5C2C1CC06D00ED70E3 /* NotificationManager.swift in Sources */, 6B7453452C1D062B000C2955 /* HomeView.swift in Sources */, 89937B612C1CCF8000ED70E3 /* AllNews.swift in Sources */, + 6B93108A2C1D19CD00A1F361 /* RouterModel.swift in Sources */, 6B74530A2C1CB36B000C2955 /* ContentView.swift in Sources */, 6B7453462C1D062B000C2955 /* ListView.swift in Sources */, 89937B5F2C1CCED800ED70E3 /* News.swift in Sources */, 6B7453082C1CB36B000C2955 /* Code_Drop_Team_11App.swift in Sources */, + 6B93108C2C1D1DBB00A1F361 /* EndView.swift in Sources */, 89937B652C1CEA4300ED70E3 /* Quotes.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -480,7 +488,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"Code Drop_Team 11/Preview Content\""; - DEVELOPMENT_TEAM = 8D32S9PLZ6; + DEVELOPMENT_TEAM = LLTXZL34C3; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = "Code-Drop-Team-11-Info.plist"; @@ -496,7 +504,7 @@ "@executable_path/Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = "com.leeyeeunKim.Code-Drop-Team-11"; + PRODUCT_BUNDLE_IDENTIFIER = "com.MiaHyun.Code-Drop-Team-11"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; @@ -513,7 +521,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"Code Drop_Team 11/Preview Content\""; - DEVELOPMENT_TEAM = 8D32S9PLZ6; + DEVELOPMENT_TEAM = LLTXZL34C3; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = "Code-Drop-Team-11-Info.plist"; @@ -529,7 +537,7 @@ "@executable_path/Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = "com.leeyeeunKim.Code-Drop-Team-11"; + PRODUCT_BUNDLE_IDENTIFIER = "com.MiaHyun.Code-Drop-Team-11"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; diff --git a/Code Drop_Team 11/Code Drop_Team 11.xcodeproj/project.xcworkspace/xcuserdata/hyunlee.xcuserdatad/UserInterfaceState.xcuserstate b/Code Drop_Team 11/Code Drop_Team 11.xcodeproj/project.xcworkspace/xcuserdata/hyunlee.xcuserdatad/UserInterfaceState.xcuserstate index 18262cf..7fb0bb0 100644 Binary files a/Code Drop_Team 11/Code Drop_Team 11.xcodeproj/project.xcworkspace/xcuserdata/hyunlee.xcuserdatad/UserInterfaceState.xcuserstate and b/Code Drop_Team 11/Code Drop_Team 11.xcodeproj/project.xcworkspace/xcuserdata/hyunlee.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Code Drop_Team 11/Code Drop_Team 11/Code_Drop_Team_11App.swift b/Code Drop_Team 11/Code Drop_Team 11/Code_Drop_Team_11App.swift index a005397..ec8a0f5 100644 --- a/Code Drop_Team 11/Code Drop_Team 11/Code_Drop_Team_11App.swift +++ b/Code Drop_Team 11/Code Drop_Team 11/Code_Drop_Team_11App.swift @@ -11,11 +11,16 @@ import SwiftData @main struct Code_Drop_Team_11App: App { var vm = HealthKitViewModel() + @StateObject var notificationManager = NotificationManager() + @StateObject var router = Router() var body: some Scene { WindowGroup { HomeView() .environmentObject(vm) - }.modelContainer(for: News.self) + .environmentObject(router) + .environmentObject(notificationManager) + + } } } diff --git a/Code Drop_Team 11/Code Drop_Team 11/DataModel/News.swift b/Code Drop_Team 11/Code Drop_Team 11/DataModel/News.swift index e4811fa..1c69e12 100644 --- a/Code Drop_Team 11/Code Drop_Team 11/DataModel/News.swift +++ b/Code Drop_Team 11/Code Drop_Team 11/DataModel/News.swift @@ -6,10 +6,8 @@ // import Foundation -import SwiftData -@Model -class News: Hashable, Equatable { +class News: Hashable, Equatable, Identifiable { // var id: ObjectIdentifier var id = UUID() diff --git a/Code Drop_Team 11/Code Drop_Team 11/NotificationManager.swift b/Code Drop_Team 11/Code Drop_Team 11/NotificationManager.swift index 80c3655..bee5a12 100644 --- a/Code Drop_Team 11/Code Drop_Team 11/NotificationManager.swift +++ b/Code Drop_Team 11/Code Drop_Team 11/NotificationManager.swift @@ -55,8 +55,8 @@ class NotificationManager: ObservableObject { } else { print("Notification scheduled successfully") DispatchQueue.main.async { -// self.todayNews.append(randomNews) - self.modelContext.insert(randomNews) + self.todayNews.append(randomNews) +// self.modelContext.insert(randomNews) } } } diff --git a/Code Drop_Team 11/RouterModel.swift b/Code Drop_Team 11/RouterModel.swift new file mode 100644 index 0000000..6895697 --- /dev/null +++ b/Code Drop_Team 11/RouterModel.swift @@ -0,0 +1,29 @@ +// +// RouterModel.swift +// Code Drop_Team 11 +// +// Created by Hyun Lee on 6/15/24. +// + +import Foundation +import SwiftUI + +class Router: ObservableObject{ + @Published var path: NavigationPath = NavigationPath() + + func push(_ routePathView: Destination){ + path.append(routePathView) + } + + func backToRoot(){ + self.path = NavigationPath() + } +} + +enum Destination{ + case homeView + case listView + case detailView + case endView +} + diff --git a/Code Drop_Team 11/Views/DetailView.swift b/Code Drop_Team 11/Views/DetailView.swift index 17bbb6c..1fbb5db 100644 --- a/Code Drop_Team 11/Views/DetailView.swift +++ b/Code Drop_Team 11/Views/DetailView.swift @@ -8,7 +8,10 @@ import SwiftUI struct DetailView: View { - var insight: Insight + @EnvironmentObject var notificationManager: NotificationManager + @EnvironmentObject var vm: HealthKitViewModel + + var insight: News var body: some View { VStack { @@ -19,7 +22,7 @@ struct DetailView: View { Text(insight.title) .font(.largeTitle) .padding() - Text(insight.detail) + Text(insight.text) .font(.body) .padding() Spacer() @@ -40,5 +43,5 @@ struct DetailView: View { } #Preview { - DetailView() + DetailView(insight: News(title: "title", text: "text", link: "link")) } diff --git a/Code Drop_Team 11/Views/EndView.swift b/Code Drop_Team 11/Views/EndView.swift new file mode 100644 index 0000000..591a484 --- /dev/null +++ b/Code Drop_Team 11/Views/EndView.swift @@ -0,0 +1,51 @@ +// +// EndView.swift +// Code Drop_Team 11 +// +// Created by Hyun Lee on 6/15/24. +// + +import SwiftUI + +struct EndView: View { + var body: some View { + + @EnvironmentObject var router: Router + @EnvironmentObject var notificationManager: NotificationManager + + var random = AllQuotes.randomElement() + VStack{ + Spacer() + ZStack{ + RoundedRectangle(cornerRadius: 32) + .frame(width:393, height: 224) + .foregroundColor(.gray) + VStack { + Text("Text(\"\(random?.title ?? "")\")") + Text("\(random?.text ?? "")") +// Spacer() + Text("- \(random?.name ?? "")") + } + } + Spacer() + Button{ +// notificationManager. + router.push(.homeView) +// router.backToRoot() + }label:{ + ZStack{ + RoundedRectangle(cornerRadius: 16) + .foregroundColor(.green) + .frame(width: 354, height:54) + Text("홈으로") + .foregroundStyle(Color(.white)) + } + } + } + + } +} + +#Preview { + EndView() +} diff --git a/Code Drop_Team 11/Views/HomeView.swift b/Code Drop_Team 11/Views/HomeView.swift index 5723ff8..234e1e6 100644 --- a/Code Drop_Team 11/Views/HomeView.swift +++ b/Code Drop_Team 11/Views/HomeView.swift @@ -11,9 +11,12 @@ import SwiftUI struct HomeView: View { @State private var isShowingDetail = false + @EnvironmentObject var router: Router + @EnvironmentObject var notificationManager: NotificationManager + @EnvironmentObject var vm: HealthKitViewModel var body: some View { - NavigationView { + NavigationStack(path: $router.path) { VStack { Spacer() Image("Group 9") @@ -25,19 +28,49 @@ struct HomeView: View { Text("중간에 잠깐 쉬고 걷는 것은 효율에 도움이 돼요.") .foregroundColor(.white) Spacer() - Button("시작하기") { - self.isShowingDetail.toggle() + HStack{ + Button("시작하기") { +// router.backToRoot() + router.push(.listView) + } + .padding() + .foregroundColor(.white) + .background(Color.green) + .cornerRadius(8) + .padding() + .frame(width: 124, height:56) } - .padding() - .foregroundColor(.white) - .background(Color.green) - .cornerRadius(8) - .padding() -// NavigationLink(destination: ListView(), isActive: $isShowingDetail) { + +// NavigationLink(destination: ListView() +// .environmentObject(notificationManager) +// .environmentObject(router) +// , isActive: $isShowingDetail) { // EmptyView() // } } + .navigationDestination(for: Destination.self){ destination in + switch destination{ + case .listView: + ListView() + .environmentObject(notificationManager) + .environmentObject(router) + case .endView: + EndView() + .environmentObject(notificationManager) + .environmentObject(router) + case .homeView: + HomeView() + .environmentObject(notificationManager) + .environmentObject(router) + .environmentObject(vm) + default: + ListView() + .environmentObject(notificationManager) + .environmentObject(router) + } + } + .background(Color.black) .navigationTitle("6월 15일") .foregroundColor(.white) diff --git a/Code Drop_Team 11/Views/ListView.swift b/Code Drop_Team 11/Views/ListView.swift index e9b0f34..2bb0d18 100644 --- a/Code Drop_Team 11/Views/ListView.swift +++ b/Code Drop_Team 11/Views/ListView.swift @@ -8,29 +8,95 @@ import SwiftUI struct ListView: View { - var insights: [Insight] = [ - Insight(title: "중요한 정보는 왼쪽 위에 배치하세요.", detail: "사람들의 시선은 왼쪽 위에서부터 시작됩니다. 가장 중요한 정보는 왼쪽 위에 배치하는 것이 UX적으로 좋습니다."), - Insight(title: "중요한 정보는 왼쪽 위에 배치하세요.", detail: "사람들의 시선은 왼쪽 위에서부터 시작됩니다. 가장 중요한 정보는 왼쪽 위에 배치하는 것이 UX적으로 좋습니다."), - Insight(title: "중요한 정보는 왼쪽 위에 배치하세요.", detail: "사람들의 시선은 왼쪽 위에서부터 시작됩니다. 가장 중요한 정보는 왼쪽 위에 배치하는 것이 UX적으로 좋습니다."), - ] + @EnvironmentObject var router: Router + let timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect() + @EnvironmentObject var vm: HealthKitViewModel + @EnvironmentObject var notificationManager: NotificationManager + @State var isShowingDetail = false + + var array = [News(title: "title", text: "text", link: "link"), + News(title: "title", text: "text", link: "link"), + News(title: "title", text: "text", link: "link"), + News(title: "title", text: "text", link: "link"), + News(title: "title", text: "text", link: "link")] + var body: some View { - NavigationStack { - List { - ForEach(insights) { insight in - NavigationLink { - DetailView(insight: insight) - } label: { - VStack { - Text(insight.title) - .bold() - Text(insight.detail) - } + //notificationManager.todayNews + List(0..