diff --git a/YumemiTraining.xcodeproj/project.pbxproj b/YumemiTraining.xcodeproj/project.pbxproj index 64436b3..e53b1b3 100644 --- a/YumemiTraining.xcodeproj/project.pbxproj +++ b/YumemiTraining.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ F072BB632B7F49F300A8E86F /* SizePreferenceKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = F072BB622B7F49F300A8E86F /* SizePreferenceKey.swift */; }; F072BB652B7F569200A8E86F /* Weather.swift in Sources */ = {isa = PBXBuildFile; fileRef = F072BB642B7F569200A8E86F /* Weather.swift */; }; F0AEFC312B85E2270090F669 /* TemperatureView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0AEFC302B85E2270090F669 /* TemperatureView.swift */; }; + F072BB6B2B7F848600A8E86F /* NewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F072BB6A2B7F848600A8E86F /* NewView.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -32,6 +33,7 @@ F072BB622B7F49F300A8E86F /* SizePreferenceKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SizePreferenceKey.swift; sourceTree = ""; }; F072BB642B7F569200A8E86F /* Weather.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Weather.swift; sourceTree = ""; }; F0AEFC302B85E2270090F669 /* TemperatureView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemperatureView.swift; sourceTree = ""; }; + F072BB6A2B7F848600A8E86F /* NewView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewView.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -66,6 +68,7 @@ isa = PBXGroup; children = ( F072BB492B7F09D400A8E86F /* YumemiTrainingApp.swift */, + F072BB6A2B7F848600A8E86F /* NewView.swift */, F072BB4B2B7F09D400A8E86F /* ForecastView.swift */, F0AEFC302B85E2270090F669 /* TemperatureView.swift */, F072BB602B7F496500A8E86F /* View+.swift */, @@ -167,6 +170,7 @@ F072BB5D2B7F2C9300A8E86F /* WeatherCondition.swift in Sources */, F072BB5B2B7F2B9600A8E86F /* ForecastViewModel.swift in Sources */, F072BB4C2B7F09D400A8E86F /* ForecastView.swift in Sources */, + F072BB6B2B7F848600A8E86F /* NewView.swift in Sources */, F072BB4A2B7F09D400A8E86F /* YumemiTrainingApp.swift in Sources */, F0AEFC312B85E2270090F669 /* TemperatureView.swift in Sources */, F072BB632B7F49F300A8E86F /* SizePreferenceKey.swift in Sources */, diff --git a/YumemiTraining/ForecastView.swift b/YumemiTraining/ForecastView.swift index 3d0ec37..685699f 100644 --- a/YumemiTraining/ForecastView.swift +++ b/YumemiTraining/ForecastView.swift @@ -8,6 +8,7 @@ import SwiftUI struct ForecastView: View { + @Environment(\.dismiss) var dismiss @StateObject var viewModel: ViewModel @State private var buttonsSize: CGSize = .zero @@ -37,7 +38,8 @@ struct ForecastView: View { HStack(spacing: 0) { Button { - // TODO: Close Action + // Close Action + self.dismiss() } label: { Text("Close") } @@ -78,7 +80,6 @@ struct ForecastView: View { Text(message) } } - } } diff --git a/YumemiTraining/ForecastViewModel.swift b/YumemiTraining/ForecastViewModel.swift index fcd9e4c..aea1648 100644 --- a/YumemiTraining/ForecastViewModel.swift +++ b/YumemiTraining/ForecastViewModel.swift @@ -11,7 +11,6 @@ import YumemiWeather @MainActor protocol ForecastViewModel: ObservableObject { var weather: Weather? { get } - var weatherCondition: WeatherCondition? { get } var alertMessage: String? { get } var isAlertPresented: Bool { get set } diff --git a/YumemiTraining/NewView.swift b/YumemiTraining/NewView.swift new file mode 100644 index 0000000..b0306da --- /dev/null +++ b/YumemiTraining/NewView.swift @@ -0,0 +1,31 @@ +// +// NewView.swift +// YumemiTraining +// +// Created by 及川 寛太 on 2024/02/16. +// + +import SwiftUI + +struct NewView: View { + @State var isPresented: Bool = false + + var body: some View { + EmptyView() + .onAppear { + self.isPresented = true + } + .fullScreenCover(isPresented: $isPresented) { + ForecastView( + viewModel: ForecastViewModelImpl() + ) + .onDisappear { + self.isPresented = true + } + } + } +} + +#Preview { + NewView() +} diff --git a/YumemiTraining/YumemiTrainingApp.swift b/YumemiTraining/YumemiTrainingApp.swift index 9fb7a7a..93ca2c2 100644 --- a/YumemiTraining/YumemiTrainingApp.swift +++ b/YumemiTraining/YumemiTrainingApp.swift @@ -11,7 +11,7 @@ import SwiftUI struct YumemiTrainingApp: App { var body: some Scene { WindowGroup { - ForecastView(viewModel: ForecastViewModelImpl()) + NewView() } } }