From bdc3560668f5d232f46fcf694bae9be7c159f01f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Mu=CC=88ller?= Date: Mon, 21 Dec 2020 20:28:01 +0100 Subject: [PATCH] Changed file structure --- DHBW-Service.xcodeproj/project.pbxproj | 60 +++++++++++-- .../xcschemes/xcschememanagement.plist | 6 +- DHBW-Service/{ => App}/DHBW_ServiceApp.swift | 2 +- DHBW-Service/ContentView.swift | 84 ------------------- .../.xccurrentversion | 0 .../DHBW_Service.xcdatamodel/contents | 0 DHBW-Service/{ => CoreData}/Persistence.swift | 0 .../AccentColor.colorset/Contents.json | 0 .../AppIcon.appiconset/Contents.json | 0 .../Assets.xcassets/Contents.json | 0 .../{ => Supporting Files}/Info.plist | 0 DHBW-Service/Views/ContentView.swift | 33 ++++++++ DHBW-Service/Views/Tabs/HomeView.swift | 20 +++++ 13 files changed, 109 insertions(+), 96 deletions(-) rename DHBW-Service/{ => App}/DHBW_ServiceApp.swift (91%) delete mode 100644 DHBW-Service/ContentView.swift rename DHBW-Service/{ => CoreData}/DHBW_Service.xcdatamodeld/.xccurrentversion (100%) rename DHBW-Service/{ => CoreData}/DHBW_Service.xcdatamodeld/DHBW_Service.xcdatamodel/contents (100%) rename DHBW-Service/{ => CoreData}/Persistence.swift (100%) rename DHBW-Service/{ => Supporting Files}/Assets.xcassets/AccentColor.colorset/Contents.json (100%) rename DHBW-Service/{ => Supporting Files}/Assets.xcassets/AppIcon.appiconset/Contents.json (100%) rename DHBW-Service/{ => Supporting Files}/Assets.xcassets/Contents.json (100%) rename DHBW-Service/{ => Supporting Files}/Info.plist (100%) create mode 100644 DHBW-Service/Views/ContentView.swift create mode 100644 DHBW-Service/Views/Tabs/HomeView.swift diff --git a/DHBW-Service.xcodeproj/project.pbxproj b/DHBW-Service.xcodeproj/project.pbxproj index 60a2e1f..4f5f386 100644 --- a/DHBW-Service.xcodeproj/project.pbxproj +++ b/DHBW-Service.xcodeproj/project.pbxproj @@ -15,6 +15,7 @@ CD9FAB8D258EC60600D6D0C5 /* DHBW_Service.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = CD9FAB8B258EC60600D6D0C5 /* DHBW_Service.xcdatamodeld */; }; CD9FAB98258EC60600D6D0C5 /* DHBW_ServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD9FAB97258EC60600D6D0C5 /* DHBW_ServiceTests.swift */; }; CD9FABA3258EC60600D6D0C5 /* DHBW_ServiceUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD9FABA2258EC60600D6D0C5 /* DHBW_ServiceUITests.swift */; }; + CDCD721A25912E1200FBF2F5 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDCD721925912E1200FBF2F5 /* HomeView.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -49,6 +50,7 @@ CD9FAB9E258EC60600D6D0C5 /* DHBW-ServiceUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "DHBW-ServiceUITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; CD9FABA2258EC60600D6D0C5 /* DHBW_ServiceUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DHBW_ServiceUITests.swift; sourceTree = ""; }; 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 = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -99,12 +101,10 @@ CD9FAB7F258EC60200D6D0C5 /* DHBW-Service */ = { isa = PBXGroup; children = ( - CD9FAB80258EC60200D6D0C5 /* DHBW_ServiceApp.swift */, - CD9FAB82258EC60200D6D0C5 /* ContentView.swift */, - CD9FAB84258EC60600D6D0C5 /* Assets.xcassets */, - CD9FAB89258EC60600D6D0C5 /* Persistence.swift */, - CD9FAB8E258EC60600D6D0C5 /* Info.plist */, - CD9FAB8B258EC60600D6D0C5 /* DHBW_Service.xcdatamodeld */, + CDCD720F25912D3C00FBF2F5 /* App */, + CDCD721025912D4900FBF2F5 /* Views */, + CDCD721125912D5400FBF2F5 /* CoreData */, + CDCD721225912D6300FBF2F5 /* Supporting Files */, CD9FAB86258EC60600D6D0C5 /* Preview Content */, ); path = "DHBW-Service"; @@ -136,6 +136,49 @@ path = "DHBW-ServiceUITests"; sourceTree = ""; }; + CDCD720F25912D3C00FBF2F5 /* App */ = { + isa = PBXGroup; + children = ( + CD9FAB80258EC60200D6D0C5 /* DHBW_ServiceApp.swift */, + ); + path = App; + sourceTree = ""; + }; + CDCD721025912D4900FBF2F5 /* Views */ = { + isa = PBXGroup; + children = ( + CD9FAB82258EC60200D6D0C5 /* ContentView.swift */, + CDCD721E25912E1700FBF2F5 /* Tabs */, + ); + path = Views; + sourceTree = ""; + }; + CDCD721125912D5400FBF2F5 /* CoreData */ = { + isa = PBXGroup; + children = ( + CD9FAB8B258EC60600D6D0C5 /* DHBW_Service.xcdatamodeld */, + CD9FAB89258EC60600D6D0C5 /* Persistence.swift */, + ); + path = CoreData; + sourceTree = ""; + }; + CDCD721225912D6300FBF2F5 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + CD9FAB8E258EC60600D6D0C5 /* Info.plist */, + CD9FAB84258EC60600D6D0C5 /* Assets.xcassets */, + ); + path = "Supporting Files"; + sourceTree = ""; + }; + CDCD721E25912E1700FBF2F5 /* Tabs */ = { + isa = PBXGroup; + children = ( + CDCD721925912E1200FBF2F5 /* HomeView.swift */, + ); + path = Tabs; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -268,6 +311,7 @@ CD9FAB8A258EC60600D6D0C5 /* Persistence.swift in Sources */, CD9FAB83258EC60200D6D0C5 /* ContentView.swift in Sources */, CD9FAB8D258EC60600D6D0C5 /* DHBW_Service.xcdatamodeld in Sources */, + CDCD721A25912E1200FBF2F5 /* HomeView.swift in Sources */, CD9FAB81258EC60200D6D0C5 /* DHBW_ServiceApp.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -429,7 +473,7 @@ DEVELOPMENT_ASSET_PATHS = "\"DHBW-Service/Preview Content\""; DEVELOPMENT_TEAM = HS7KNT4MZ2; ENABLE_PREVIEWS = YES; - INFOPLIST_FILE = "DHBW-Service/Info.plist"; + INFOPLIST_FILE = "DHBW-Service/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -451,7 +495,7 @@ DEVELOPMENT_ASSET_PATHS = "\"DHBW-Service/Preview Content\""; DEVELOPMENT_TEAM = HS7KNT4MZ2; ENABLE_PREVIEWS = YES; - INFOPLIST_FILE = "DHBW-Service/Info.plist"; + INFOPLIST_FILE = "DHBW-Service/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", diff --git a/DHBW-Service.xcodeproj/xcuserdata/patrick.xcuserdatad/xcschemes/xcschememanagement.plist b/DHBW-Service.xcodeproj/xcuserdata/patrick.xcuserdatad/xcschemes/xcschememanagement.plist index 05bc65a..c670c69 100644 --- a/DHBW-Service.xcodeproj/xcuserdata/patrick.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/DHBW-Service.xcodeproj/xcuserdata/patrick.xcuserdatad/xcschemes/xcschememanagement.plist @@ -15,17 +15,17 @@ CD9FAB7C258EC60200D6D0C5 primary - + CD9FAB92258EC60600D6D0C5 primary - + CD9FAB9D258EC60600D6D0C5 primary - + diff --git a/DHBW-Service/DHBW_ServiceApp.swift b/DHBW-Service/App/DHBW_ServiceApp.swift similarity index 91% rename from DHBW-Service/DHBW_ServiceApp.swift rename to DHBW-Service/App/DHBW_ServiceApp.swift index 90d3ce1..de336c7 100644 --- a/DHBW-Service/DHBW_ServiceApp.swift +++ b/DHBW-Service/App/DHBW_ServiceApp.swift @@ -14,7 +14,7 @@ struct DHBW_ServiceApp: App { var body: some Scene { WindowGroup { ContentView() - .environment(\.managedObjectContext, persistenceController.container.viewContext) + .environment(\.managedObjectContext, persistenceController.context) } } } diff --git a/DHBW-Service/ContentView.swift b/DHBW-Service/ContentView.swift deleted file mode 100644 index 0bf7972..0000000 --- a/DHBW-Service/ContentView.swift +++ /dev/null @@ -1,84 +0,0 @@ -// -// ContentView.swift -// DHBW-Service -// -// Created by Patrick Müller on 20.12.20. -// - -import SwiftUI -import CoreData - -struct ContentView: View { - @Environment(\.managedObjectContext) private var viewContext - - @FetchRequest( - sortDescriptors: [NSSortDescriptor(keyPath: \Item.timestamp, ascending: true)], - animation: .default) - private var items: FetchedResults - - var body: some View { - List { - ForEach(items) { item in - Text("Item at \(item.timestamp!, formatter: itemFormatter)") - } - .onDelete(perform: deleteItems) - } - .toolbar { - #if os(iOS) - ToolbarItem(placement: .bottomBar) { - EditButton() - } - #endif - - ToolbarItem(placement: .bottomBar) { - Button(action: addItem) { - Label("Add Item", systemImage: "plus") - } - } - } - } - - private func addItem() { - withAnimation { - let newItem = Item(context: viewContext) - newItem.timestamp = Date() - - do { - try viewContext.save() - } catch { - // Replace this implementation with code to handle the error appropriately. - // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. - let nsError = error as NSError - fatalError("Unresolved error \(nsError), \(nsError.userInfo)") - } - } - } - - private func deleteItems(offsets: IndexSet) { - withAnimation { - offsets.map { items[$0] }.forEach(viewContext.delete) - - do { - try viewContext.save() - } catch { - // Replace this implementation with code to handle the error appropriately. - // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. - let nsError = error as NSError - fatalError("Unresolved error \(nsError), \(nsError.userInfo)") - } - } - } -} - -private let itemFormatter: DateFormatter = { - let formatter = DateFormatter() - formatter.dateStyle = .short - formatter.timeStyle = .medium - return formatter -}() - -struct ContentView_Previews: PreviewProvider { - static var previews: some View { - ContentView().environment(\.managedObjectContext, PersistenceController.preview.container.viewContext) - } -} diff --git a/DHBW-Service/DHBW_Service.xcdatamodeld/.xccurrentversion b/DHBW-Service/CoreData/DHBW_Service.xcdatamodeld/.xccurrentversion similarity index 100% rename from DHBW-Service/DHBW_Service.xcdatamodeld/.xccurrentversion rename to DHBW-Service/CoreData/DHBW_Service.xcdatamodeld/.xccurrentversion diff --git a/DHBW-Service/DHBW_Service.xcdatamodeld/DHBW_Service.xcdatamodel/contents b/DHBW-Service/CoreData/DHBW_Service.xcdatamodeld/DHBW_Service.xcdatamodel/contents similarity index 100% rename from DHBW-Service/DHBW_Service.xcdatamodeld/DHBW_Service.xcdatamodel/contents rename to DHBW-Service/CoreData/DHBW_Service.xcdatamodeld/DHBW_Service.xcdatamodel/contents diff --git a/DHBW-Service/Persistence.swift b/DHBW-Service/CoreData/Persistence.swift similarity index 100% rename from DHBW-Service/Persistence.swift rename to DHBW-Service/CoreData/Persistence.swift diff --git a/DHBW-Service/Assets.xcassets/AccentColor.colorset/Contents.json b/DHBW-Service/Supporting Files/Assets.xcassets/AccentColor.colorset/Contents.json similarity index 100% rename from DHBW-Service/Assets.xcassets/AccentColor.colorset/Contents.json rename to DHBW-Service/Supporting Files/Assets.xcassets/AccentColor.colorset/Contents.json diff --git a/DHBW-Service/Assets.xcassets/AppIcon.appiconset/Contents.json b/DHBW-Service/Supporting Files/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from DHBW-Service/Assets.xcassets/AppIcon.appiconset/Contents.json rename to DHBW-Service/Supporting Files/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/DHBW-Service/Assets.xcassets/Contents.json b/DHBW-Service/Supporting Files/Assets.xcassets/Contents.json similarity index 100% rename from DHBW-Service/Assets.xcassets/Contents.json rename to DHBW-Service/Supporting Files/Assets.xcassets/Contents.json diff --git a/DHBW-Service/Info.plist b/DHBW-Service/Supporting Files/Info.plist similarity index 100% rename from DHBW-Service/Info.plist rename to DHBW-Service/Supporting Files/Info.plist diff --git a/DHBW-Service/Views/ContentView.swift b/DHBW-Service/Views/ContentView.swift new file mode 100644 index 0000000..8a4fbba --- /dev/null +++ b/DHBW-Service/Views/ContentView.swift @@ -0,0 +1,33 @@ +// +// ContentView.swift +// DHBW-Service +// +// Created by Patrick Müller on 20.12.20. +// + +import SwiftUI +import CoreData + +struct ContentView: View { + @State private var selection = 0 + + var body: some View { + TabView(selection: $selection) { + HomeView() + .tabItem { + VStack { + Image(systemName: "house.fill") + Text("Home") + } + } + .tag(0) + } + } +} + +struct ContentView_Previews: PreviewProvider { + static var previews: some View { + ContentView() + .preferredColorScheme(.dark) + } +} diff --git a/DHBW-Service/Views/Tabs/HomeView.swift b/DHBW-Service/Views/Tabs/HomeView.swift new file mode 100644 index 0000000..d51f9d0 --- /dev/null +++ b/DHBW-Service/Views/Tabs/HomeView.swift @@ -0,0 +1,20 @@ +// +// HomeView.swift +// DHBW-Service +// +// Created by Patrick Müller on 21.12.20. +// + +import SwiftUI + +struct HomeView: View { + var body: some View { + Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + } +} + +struct HomeView_Previews: PreviewProvider { + static var previews: some View { + HomeView() + } +}