Skip to content

Commit

Permalink
Feat #16 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyun Lee committed Jun 15, 2024
1 parent 7c4d4ca commit 168956f
Show file tree
Hide file tree
Showing 11 changed files with 232 additions and 39 deletions.
Binary file modified Code Drop_Team 11/.DS_Store
Binary file not shown.
16 changes: 12 additions & 4 deletions Code Drop_Team 11/Code Drop_Team 11.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -60,6 +62,8 @@
6B7453402C1D062B000C2955 /* DetailView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetailView.swift; sourceTree = "<group>"; };
6B7453412C1D062B000C2955 /* HomeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
6B7453422C1D062B000C2955 /* ListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListView.swift; sourceTree = "<group>"; };
6B9310892C1D19CD00A1F361 /* RouterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RouterModel.swift; sourceTree = "<group>"; };
6B93108B2C1D1DBB00A1F361 /* EndView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EndView.swift; sourceTree = "<group>"; };
89937B5B2C1CC06D00ED70E3 /* NotificationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationManager.swift; sourceTree = "<group>"; };
89937B5E2C1CCED800ED70E3 /* News.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = News.swift; sourceTree = "<group>"; };
89937B602C1CCF8000ED70E3 /* AllNews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllNews.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -94,6 +98,7 @@
6B7452FB2C1CB36B000C2955 = {
isa = PBXGroup;
children = (
6B9310892C1D19CD00A1F361 /* RouterModel.swift */,
6B7453432C1D062B000C2955 /* Views */,
6B7453062C1CB36B000C2955 /* Code Drop_Team 11 */,
6B7453172C1CB36C000C2955 /* Code Drop_Team 11Tests */,
Expand Down Expand Up @@ -160,6 +165,7 @@
6B7453402C1D062B000C2955 /* DetailView.swift */,
6B7453412C1D062B000C2955 /* HomeView.swift */,
6B7453422C1D062B000C2955 /* ListView.swift */,
6B93108B2C1D1DBB00A1F361 /* EndView.swift */,
);
path = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand All @@ -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;
Expand All @@ -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";
Expand All @@ -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;
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

}
}
}
4 changes: 1 addition & 3 deletions Code Drop_Team 11/Code Drop_Team 11/DataModel/News.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
//

import Foundation
import SwiftData

@Model
class News: Hashable, Equatable {
class News: Hashable, Equatable, Identifiable {
// var id: ObjectIdentifier

var id = UUID()
Expand Down
4 changes: 2 additions & 2 deletions Code Drop_Team 11/Code Drop_Team 11/NotificationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
29 changes: 29 additions & 0 deletions Code Drop_Team 11/RouterModel.swift
Original file line number Diff line number Diff line change
@@ -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
}

9 changes: 6 additions & 3 deletions Code Drop_Team 11/Views/DetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -19,7 +22,7 @@ struct DetailView: View {
Text(insight.title)
.font(.largeTitle)
.padding()
Text(insight.detail)
Text(insight.text)
.font(.body)
.padding()
Spacer()
Expand All @@ -40,5 +43,5 @@ struct DetailView: View {
}

#Preview {
DetailView()
DetailView(insight: News(title: "title", text: "text", link: "link"))
}
51 changes: 51 additions & 0 deletions Code Drop_Team 11/Views/EndView.swift
Original file line number Diff line number Diff line change
@@ -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()
}
51 changes: 42 additions & 9 deletions Code Drop_Team 11/Views/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand Down
Loading

0 comments on commit 168956f

Please sign in to comment.