Commit c9d655b9 authored by domenicw's avatar domenicw
Browse files

More work on Networking

Events, Joboffers are now displayed correctly
Home is not shown anymore
parent 8f78ea45
......@@ -66,15 +66,22 @@
B0AF913E2157CE2D008F3B80 /* NetworkManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0AF913D2157CE2D008F3B80 /* NetworkManager.swift */; };
B0AF91402157CF50008F3B80 /* AMIVApiEvents.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0AF913F2157CF50008F3B80 /* AMIVApiEvents.swift */; };
B0AF91422157D192008F3B80 /* KeychainKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0AF91412157D192008F3B80 /* KeychainKey.swift */; };
B0AF91452157D34E008F3B80 /* JobsResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0AF91442157D34E008F3B80 /* JobsResponse.swift */; };
B0AF91452157D34E008F3B80 /* JobOffersResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0AF91442157D34E008F3B80 /* JobOffersResponse.swift */; };
B0AF91472157D36E008F3B80 /* EventsResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0AF91462157D36E008F3B80 /* EventsResponse.swift */; };
B0AF914B2157DE2A008F3B80 /* EventItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0AF914A2157DE2A008F3B80 /* EventItem.swift */; };
B0AF914B2157DE2A008F3B80 /* AMIVEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0AF914A2157DE2A008F3B80 /* AMIVEvent.swift */; };
B0D3F92B21552E8E005209FF /* UIButton+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0D3F92A21552E8E005209FF /* UIButton+Extension.swift */; };
B0E22FDA216DD2E0002317D6 /* AMIVApiJobs.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0E22FD9216DD2E0002317D6 /* AMIVApiJobs.swift */; };
B0E22FDC216DD41D002317D6 /* JobOffer.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0E22FDB216DD41D002317D6 /* JobOffer.swift */; };
B0E22FDF216DD754002317D6 /* AMIVApiStudyDocuments.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0E22FDE216DD754002317D6 /* AMIVApiStudyDocuments.swift */; };
B0E22FE1216E93EF002317D6 /* StudyDocumentResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0E22FE0216E93EF002317D6 /* StudyDocumentResponse.swift */; };
B0E22FE3216E9448002317D6 /* StudyDocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0E22FE2216E9448002317D6 /* StudyDocument.swift */; };
B0F5B94F217137EC005E4591 /* Local+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0F5B94E217137EC005E4591 /* Local+Extension.swift */; };
B0F5B9512171408E005E4591 /* AMIVMedia.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0F5B9502171408E005E4591 /* AMIVMedia.swift */; };
B0F5B955217142E3005E4591 /* AMIVMediaType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0F5B954217142E3005E4591 /* AMIVMediaType.swift */; };
B0F5B9582171480B005E4591 /* JobsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0F5B9572171480B005E4591 /* JobsViewModel.swift */; };
B0F5B95A2171624D005E4591 /* GenericInfoViewControllerAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0F5B9592171624D005E4591 /* GenericInfoViewControllerAction.swift */; };
B0F5B95C2171786C005E4591 /* AMIVApiUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0F5B95B2171786C005E4591 /* AMIVApiUser.swift */; };
B0F5B95F217179D9005E4591 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0F5B95E217179D9005E4591 /* User.swift */; };
B0FE2EFC2154179600F3D073 /* JobsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0FE2EFB2154179600F3D073 /* JobsViewController.swift */; };
B0FE2EFF21541A2B00F3D073 /* EventsNavigator.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0FE2EFE21541A2B00F3D073 /* EventsNavigator.swift */; };
B0FE2F0221541A6300F3D073 /* EventsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0FE2F0121541A6300F3D073 /* EventsViewController.swift */; };
......@@ -169,15 +176,22 @@
B0AF913D2157CE2D008F3B80 /* NetworkManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkManager.swift; sourceTree = "<group>"; };
B0AF913F2157CF50008F3B80 /* AMIVApiEvents.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AMIVApiEvents.swift; sourceTree = "<group>"; };
B0AF91412157D192008F3B80 /* KeychainKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainKey.swift; sourceTree = "<group>"; };
B0AF91442157D34E008F3B80 /* JobsResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JobsResponse.swift; sourceTree = "<group>"; };
B0AF91442157D34E008F3B80 /* JobOffersResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JobOffersResponse.swift; sourceTree = "<group>"; };
B0AF91462157D36E008F3B80 /* EventsResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventsResponse.swift; sourceTree = "<group>"; };
B0AF914A2157DE2A008F3B80 /* EventItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventItem.swift; sourceTree = "<group>"; };
B0AF914A2157DE2A008F3B80 /* AMIVEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AMIVEvent.swift; sourceTree = "<group>"; };
B0D3F92A21552E8E005209FF /* UIButton+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIButton+Extension.swift"; sourceTree = "<group>"; };
B0E22FD9216DD2E0002317D6 /* AMIVApiJobs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AMIVApiJobs.swift; sourceTree = "<group>"; };
B0E22FDB216DD41D002317D6 /* JobOffer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JobOffer.swift; sourceTree = "<group>"; };
B0E22FDE216DD754002317D6 /* AMIVApiStudyDocuments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AMIVApiStudyDocuments.swift; sourceTree = "<group>"; };
B0E22FE0216E93EF002317D6 /* StudyDocumentResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudyDocumentResponse.swift; sourceTree = "<group>"; };
B0E22FE2216E9448002317D6 /* StudyDocument.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudyDocument.swift; sourceTree = "<group>"; };
B0F5B94E217137EC005E4591 /* Local+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Local+Extension.swift"; sourceTree = "<group>"; };
B0F5B9502171408E005E4591 /* AMIVMedia.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AMIVMedia.swift; sourceTree = "<group>"; };
B0F5B954217142E3005E4591 /* AMIVMediaType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AMIVMediaType.swift; sourceTree = "<group>"; };
B0F5B9572171480B005E4591 /* JobsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JobsViewModel.swift; sourceTree = "<group>"; };
B0F5B9592171624D005E4591 /* GenericInfoViewControllerAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenericInfoViewControllerAction.swift; sourceTree = "<group>"; };
B0F5B95B2171786C005E4591 /* AMIVApiUser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AMIVApiUser.swift; sourceTree = "<group>"; };
B0F5B95E217179D9005E4591 /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
B0FE2EFB2154179600F3D073 /* JobsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JobsViewController.swift; sourceTree = "<group>"; };
B0FE2EFE21541A2B00F3D073 /* EventsNavigator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventsNavigator.swift; sourceTree = "<group>"; };
B0FE2F0121541A6300F3D073 /* EventsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventsViewController.swift; sourceTree = "<group>"; };
......@@ -370,6 +384,7 @@
B050E15721516E160090CB79 /* Model */ = {
isa = PBXGroup;
children = (
B0F5B956217147FC005E4591 /* Jobs */,
B048377A21582C4500AFA689 /* Events */,
B050E1882151A4850090CB79 /* Settings Model */,
);
......@@ -392,6 +407,7 @@
B050E1932151A9750090CB79 /* Bundle+Extension.swift */,
B0D3F92A21552E8E005209FF /* UIButton+Extension.swift */,
B048377D21582D4E00AFA689 /* String+Extension.swift */,
B0F5B94E217137EC005E4591 /* Local+Extension.swift */,
);
path = Extension;
sourceTree = "<group>";
......@@ -564,6 +580,7 @@
B05EC253216BFE6600D5AD99 /* AMIVApiSession.swift */,
B0E22FD9216DD2E0002317D6 /* AMIVApiJobs.swift */,
B0E22FDE216DD754002317D6 /* AMIVApiStudyDocuments.swift */,
B0F5B95B2171786C005E4591 /* AMIVApiUser.swift */,
);
path = EndPoint;
sourceTree = "<group>";
......@@ -603,6 +620,9 @@
B0AF91432157D320008F3B80 /* Model */ = {
isa = PBXGroup;
children = (
B0F5B9502171408E005E4591 /* AMIVMedia.swift */,
B0F5B954217142E3005E4591 /* AMIVMediaType.swift */,
B0F5B95D217179C6005E4591 /* User */,
B0E22FDD216DD73D002317D6 /* Study Documents */,
B05EC250216BFCC700D5AD99 /* Authentication */,
B0AF91492157DE14008F3B80 /* Jobs */,
......@@ -615,7 +635,7 @@
isa = PBXGroup;
children = (
B0AF91462157D36E008F3B80 /* EventsResponse.swift */,
B0AF914A2157DE2A008F3B80 /* EventItem.swift */,
B0AF914A2157DE2A008F3B80 /* AMIVEvent.swift */,
);
path = Events;
sourceTree = "<group>";
......@@ -623,7 +643,7 @@
B0AF91492157DE14008F3B80 /* Jobs */ = {
isa = PBXGroup;
children = (
B0AF91442157D34E008F3B80 /* JobsResponse.swift */,
B0AF91442157D34E008F3B80 /* JobOffersResponse.swift */,
B0E22FDB216DD41D002317D6 /* JobOffer.swift */,
);
path = Jobs;
......@@ -638,6 +658,22 @@
path = "Study Documents";
sourceTree = "<group>";
};
B0F5B956217147FC005E4591 /* Jobs */ = {
isa = PBXGroup;
children = (
B0F5B9572171480B005E4591 /* JobsViewModel.swift */,
);
path = Jobs;
sourceTree = "<group>";
};
B0F5B95D217179C6005E4591 /* User */ = {
isa = PBXGroup;
children = (
B0F5B95E217179D9005E4591 /* User.swift */,
);
path = User;
sourceTree = "<group>";
};
B0FE2EFD21541A1000F3D073 /* Events */ = {
isa = PBXGroup;
children = (
......@@ -670,6 +706,7 @@
B0FE2F0521541C5C00F3D073 /* GenericInfoViewController.swift */,
B0FE2F072154230500F3D073 /* GenericInfoViewControllerDelegate.swift */,
B0FE2F092154237C00F3D073 /* GenericInfoViewControllerModel.swift */,
B0F5B9592171624D005E4591 /* GenericInfoViewControllerAction.swift */,
);
path = Info;
sourceTree = "<group>";
......@@ -811,7 +848,7 @@
B0AF91422157D192008F3B80 /* KeychainKey.swift in Sources */,
B0FE2F16215514E600F3D073 /* QuickLookDataSource.swift in Sources */,
B050E17821517EF50090CB79 /* AmivMicroAppModel.swift in Sources */,
B0AF91452157D34E008F3B80 /* JobsResponse.swift in Sources */,
B0AF91452157D34E008F3B80 /* JobOffersResponse.swift in Sources */,
B050E16E215178BA0090CB79 /* AmivMicroAppsNavigator.swift in Sources */,
B050E18C2151A54D0090CB79 /* SettingsCellModel.swift in Sources */,
B0E22FDF216DD754002317D6 /* AMIVApiStudyDocuments.swift in Sources */,
......@@ -828,12 +865,15 @@
B050E171215179A30090CB79 /* AmivMicroAppsViewController.swift in Sources */,
B050E18A2151A4A80090CB79 /* SettingsAction.swift in Sources */,
B0E22FE3216E9448002317D6 /* StudyDocument.swift in Sources */,
B0F5B955217142E3005E4591 /* AMIVMediaType.swift in Sources */,
B07A8A0421523AB8003CC2D8 /* InfoViewControllerModel.swift in Sources */,
B0AF913A2157BF11008F3B80 /* NetworkRouter.swift in Sources */,
B0AF913E2157CE2D008F3B80 /* NetworkManager.swift in Sources */,
B050E146215169D00090CB79 /* RootNavigator.swift in Sources */,
B0F5B95A2171624D005E4591 /* GenericInfoViewControllerAction.swift in Sources */,
B0AF91342157B430008F3B80 /* NetworkError.swift in Sources */,
B05EC24F216BF9B900D5AD99 /* RouterError.swift in Sources */,
B0F5B9582171480B005E4591 /* JobsViewModel.swift in Sources */,
B07A8A0621523B96003CC2D8 /* InfoViewControllerDelegate.swift in Sources */,
B0E22FDC216DD41D002317D6 /* JobOffer.swift in Sources */,
B050E1872151A3C40090CB79 /* SettingsViewControllerDelegate.swift in Sources */,
......@@ -846,7 +886,9 @@
B050E1972151AAC40090CB79 /* SettingsNavigator.swift in Sources */,
B0E22FDA216DD2E0002317D6 /* AMIVApiJobs.swift in Sources */,
B050E1942151A9750090CB79 /* Bundle+Extension.swift in Sources */,
B0F5B95F217179D9005E4591 /* User.swift in Sources */,
B050E14E21516AFE0090CB79 /* AppNavigator.swift in Sources */,
B0F5B9512171408E005E4591 /* AMIVMedia.swift in Sources */,
B0FE2F0A2154237C00F3D073 /* GenericInfoViewControllerModel.swift in Sources */,
B050E18121519B390090CB79 /* LoginViewControllerDelegate.swift in Sources */,
B0845924215B78C700479D27 /* AmivMicroAppCheckin.swift in Sources */,
......@@ -856,8 +898,9 @@
B0FE2F0621541C5C00F3D073 /* GenericInfoViewController.swift in Sources */,
B0AF91472157D36E008F3B80 /* EventsResponse.swift in Sources */,
B0FE2F1221550C0100F3D073 /* JobsViewControllerDelegate.swift in Sources */,
B0AF914B2157DE2A008F3B80 /* EventItem.swift in Sources */,
B0AF914B2157DE2A008F3B80 /* AMIVEvent.swift in Sources */,
B0845926215B797200479D27 /* AmivMicroApp.swift in Sources */,
B0F5B94F217137EC005E4591 /* Local+Extension.swift in Sources */,
B0FE2F082154230500F3D073 /* GenericInfoViewControllerDelegate.swift in Sources */,
B050E1852151A3700090CB79 /* SettingsViewController.swift in Sources */,
B0FE2F102154495100F3D073 /* BlurButton.swift in Sources */,
......@@ -880,6 +923,7 @@
B050E15F2151735A0090CB79 /* UIColor+Extension.swift in Sources */,
B0845928215B7AF200479D27 /* AmivMicroAppBarcode.swift in Sources */,
B050E17F215195B50090CB79 /* UIFont+Extension.swift in Sources */,
B0F5B95C2171786C005E4591 /* AMIVApiUser.swift in Sources */,
B0AF912E2157B19A008F3B80 /* HTTPMethod.swift in Sources */,
B0AF91302157B26C008F3B80 /* HTTPTask.swift in Sources */,
B07A8A022152384F003CC2D8 /* InfoItemModel.swift in Sources */,
......
......@@ -10,5 +10,18 @@
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>B050E11B215169230090CB79</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>B050E12F215169250090CB79</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
//
// Local+Extension.swift
// Amiv
//
// Created by Domenic Wüthrich on 12.10.18.
// Copyright © 2018 Amiv an der ETH. All rights reserved.
//
import Foundation
public extension Locale {
public enum AppLanguage {
case german
case english
}
public static func current() -> AppLanguage {
if ["de-DE", "de-CH", "de-AT", "de-LI", "de-LU"].contains(Locale.current.languageCode) {
return .german
} else {
return .english
}
}
public static func getLocalizedString(english: String, german: String) -> String {
switch Locale.current() {
case .english:
return english
case .german:
return german
}
}
}
......@@ -13,6 +13,7 @@ public enum KeychainKey: String {
case username
case password
case authToken
case sessionID
}
......
......@@ -10,15 +10,27 @@ import Foundation
public struct EventViewModel {
let title: String
let eventResponse: EventsResponse?
// MARK: - Variables
let viewTitle: String
let events: [AMIVEvent]
// MARK: - Initializers
public init(viewTitle: String, events: [AMIVEvent]) {
self.viewTitle = viewTitle
self.events = events
}
public init(response: EventsResponse) {
self.init(viewTitle: "Events", events: response.events)
}
}
extension EventViewModel {
public static func create(with response: EventsResponse?) -> EventViewModel {
return self.init(title: "Events", eventResponse: response)
public static func empty() -> EventViewModel {
return self.init(viewTitle: "Events", events: [])
}
}
//
// JobsViewModel.swift
// Amiv
//
// Created by Domenic Wüthrich on 12.10.18.
// Copyright © 2018 Amiv an der ETH. All rights reserved.
//
import Foundation
public struct JobsViewModel {
// MARK: - Variables
var viewTitle: String
var jobOffers: [JobOffer]
// MARK: - Initializers
public init(viewTitle: String, jobOffers: [JobOffer]) {
self.viewTitle = viewTitle
self.jobOffers = jobOffers
}
public init(jobOffers: [JobOffer]) {
self.init(viewTitle: "Jobs", jobOffers: jobOffers)
}
}
extension JobsViewModel {
public static func empty() -> JobsViewModel {
return .init(jobOffers: [])
}
}
......@@ -24,7 +24,7 @@ public class AppNavigator: Navigator {
// MARK: - Tabs
private enum Tab: Int {
case home
//case home
case events
case jobs
case apps
......@@ -43,7 +43,7 @@ public class AppNavigator: Navigator {
private func createTabs() {
// Create all tabs
self.createHomeTab()
//self.createHomeTab()
self.createEventsTab()
self.createJobsTab()
self.createAmivApplicationTab()
......@@ -51,7 +51,7 @@ public class AppNavigator: Navigator {
// Make tabBarController ready
self.tabBarController.viewControllers = self.childNavigators.map({ $0.rootViewController })
self.tabBarController.selectedIndex = Tab.home.rawValue
self.tabBarController.selectedIndex = Tab.events.rawValue
self.tabBarController.tabBar.tintColor = .amivRed
}
......
......@@ -24,7 +24,7 @@ public class EventsNavigator: Navigator {
// MARK: - Initializers
public init() {
let events = EventsViewController(model: .create(with: nil))
let events = EventsViewController(model: .empty())
self.navigationController = UINavigationController(rootViewController: events)
self.navigationController.navigationBar.tintColor = .amivRed
events.delegate = self
......@@ -44,22 +44,37 @@ public class EventsNavigator: Navigator {
extension EventsNavigator: EventsViewControllerDelegate {
public func didSelectEvent(_ viewController: EventsViewController, section: Int, index: Int) {
debugPrint("didSelect section: \(section) and index: \(index)")
public func didSelectEvent(_ viewController: EventsViewController, event: AMIVEvent) {
// TODO: - Retrieve event, convert into GenericInfoViewControllerModel and show Detail View
// let model = ...
self.goToEventDetailView(model: .createTestModel())
if let eventImage = event.image {
self.networkManager.getImage(for: eventImage.filePath) { (data, error) in
let model: GenericInfoViewControllerModel
if error == nil, let data = data {
let image = UIImage(data: data)
model = GenericInfoViewControllerModel(event: event, image: image)
} else {
model = GenericInfoViewControllerModel(event: event, image: nil)
}
DispatchQueue.main.async {
self.goToEventDetailView(model: model)
}
}
} else {
let model = GenericInfoViewControllerModel(event: event, image: nil)
self.goToEventDetailView(model: model)
}
}
public func refreshData(_ viewController: EventsViewController) {
debugPrint("Refreshing Events Data")
self.networkManager.getEvents { (response, error) in
if let response = response {
guard let response = response else {
DispatchQueue.main.async {
viewController.model = .create(with: response)
viewController.tableView.refreshControl?.endRefreshing()
}
return
}
DispatchQueue.main.async {
viewController.model = EventViewModel(response: response)
}
}
}
......@@ -68,7 +83,7 @@ extension EventsNavigator: EventsViewControllerDelegate {
extension EventsNavigator: GenericInfoViewControllerDelegate {
public func buttonTapped(_ viewController: GenericInfoViewController) {
public func buttonTapped(_ viewController: GenericInfoViewController, action: GenericInfoViewControllerAction) {
debugPrint("Info View button tapped")
// TODO: - Sign up for event
......
......@@ -27,19 +27,19 @@ public class JobsNavigator: Navigator {
// MARK: - Initializers
public init() {
let jobs = JobsViewController()
let jobs = JobsViewController(model: JobsViewModel.empty())
self.navigationController = UINavigationController(rootViewController: jobs)
self.navigationController.navigationBar.tintColor = .amivRed
jobs.delegate = self
#warning("replace with proper code")
manager.getJobOffers { (offers, error) in
guard error == nil else {
debugPrint(error)
guard error == nil, let offers = offers else {
#warning("handle error")
return
}
debugPrint(offers)
let model = JobsViewModel(jobOffers: offers)
jobs.model = model
}
}
......@@ -55,36 +55,71 @@ public class JobsNavigator: Navigator {
extension JobsNavigator: JobsViewControllerDelegate {
public func didSelectJob(_ viewController: JobsViewController, section: Int, index: Int) {
debugPrint("didSelect section: \(section) and index: \(index)")
// TODO: - Retrieve job, convert into GenericInfoViewControllerModel and show Detail View
// let model = ...
self.goToJobsDetailView(model: .createTestModel())
public func didSelectJob(_ viewController: JobsViewController, job: JobOffer) {
self.manager.getImage(for: job.logo.filePath) { (data, error) in
DispatchQueue.main.async {
guard error == nil, let data = data else {
let model = GenericInfoViewControllerModel(jobOffer: job, image: nil)
self.goToJobsDetailView(model: model)
return
}
let image = UIImage(data: data)
let model = GenericInfoViewControllerModel(jobOffer: job, image: image)
self.goToJobsDetailView(model: model)
}
}
}
public func refreshData(_ viewController: JobsViewController) {
debugPrint("Refreshing Jobs Data")
manager.getJobOffers { (offers, error) in
guard error == nil, let offers = offers else {
DispatchQueue.main.async {
viewController.tableView.refreshControl?.endRefreshing()
}
return
}
let model = JobsViewModel(jobOffers: offers)
viewController.model = model
}
}
}
extension JobsNavigator: GenericInfoViewControllerDelegate {
public func buttonTapped(_ viewController: GenericInfoViewController) {
public func buttonTapped(_ viewController: GenericInfoViewController, action: GenericInfoViewControllerAction) {
debugPrint("Info View button tapped")
// TODO: - Show job description pdf using QLPreviewController
// https://www.hackingwithswift.com/example-code/libraries/how-to-preview-files-using-quick-look-and-qlpreviewcontroller
#warning("replace with actual pdf data")
guard case .openPDF(let path) = action else {
return
}
self.manager.getMedia(for: path) { (url, error) in
guard error == nil, let url = url else {
return
}
let quickLook = QLPreviewController()
let dataSource = QuickLookDataSource(urls: [url])
self.quickLookDataSource = dataSource
quickLook.dataSource = dataSource
DispatchQueue.main.async {
self.navigationController.present(quickLook, animated: true, completion: nil)
}
}
/*
let url = Bundle.main.url(forResource: "Dienstverschiebungsgesuch", withExtension: "pdf")!
let quickLook = QLPreviewController()
let dataSource = QuickLookDataSource(urls: [url])
self.quickLookDataSource = dataSource
quickLook.dataSource = dataSource
self.navigationController.present(quickLook, animated: true, completion: nil)
*/
}
}
......@@ -73,6 +73,7 @@ extension OnboardingNavigator: LoginViewControllerDelegate {
// Save token into secure and encrypted keychain
let keychain = KeychainSwift()
keychain.set(response.token, forKey: KeychainKey.authToken.rawValue)
keychain.set(response.id, forKey: KeychainKey.sessionID.rawValue)
keychain.synchronizable = true
DispatchQueue.main.async {
......
......@@ -11,6 +11,7 @@ import Foundation
public enum AMIVApiEvents {
case events
case media(_ path: String)
}
......@@ -19,34 +20,36 @@ extension AMIVApiEvents: EndPointType {
public var path: String {
switch self {
case .events:
return "events"
return "/events"
case .media(let path):
return path
}
}
public var httpMethod: HTTPMethod {
switch self {
case .events:
case .events, .media:
return .get
}
}
public var task: HTTPTask {
switch self {
case .events:
case .events, .media:
return .request
}
}
public var headers: HTTPHeaders? {
switch self {
case .events:
case .events, .media:
return nil
}
}
public var isAuthenticationRequired: Bool {
switch self {
case .events:
case .events, .media:
return false
}
}
......
......@@ -11,6 +11,7 @@ import Foundation
public enum AMIVApiJobs: EndPointType {
case jobs
case media(_ path: String)
}
......