To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 2192626d authored by domenicw's avatar domenicw
Browse files

More work on jobs and events

parent d7d523e9
......@@ -55,6 +55,10 @@
B0FE2F0A2154237C00F3D073 /* GenericInfoViewControllerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0FE2F092154237C00F3D073 /* GenericInfoViewControllerModel.swift */; };
B0FE2F0D21543E6600F3D073 /* ImageViewerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0FE2F0C21543E6600F3D073 /* ImageViewerViewController.swift */; };
B0FE2F102154495100F3D073 /* BlurButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0FE2F0F2154495100F3D073 /* BlurButton.swift */; };
B0FE2F1221550C0100F3D073 /* JobsViewControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0FE2F1121550C0100F3D073 /* JobsViewControllerDelegate.swift */; };
B0FE2F1421550C4400F3D073 /* EventsViewControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0FE2F1321550C4400F3D073 /* EventsViewControllerDelegate.swift */; };
B0FE2F16215514E600F3D073 /* QuickLookDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0FE2F15215514E600F3D073 /* QuickLookDataSource.swift */; };
B0FE2F182155167F00F3D073 /* Dienstverschiebungsgesuch.pdf in Resources */ = {isa = PBXBuildFile; fileRef = B0FE2F172155167F00F3D073 /* Dienstverschiebungsgesuch.pdf */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
......@@ -121,6 +125,10 @@
B0FE2F092154237C00F3D073 /* GenericInfoViewControllerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenericInfoViewControllerModel.swift; sourceTree = "<group>"; };
B0FE2F0C21543E6600F3D073 /* ImageViewerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageViewerViewController.swift; sourceTree = "<group>"; };
B0FE2F0F2154495100F3D073 /* BlurButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlurButton.swift; sourceTree = "<group>"; };
B0FE2F1121550C0100F3D073 /* JobsViewControllerDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JobsViewControllerDelegate.swift; sourceTree = "<group>"; };
B0FE2F1321550C4400F3D073 /* EventsViewControllerDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventsViewControllerDelegate.swift; sourceTree = "<group>"; };
B0FE2F15215514E600F3D073 /* QuickLookDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickLookDataSource.swift; sourceTree = "<group>"; };
B0FE2F172155167F00F3D073 /* Dienstverschiebungsgesuch.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = Dienstverschiebungsgesuch.pdf; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -187,6 +195,7 @@
B050E13F2151695A0090CB79 /* Base */ = {
isa = PBXGroup;
children = (
B0FE2F172155167F00F3D073 /* Dienstverschiebungsgesuch.pdf */,
B050E11F215169230090CB79 /* AppDelegate.swift */,
B050E126215169250090CB79 /* Assets.xcassets */,
B050E128215169250090CB79 /* LaunchScreen.storyboard */,
......@@ -348,6 +357,7 @@
isa = PBXGroup;
children = (
B050E16A215177820090CB79 /* JobsNavigator.swift */,
B0FE2F15215514E600F3D073 /* QuickLookDataSource.swift */,
);
path = Jobs;
sourceTree = "<group>";
......@@ -401,6 +411,7 @@
isa = PBXGroup;
children = (
B0FE2EFB2154179600F3D073 /* JobsViewController.swift */,
B0FE2F1121550C0100F3D073 /* JobsViewControllerDelegate.swift */,
);
path = Jobs;
sourceTree = "<group>";
......@@ -449,6 +460,7 @@
isa = PBXGroup;
children = (
B0FE2F0121541A6300F3D073 /* EventsViewController.swift */,
B0FE2F1321550C4400F3D073 /* EventsViewControllerDelegate.swift */,
);
path = Events;
sourceTree = "<group>";
......@@ -571,6 +583,7 @@
files = (
B050E12A215169250090CB79 /* LaunchScreen.storyboard in Resources */,
B050E127215169250090CB79 /* Assets.xcassets in Resources */,
B0FE2F182155167F00F3D073 /* Dienstverschiebungsgesuch.pdf in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -588,6 +601,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B0FE2F1421550C4400F3D073 /* EventsViewControllerDelegate.swift in Sources */,
B0FE2F16215514E600F3D073 /* QuickLookDataSource.swift in Sources */,
B050E17821517EF50090CB79 /* AmivApplicationModel.swift in Sources */,
B050E16E215178BA0090CB79 /* AmivApplictionsNavigator.swift in Sources */,
B050E18C2151A54D0090CB79 /* SettingsCellModel.swift in Sources */,
......@@ -617,6 +632,7 @@
B0FE2F0D21543E6600F3D073 /* ImageViewerViewController.swift in Sources */,
B050E18E2151A5660090CB79 /* SettingsCellType.swift in Sources */,
B0FE2F0621541C5C00F3D073 /* GenericInfoViewController.swift in Sources */,
B0FE2F1221550C0100F3D073 /* JobsViewControllerDelegate.swift in Sources */,
B0FE2F082154230500F3D073 /* GenericInfoViewControllerDelegate.swift in Sources */,
B050E1852151A3700090CB79 /* SettingsViewController.swift in Sources */,
B0FE2F102154495100F3D073 /* BlurButton.swift in Sources */,
......
......@@ -24,6 +24,7 @@ public class AmivApplicationsNavigator: Navigator {
public init() {
let root = AmivApplicationViewcontroller(model: AmivApplicationModel.createModels())
self.navigationController = UINavigationController(rootViewController: root)
self.navigationController.navigationBar.tintColor = .amivRed
root.delegate = self
}
......
......@@ -24,6 +24,42 @@ public class EventsNavigator: Navigator {
public init() {
let home = EventsViewController()
self.navigationController = UINavigationController(rootViewController: home)
self.navigationController.navigationBar.tintColor = .amivRed
home.delegate = self
}
// MARK: - Navigation
private func goToEventDetailView(model: GenericInfoViewControllerModel) {
let info = GenericInfoViewController(model: model)
info.delegate = self
self.navigationController.pushViewController(info, animated: true)
}
}
extension EventsNavigator: EventsViewControllerDelegate {
public func didSelectEvent(section: Int, index: Int) {
debugPrint("didSelect section: \(section) and index: \(index)")
// TODO: - Retrieve event, convert into GenericInfoViewControllerModel and show Detail View
// let model = ...
self.goToEventDetailView(model: .createTestModel())
}
public func refreshData() {
debugPrint("Refreshing Events Data")
}
}
extension EventsNavigator: GenericInfoViewControllerDelegate {
public func buttonTapped() {
debugPrint("Info View button tapped")
// TODO: - Sign up for event
}
}
......@@ -25,6 +25,7 @@ public class HomeNavigator: Navigator {
let model = EventModel()
let home = HomeViewController(model: model)
self.navigationController = UINavigationController(rootViewController: home)
self.navigationController.navigationBar.tintColor = .amivRed
}
}
......@@ -8,11 +8,14 @@
import Foundation
import UIKit
import QuickLook
public class JobsNavigator: Navigator {
// MARK: - Variables
private var quickLookDataSource: QuickLookDataSource?
public var rootViewController: UIViewController {
return self.navigationController
}
......@@ -24,6 +27,52 @@ public class JobsNavigator: Navigator {
public init() {
let jobs = JobsViewController()
self.navigationController = UINavigationController(rootViewController: jobs)
self.navigationController.navigationBar.tintColor = .amivRed
jobs.delegate = self
}
// MARK: - Navigation
private func goToJobsDetailView(model: GenericInfoViewControllerModel) {
let info = GenericInfoViewController(model: model)
info.delegate = self
self.navigationController.pushViewController(info, animated: true)
}
}
extension JobsNavigator: JobsViewControllerDelegate {
public func didSelectJob(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 refreshData() {
debugPrint("Refreshing Jobs Data")
}
}
extension JobsNavigator: GenericInfoViewControllerDelegate {
public func buttonTapped() {
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")
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)
}
}
//
// QuickLookDataSource.swift
// Amiv
//
// Created by Domenic Wüthrich on 21.09.18.
// Copyright © 2018 Amiv an der ETH. All rights reserved.
//
import Foundation
import UIKit
import QuickLook
public class QuickLookDataSource: QLPreviewControllerDataSource {
// MARK: - Variables
public let urls: [URL]
// MARK: - Initializers
public init(urls: [URL]) {
self.urls = urls
}
// MARK: - Data Source
public func numberOfPreviewItems(in controller: QLPreviewController) -> Int {
return self.urls.count
}
public func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {
return self.urls[index] as QLPreviewItem
}
}
......@@ -25,6 +25,7 @@ public class SettingsNavigator: Navigator {
let model = SettingsModel.create()
let settings = SettingsViewController(model: model)
self.navigationController = UINavigationController(rootViewController: settings)
self.navigationController.navigationBar.tintColor = .amivRed
settings.delegate = self
}
......
......@@ -13,6 +13,8 @@ public class EventsViewController: UITableViewController {
// MARK: - Variables
public var delegate: EventsViewControllerDelegate?
// MARK: - Initializers
public init() {
......@@ -29,14 +31,30 @@ public class EventsViewController: UITableViewController {
public override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = .white
let refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action: #selector(self.refreshData), for: .primaryActionTriggered)
self.tableView.refreshControl = refreshControl
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar.prefersLargeTitles = true
self.navigationItem.largeTitleDisplayMode = .automatic
}
public override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
self.refreshControl?.endRefreshing()
}
// MARK: - View Interaction
@objc private func refreshData() {
self.delegate?.refreshData()
}
}
// MARK: - Table View Data Source
......@@ -48,7 +66,7 @@ extension EventsViewController {
}
public override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 0
return 1
}
public override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
......@@ -60,3 +78,14 @@ extension EventsViewController {
}
}
// MARK: - Table View Delegate
extension EventsViewController {
public override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.delegate?.didSelectEvent(section: indexPath.section, index: indexPath.row)
tableView.deselectRow(at: indexPath, animated: true)
}
}
//
// EventsViewControllerDelegate.swift
// Amiv
//
// Created by Domenic Wüthrich on 21.09.18.
// Copyright © 2018 Amiv an der ETH. All rights reserved.
//
import Foundation
public protocol EventsViewControllerDelegate {
func didSelectEvent(section: Int, index: Int)
func refreshData()
}
......@@ -181,7 +181,7 @@ public class GenericInfoViewController: UIViewController {
NSLayoutConstraint(item: button, attribute: .top, relatedBy: .equal, toItem: self.textView, attribute: .bottom, multiplier: 1, constant: 20).isActive = true
NSLayoutConstraint(item: button, attribute: .leading, relatedBy: .equal, toItem: self.view, attribute: .leadingMargin, multiplier: 1, constant: 10).isActive = true
NSLayoutConstraint(item: button, attribute: .trailing, relatedBy: .equal, toItem: self.view, attribute: .trailingMargin, multiplier: 1, constant: -10).isActive = true
NSLayoutConstraint(item: button, attribute: .bottom, relatedBy: .equal, toItem: self.scrollView, attribute: .bottom, multiplier: 1, constant: 0).isActive = true
NSLayoutConstraint(item: button, attribute: .bottom, relatedBy: .equal, toItem: self.scrollView, attribute: .bottom, multiplier: 1, constant: -10).isActive = true
NSLayoutConstraint(item: button, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 50).isActive = true
}
......@@ -190,8 +190,7 @@ public class GenericInfoViewController: UIViewController {
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationItem.largeTitleDisplayMode = .automatic
self.navigationController?.navigationBar.prefersLargeTitles = true
self.navigationItem.largeTitleDisplayMode = .never
}
// MARK: - View Interaction
......
......@@ -13,6 +13,8 @@ public class JobsViewController: UITableViewController {
// MARK: - Variables
public var delegate: JobsViewControllerDelegate?
// MARK: - Initializers
public init() {
......@@ -26,6 +28,14 @@ public class JobsViewController: UITableViewController {
// MARK: - View Setup
public override func viewDidLoad() {
super.viewDidLoad()
let refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action: #selector(self.refreshData), for: .primaryActionTriggered)
self.tableView.refreshControl = refreshControl
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
......@@ -33,8 +43,18 @@ public class JobsViewController: UITableViewController {
self.navigationItem.largeTitleDisplayMode = .automatic
}
public override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
self.refreshControl?.endRefreshing()
}
// MARK: - View Interaction
@objc private func refreshData() {
self.delegate?.refreshData()
}
}
// MARK: - Table View Data Source
......@@ -46,7 +66,7 @@ extension JobsViewController {
}
public override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 0
return 1
}
public override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
......@@ -58,3 +78,14 @@ extension JobsViewController {
}
}
// MARK: - Table View Delegate
extension JobsViewController {
public override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.delegate?.didSelectJob(section: indexPath.section, index: indexPath.row)
tableView.deselectRow(at: indexPath, animated: true)
}
}
//
// JobsViewControllerDelegate.swift
// Amiv
//
// Created by Domenic Wüthrich on 21.09.18.
// Copyright © 2018 Amiv an der ETH. All rights reserved.
//
import Foundation
public protocol JobsViewControllerDelegate {
func didSelectJob(section: Int, index: Int)
func refreshData()
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment