Skip to content
Snippets Groups Projects
Commit 578863eb authored by Tormod Mork Müller's avatar Tormod Mork Müller :computer:
Browse files

Moved API files and removed unused old files

parent 6f10ee6d
Branches
No related tags found
1 merge request!110Made changes for the Mobile application
[
{
"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
}
}
}
]
[
{
"id": 232,
"name": "Ola Nordmann",
"dateOfBirth": "01.04.1988",
"role": "Storage",
"admin": false,
"imageName": "UserProfile"
}
]
//
// 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
*/
//
// 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
}
}
*/
......@@ -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 {
......
//
// 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
}*/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment