From 578863eb2cb6f131b3d2d41da09ad06a386bb8ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tormod=20Mork=20Mu=CC=88ller?= <tormodmm@stud.ntnu.no> Date: Wed, 11 May 2022 23:07:54 +0200 Subject: [PATCH] Moved API files and removed unused old files --- .../Resources/projectData.json | 60 ----- .../Resources/userData.json | 10 - .../FetchingApiData/ViewController.swift | 21 -- .../Views/MapView_Old/MapView_Old.swift | 246 ------------------ .../{ => FetchingApiData}/ProfileData.swift | 0 .../{ => FetchingApiData}/ProjectData.swift | 2 +- .../Views/Model/Scaffolding1.swift | 48 ---- 7 files changed, 1 insertion(+), 386 deletions(-) delete mode 100644 stillasMobileApplication/stillasMobileApplication/Resources/projectData.json delete mode 100644 stillasMobileApplication/stillasMobileApplication/Resources/userData.json delete mode 100644 stillasMobileApplication/stillasMobileApplication/Views/FetchingApiData/ViewController.swift delete mode 100644 stillasMobileApplication/stillasMobileApplication/Views/MapView_Old/MapView_Old.swift rename stillasMobileApplication/stillasMobileApplication/Views/Model/{ => FetchingApiData}/ProfileData.swift (100%) rename stillasMobileApplication/stillasMobileApplication/Views/Model/{ => FetchingApiData}/ProjectData.swift (92%) delete mode 100644 stillasMobileApplication/stillasMobileApplication/Views/Model/Scaffolding1.swift diff --git a/stillasMobileApplication/stillasMobileApplication/Resources/projectData.json b/stillasMobileApplication/stillasMobileApplication/Resources/projectData.json deleted file mode 100644 index e308079..0000000 --- a/stillasMobileApplication/stillasMobileApplication/Resources/projectData.json +++ /dev/null @@ -1,60 +0,0 @@ -[ - { - "projectID": 420, - "projectName": "Ntnu i gjøvik", - "latitude": 60.7905060889568, - "longitude": 10.681777071532371, - "period": { - "startDate": "20.02.2020", - "endDate": "10.05.2020" - }, - "size": 240, - "State": "Active", - "adresse":{ - "gate": "Piazza del Colosseo 1", - "postnummer": "0184", - "kommune": "Roma", - "fylke": "Roma" - }, - "Leier": { - "name": "Rome", - "number": 639967700 - }, - "Scaffolding": { - "units":[ - { - "type": "Spire", - "quantity": { - "expected": 3241, - "registered":3241 - } - }, - { - "type": "Flooring", - "quantity": { - "expected": 500000, - "registered":499211 - } - } - ] - }, - "geofence": { - "w-position": { - "latitude": 60.79077759591496, - "longitude": 10.683249543160402 - }, - "x-position": { - "latitude": 60.79015256651516, - "longitude": 10.684424851812308 - }, - "y-position":{ - "latitude": 60.789159847696716, - "longitude": 10.68094413003551 - }, - "z-position":{ - "latitude": 60.78963782726421, - "longitude": 10.680160590934236 - } - } - } -] diff --git a/stillasMobileApplication/stillasMobileApplication/Resources/userData.json b/stillasMobileApplication/stillasMobileApplication/Resources/userData.json deleted file mode 100644 index 90efc39..0000000 --- a/stillasMobileApplication/stillasMobileApplication/Resources/userData.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "id": 232, - "name": "Ola Nordmann", - "dateOfBirth": "01.04.1988", - "role": "Storage", - "admin": false, - "imageName": "UserProfile" - } -] diff --git a/stillasMobileApplication/stillasMobileApplication/Views/FetchingApiData/ViewController.swift b/stillasMobileApplication/stillasMobileApplication/Views/FetchingApiData/ViewController.swift deleted file mode 100644 index f8df0e6..0000000 --- a/stillasMobileApplication/stillasMobileApplication/Views/FetchingApiData/ViewController.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// ViewController.swift -// stillasMobileApplication -// -// Created by Tormod Mork Muller on 06/04/2022. -// -/* -import Foundation -import UIKit - -class ViewController: UIViewController { - override func viewDidLoad() { - super.viewDidLoad() - } -} - -let url = "http://10.212.138.205:8080/stillastracking/v1/api/unit/" -var project: Project -*/ - - diff --git a/stillasMobileApplication/stillasMobileApplication/Views/MapView_Old/MapView_Old.swift b/stillasMobileApplication/stillasMobileApplication/Views/MapView_Old/MapView_Old.swift deleted file mode 100644 index db8e136..0000000 --- a/stillasMobileApplication/stillasMobileApplication/Views/MapView_Old/MapView_Old.swift +++ /dev/null @@ -1,246 +0,0 @@ -// -// MapView.swift -// stillasMobileApplication -// -// Created by Tormod Mork Muller on 24/03/2022. -// -/* -import SwiftUI -import UIKit -import MapKit - - -struct ScaffoldingUnit: Identifiable { - let id = UUID() - let name: String - let size: String - let amount: Int -} - -struct ScaffoldingUnitRow: View { - var scaffolding: ScaffoldingUnit - - var body: some View { - HStack { - VStack(alignment: .leading) { - Text(scaffolding.name) - Text(scaffolding.size).font(.subheadline).foregroundColor(.gray) - } - Spacer() - Text(String(format: "%d", scaffolding.amount)) - .foregroundColor(.gray) - } - } -} - -/** - A MapView responsible for displaying the Apple Maps in the application. - - Inspiration taken from this youtube video: - https://www.youtube.com/watch?v=CyMtjSspJZA - */ -struct MapView_Old: View { - @State private var isInitialOffsetSet = false - @State private var searchText = "" - - var body: some View { - ZStack { - GeometryReader { proxy in - /// MapViewMap responsible for the map view - MapViewMap() - - /// DrawerView responsible for the drawer slide - DrawerView() - } - } -} - - struct DrawerView: View { - //@State var searchQuery = "" - @State var offset: CGFloat = 0 - @State var lastOffset: CGFloat = 0 - @GestureState var gestureOffset: CGFloat = 0 - @State private var isInitialOffsetSet = false - let height = 0 - - - /*let scaffoldingUnits = [ - ScaffoldingUnit(name: "Spir", size: "2m", amount: 1400), - ScaffoldingUnit(name: "Spir", size: "3m", amount: 1500), - ScaffoldingUnit(name: "Lengdebjelke", size: "3m", amount: 480) - /*"Spir 3m", "Spir 2m", "Bærebjelke", "Trapp", "UTV Trapp", "Bunnskrue", "Diagonalstag DS", "Stillaslem Alu", "AL plank B-230 mm", "Rekkverk", "Enrørsbjelke", "Horisontaler"*/ - ]*/ - - - var body: some View { - GeometryReader { proxy in - let height = proxy.frame(in: .global).height - ZStack { - BlurView(style: .systemMaterial) - .clipShape(CustomCorners(corners: [.topLeft, .topRight], radius: 15)) - - VStack { - Capsule() - .fill(Color.gray) - .frame(width: 40, height: 5) - .padding(.top, 7) - - NavView() - /*ZStack { - NavigationView { - List (searchResults) { scaffolding in - NavigationLink(destination: DetailView(scaffolding: scaffolding)) { ScaffoldingUnitRow (scaffolding: scaffolding) } - } - //.listRowBackground(Color.red) - .listStyle(PlainListStyle()) - .searchable(text: $searchQuery) - .navigationTitle("Scaffolding units") - } - .navigationViewStyle(StackNavigationViewStyle()) - //.ignoresSafeArea(.all, edges: .horizontal) - //.frame(minWidth: 0, idealWidth: proxy.frame(in: .global).width, maxWidth: .infinity, minHeight: 0, idealHeight: proxy.frame(in: .global).height, maxHeight: .infinity, alignment: .topLeading) - - }*/ - } - .padding(.horizontal) - .frame(maxHeight: .infinity, alignment: .top) - } - .offset(y: height - 100) - .offset(y: -offset > 0 ? -offset <= (height - 100) ? offset : -(height - 100) : 0) - .gesture(DragGesture().updating($gestureOffset, body: {value, out, _ in - out = value.translation.height - /// onChangeDrawer() updates the offset when a gesture was performed - onChangeDrawer() - }).onEnded({ value in - let maxHeight = height - 100 - /// When the gesture ends, update the placement of the drawer view to fixed position - withAnimation { - if -offset > 100 && -offset < maxHeight / 2 { - offset = -(maxHeight / 3) - } - else if (-offset > maxHeight / 2) { - offset = -maxHeight - } - else { - offset = 0 - } - } - lastOffset = offset - })) - } - .ignoresSafeArea(.all, edges: .bottom) - } - - - /** - onChangeDrawer() resposible for updating the offset when a gesture is performed - */ - func onChangeDrawer (){ - DispatchQueue.main.async { - self.offset = gestureOffset + lastOffset - } - } - /*var searchResults: [ScaffoldingUnit] { - if searchQuery.isEmpty { - return scaffoldingUnits.sorted { $0.name < $1.name } - } else { - return scaffoldingUnits.filter { $0.name.contains(searchQuery) }.sorted { $0.name < $1.name } - } - }*/ - } - - /** - MapViewMap creates a view containing the map - */ - struct MapViewMap: View { - /// Sets the starting location to be Gjøvik (latitude: 60.79574, longitude: 10.69155) - @State var region = MKCoordinateRegion ( - center: CLLocationCoordinate2D( - latitude: 60.79574, - longitude: 10.69155 - ), - /// The zoom level of the application when opened - /// Closer to 0 means greater zoom level - span: MKCoordinateSpan( - latitudeDelta: 0.03, - longitudeDelta: 0.03 - ) - ) - var body: some View { - Map(coordinateRegion: $region) - .ignoresSafeArea() - } - } - - struct MapView_Previews: PreviewProvider { - static var previews: some View { - MapView() - } - } -} - - struct DetailView: View { - var scaffolding: ScaffoldingUnit - - var body: some View { - VStack { - Text(scaffolding.name).font(.title) - - HStack { - Text("\(scaffolding.size) - \(String(format: "%d", scaffolding.amount))") - } - - Spacer() - } - } - } - -struct NavView: View { - @State var searchQuery = "" - - let scaffoldingUnits = [ - ScaffoldingUnit(name: "Spir", size: "2m", amount: 1400), - ScaffoldingUnit(name: "Spir", size: "3m", amount: 1500), - ScaffoldingUnit(name: "Lengdebjelke", size: "3m", amount: 480) - /*"Spir 3m", "Spir 2m", "Bærebjelke", "Trapp", "UTV Trapp", "Bunnskrue", "Diagonalstag DS", "Stillaslem Alu", "AL plank B-230 mm", "Rekkverk", "Enrørsbjelke", "Horisontaler"*/ - ] - - var body: some View { - ZStack { - NavigationView { - List (searchResults) { scaffolding in - NavigationLink(destination: DetailView(scaffolding: scaffolding)) { ScaffoldingUnitRow (scaffolding: scaffolding) } - } - .listStyle(PlainListStyle()) - .searchable(text: $searchQuery) - .navigationTitle("Scaffolding units") - } - .navigationViewStyle(.stack) - } - } - - var searchResults: [ScaffoldingUnit] { - if searchQuery.isEmpty { - return scaffoldingUnits.sorted { $0.name < $1.name } - } else { - return scaffoldingUnits.filter { $0.name.contains(searchQuery) }.sorted { $0.name < $1.name } - } - } - -} - -extension UINavigationController { - override open func viewDidLoad() { - super.viewDidLoad() - - overrideUserInterfaceStyle = .unspecified - - let appearance = UINavigationBarAppearance() - appearance.backgroundColor = UIColor.clear - - navigationBar.standardAppearance = appearance - navigationBar.compactAppearance = appearance - navigationBar.scrollEdgeAppearance = appearance - } -} -*/ diff --git a/stillasMobileApplication/stillasMobileApplication/Views/Model/ProfileData.swift b/stillasMobileApplication/stillasMobileApplication/Views/Model/FetchingApiData/ProfileData.swift similarity index 100% rename from stillasMobileApplication/stillasMobileApplication/Views/Model/ProfileData.swift rename to stillasMobileApplication/stillasMobileApplication/Views/Model/FetchingApiData/ProfileData.swift diff --git a/stillasMobileApplication/stillasMobileApplication/Views/Model/ProjectData.swift b/stillasMobileApplication/stillasMobileApplication/Views/Model/FetchingApiData/ProjectData.swift similarity index 92% rename from stillasMobileApplication/stillasMobileApplication/Views/Model/ProjectData.swift rename to stillasMobileApplication/stillasMobileApplication/Views/Model/FetchingApiData/ProjectData.swift index 2330294..9c7563e 100644 --- a/stillasMobileApplication/stillasMobileApplication/Views/Model/ProjectData.swift +++ b/stillasMobileApplication/stillasMobileApplication/Views/Model/FetchingApiData/ProjectData.swift @@ -9,7 +9,7 @@ import SwiftUI import Foundation class ProjectData: ObservableObject { - @Published var projects = [Project]() + @Published var projects = [Project]() // TODO: REMOVE IF NOT USED IN THE END @Published private var _isLoading: Bool = false var isLoading: Bool { diff --git a/stillasMobileApplication/stillasMobileApplication/Views/Model/Scaffolding1.swift b/stillasMobileApplication/stillasMobileApplication/Views/Model/Scaffolding1.swift deleted file mode 100644 index 270485f..0000000 --- a/stillasMobileApplication/stillasMobileApplication/Views/Model/Scaffolding1.swift +++ /dev/null @@ -1,48 +0,0 @@ -// -// Scaffolding.swift -// stillasMobileApplication -// -// Created by Tormod Mork Muller on 28/03/2022. -// - -import SwiftUI -import Foundation -import CoreLocation -/* -struct Scaffolding: Hashable, Codable, Identifiable { - var id: Int - var type: String - var isFeatured: Bool - - var category: Category - enum Category: String, CaseIterable, Codable { - case flooring = "Flooring" - case spire = "Spire" - case railing = "Railing" - } - - private var imageName: String - var image: Image { - Image(imageName) - } - - var featureImage: Image? { - isFeatured ? Image(imageName + "_feature") : nil - } - - private var coordinates: Coordinates - - var locationCoordinate: CLLocationCoordinate2D { - CLLocationCoordinate2D( - latitude: coordinates.latitude, - longitude: coordinates.longitude - ) - } - - struct Coordinates: Hashable, Codable { - var latitude: Double - var longitude: Double - } - - var batteryLevel: Int -}*/ -- GitLab