From cfa09ec7aa0b8acf928b42410499b4913b11f664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Mu=CC=88ller?= Date: Mon, 21 Dec 2020 21:01:12 +0100 Subject: [PATCH] Added settings view for first opening --- DHBW-Service.xcodeproj/project.pbxproj | 12 +++++++++ DHBW-Service/Views/ContentView.swift | 6 +---- .../Views/Other/FirstOpeningSettings.swift | 26 +++++++++++++++++++ 3 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 DHBW-Service/Views/Other/FirstOpeningSettings.swift diff --git a/DHBW-Service.xcodeproj/project.pbxproj b/DHBW-Service.xcodeproj/project.pbxproj index be08bcb..8bd7118 100644 --- a/DHBW-Service.xcodeproj/project.pbxproj +++ b/DHBW-Service.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ CD9FABA3258EC60600D6D0C5 /* DHBW_ServiceUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD9FABA2258EC60600D6D0C5 /* DHBW_ServiceUITests.swift */; }; CDCD721A25912E1200FBF2F5 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDCD721925912E1200FBF2F5 /* HomeView.swift */; }; CDCD72242591316500FBF2F5 /* LocalSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDCD72232591316500FBF2F5 /* LocalSettings.swift */; }; + CDCD7230259135C500FBF2F5 /* FirstOpeningSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDCD722F259135C500FBF2F5 /* FirstOpeningSettings.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -53,6 +54,7 @@ CD9FABA4258EC60600D6D0C5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; CDCD721925912E1200FBF2F5 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = ""; }; CDCD72232591316500FBF2F5 /* LocalSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalSettings.swift; sourceTree = ""; }; + CDCD722F259135C500FBF2F5 /* FirstOpeningSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirstOpeningSettings.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -152,6 +154,7 @@ children = ( CD9FAB82258EC60200D6D0C5 /* ContentView.swift */, CDCD721E25912E1700FBF2F5 /* Tabs */, + CDCD722E259135AD00FBF2F5 /* Other */, ); path = Views; sourceTree = ""; @@ -190,6 +193,14 @@ path = Observables; sourceTree = ""; }; + CDCD722E259135AD00FBF2F5 /* Other */ = { + isa = PBXGroup; + children = ( + CDCD722F259135C500FBF2F5 /* FirstOpeningSettings.swift */, + ); + path = Other; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -319,6 +330,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + CDCD7230259135C500FBF2F5 /* FirstOpeningSettings.swift in Sources */, CD9FAB8A258EC60600D6D0C5 /* Persistence.swift in Sources */, CD9FAB83258EC60200D6D0C5 /* ContentView.swift in Sources */, CDCD72242591316500FBF2F5 /* LocalSettings.swift in Sources */, diff --git a/DHBW-Service/Views/ContentView.swift b/DHBW-Service/Views/ContentView.swift index 7f4a4b0..cff9d32 100644 --- a/DHBW-Service/Views/ContentView.swift +++ b/DHBW-Service/Views/ContentView.swift @@ -26,11 +26,7 @@ struct ContentView: View { .tag(0) } } else { - Button(action: { - self.settings.isFirstOpening = !self.settings.isFirstOpening - }){ - Text("First opening toggle") - } + FirstOpeningSettings() } } } diff --git a/DHBW-Service/Views/Other/FirstOpeningSettings.swift b/DHBW-Service/Views/Other/FirstOpeningSettings.swift new file mode 100644 index 0000000..7fa5e67 --- /dev/null +++ b/DHBW-Service/Views/Other/FirstOpeningSettings.swift @@ -0,0 +1,26 @@ +// +// FirstOpeningSettings.swift +// DHBW-Service +// +// Created by Patrick Müller on 21.12.20. +// + +import SwiftUI + +struct FirstOpeningSettings: View { + @EnvironmentObject var settings: LocalSettings + + var body: some View { + Button(action: { + self.settings.isFirstOpening = !self.settings.isFirstOpening + }){ + Text("First opening toggle") + } + } +} + +struct FirstOpeningSettings_Previews: PreviewProvider { + static var previews: some View { + FirstOpeningSettings() + } +}