mirror of
https://github.com/Mueller-Patrick/DHBW-Service-App.git
synced 2024-12-22 05:15:13 +00:00
Changed file structure
This commit is contained in:
parent
fcf7d97764
commit
bdc3560668
|
@ -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 = "<group>"; };
|
||||
CD9FABA4258EC60600D6D0C5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
CDCD721925912E1200FBF2F5 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
|
||||
/* 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 = "<group>";
|
||||
};
|
||||
CDCD720F25912D3C00FBF2F5 /* App */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CD9FAB80258EC60200D6D0C5 /* DHBW_ServiceApp.swift */,
|
||||
);
|
||||
path = App;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CDCD721025912D4900FBF2F5 /* Views */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CD9FAB82258EC60200D6D0C5 /* ContentView.swift */,
|
||||
CDCD721E25912E1700FBF2F5 /* Tabs */,
|
||||
);
|
||||
path = Views;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CDCD721125912D5400FBF2F5 /* CoreData */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CD9FAB8B258EC60600D6D0C5 /* DHBW_Service.xcdatamodeld */,
|
||||
CD9FAB89258EC60600D6D0C5 /* Persistence.swift */,
|
||||
);
|
||||
path = CoreData;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CDCD721225912D6300FBF2F5 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CD9FAB8E258EC60600D6D0C5 /* Info.plist */,
|
||||
CD9FAB84258EC60600D6D0C5 /* Assets.xcassets */,
|
||||
);
|
||||
path = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CDCD721E25912E1700FBF2F5 /* Tabs */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CDCD721925912E1200FBF2F5 /* HomeView.swift */,
|
||||
);
|
||||
path = Tabs;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* 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)",
|
||||
|
|
|
@ -15,17 +15,17 @@
|
|||
<key>CD9FAB7C258EC60200D6D0C5</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
<true />
|
||||
</dict>
|
||||
<key>CD9FAB92258EC60600D6D0C5</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
<true />
|
||||
</dict>
|
||||
<key>CD9FAB9D258EC60600D6D0C5</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
<true />
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
|
|
|
@ -14,7 +14,7 @@ struct DHBW_ServiceApp: App {
|
|||
var body: some Scene {
|
||||
WindowGroup {
|
||||
ContentView()
|
||||
.environment(\.managedObjectContext, persistenceController.container.viewContext)
|
||||
.environment(\.managedObjectContext, persistenceController.context)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<Item>
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
33
DHBW-Service/Views/ContentView.swift
Normal file
33
DHBW-Service/Views/ContentView.swift
Normal file
|
@ -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)
|
||||
}
|
||||
}
|
20
DHBW-Service/Views/Tabs/HomeView.swift
Normal file
20
DHBW-Service/Views/Tabs/HomeView.swift
Normal file
|
@ -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()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user