Moved detail view to Framework

parent 60844473
......@@ -13,7 +13,7 @@ import WhatsOpenKit
class FacilityCollectionViewCell: UICollectionViewCell {
@IBOutlet var nameLabel: UILabel!
@IBOutlet var timeDescriptionLabel: UILabel!
@IBOutlet var openClosedLabel: PaddedUILabel!
@IBOutlet var openClosedLabel: WOPPaddedUILabel!
@IBOutlet var categoryLabel: UILabel!
var facility: WOPFacility!
internal let tapRecognizer: UITapGestureRecognizer = UITapGestureRecognizer()
......
......@@ -13,7 +13,7 @@ import WhatsOpenKit
class DetailViewButtonsViewController: UIViewController {
@IBOutlet var facilityDetailView: UIView!
var detailViewController: FacilityDetailViewController?
var detailViewController: WOPFacilityDetailViewController?
var facility: WOPFacility!
@IBOutlet var favoritesButton: UIButton!
......
......@@ -150,7 +150,8 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
if(indexPath != nil) {
if(indexPath?.section == 1 || currentAlerts.count == 0) {
let destination = self.storyboard?.instantiateViewController(withIdentifier: "detailView") as? FacilityDetailViewController
let storyboard = UIStoryboard(name: "WOPSharedUI", bundle: Bundle(for: WOPFacilityDetailViewController.self))
let destination = storyboard.instantiateViewController(withIdentifier: "detailView") as? WOPFacilityDetailViewController
let tapped = self.LocationsList.cellForItem(at: indexPath!) as! FacilityCollectionViewCell
destination?.facility = tapped.facility
self.presentDetailView(destination!, tapped: tapped)
......@@ -168,7 +169,8 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
var goodToGo = false
@objc func toDetailFromSearch(_ notification: Notification) {
func toDetailCompletion() {
let dest = self.storyboard?.instantiateViewController(withIdentifier: "detailView") as! FacilityDetailViewController
let storyboard = UIStoryboard(name: "WOPSharedUI", bundle: Bundle(for: WOPFacilityDetailViewController.self))
let dest = storyboard.instantiateViewController(withIdentifier: "detailView") as! WOPFacilityDetailViewController
let userActivity = notification.object as? NSUserActivity
if(userActivity == nil) {
return // don't do anything
......@@ -215,7 +217,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
return // don't do anything
}
let dest = self.storyboard?.instantiateViewController(withIdentifier: "detailView") as! FacilityDetailViewController
let dest = self.storyboard?.instantiateViewController(withIdentifier: "detailView") as! WOPFacilityDetailViewController
dest.facility = facility!
let detailViewWithButtons = self.storyboard?.instantiateViewController(withIdentifier: "detailViewButtons") as? DetailViewButtonsViewController
......@@ -240,10 +242,10 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
func presentDetailView(_ destination: UIViewController, tapped: UICollectionViewCell) {
var trueDest: UIViewController
if destination is FacilityDetailViewController {
if destination is WOPFacilityDetailViewController {
let detailViewWithButtons = self.storyboard?.instantiateViewController(withIdentifier: "detailViewButtons") as? DetailViewButtonsViewController
detailViewWithButtons?.detailViewController = (destination as! FacilityDetailViewController)
detailViewWithButtons?.facility = (destination as! FacilityDetailViewController).facility
detailViewWithButtons?.detailViewController = (destination as! WOPFacilityDetailViewController)
detailViewWithButtons?.facility = (destination as! WOPFacilityDetailViewController).facility
trueDest = detailViewWithButtons!
}
else {
......@@ -921,8 +923,8 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
// Get the new view controller using segue.destinationViewController.
if(segue.identifier == "toDetailView") {
let destination = segue.destination as! PullingViewController
var destChild = destination.children[0] as! FacilityDetailViewController
destChild = self.storyboard?.instantiateViewController(withIdentifier: "detailView") as! FacilityDetailViewController
var destChild = destination.children[0] as! WOPFacilityDetailViewController
destChild = self.storyboard?.instantiateViewController(withIdentifier: "detailView") as! WOPFacilityDetailViewController
let destDelegate = DeckTransitioningDelegate()
destination.transitioningDelegate = destDelegate
let tapped = sender as! FacilityCollectionViewCell //this is probably a bad idea just FYI future me
......@@ -954,7 +956,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
guard let indexPath = LocationsList?.indexPathForItem(at: location) else { return nil }
if(indexPath.section == 1 || currentAlerts.count == 0) {
let cell = LocationsList?.cellForItem(at: indexPath) as? FacilityCollectionViewCell
guard let detailView = storyboard?.instantiateViewController(withIdentifier: "detailView") as? FacilityDetailViewController else { return nil }
guard let detailView = storyboard?.instantiateViewController(withIdentifier: "detailView") as? WOPFacilityDetailViewController else { return nil }
detailView.facility = cell?.facility
return detailView
}
......@@ -968,7 +970,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
}
func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) {
guard let facilityDetailView = viewControllerToCommit as? FacilityDetailViewController
guard let facilityDetailView = viewControllerToCommit as? WOPFacilityDetailViewController
else {
let finalDestination = self.storyboard?.instantiateViewController(withIdentifier: "pulling") as? PullingViewController // Fox only, no items
finalDestination?.currentViewController = viewControllerToCommit
......
......@@ -9,21 +9,20 @@
import UIKit
import StoreKit
import MapKit
import WhatsOpenKit
class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
public class WOPFacilityDetailViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet var NameLabel: UILabel!
@IBOutlet var PlaceLabel: UILabel!
@IBOutlet var OpenLabel: PaddedUILabel!
@IBOutlet var CategoryLabel: UILabel!
@IBOutlet var OpenTimesList: UITableView!
let activity = NSUserActivity(activityType: "facility")
@IBOutlet public var NameLabel: UILabel!
@IBOutlet public var PlaceLabel: UILabel!
@IBOutlet public var OpenLabel: WOPPaddedUILabel!
@IBOutlet public var CategoryLabel: UILabel!
@IBOutlet public var OpenTimesList: UITableView!
public let activity = NSUserActivity(activityType: "facility")
var facility: WOPFacility!
public var facility: WOPFacility!
override var previewActionItems: [UIPreviewActionItem] {
override public var previewActionItems: [UIPreviewActionItem] {
var title: String
if(WOPUtilities.isFavoriteFacility(facility)) {
title = "Remove from Favorites"
......@@ -37,15 +36,15 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab
override var preferredStatusBarStyle: UIStatusBarStyle {
override public var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
override func viewDidDisappear(_ animated: Bool) {
override public func viewDidDisappear(_ animated: Bool) {
activity.resignCurrent()
}
override func viewDidLoad() {
override public func viewDidLoad() {
super.viewDidLoad()
modalPresentationCapturesStatusBarAppearance = true
......@@ -101,21 +100,21 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab
activity.becomeCurrent()
}
override func didReceiveMemoryWarning() {
override public func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func numberOfSections(in tableView: UITableView) -> Int {
public func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return WOPUtilities.getCurrentSchedule(facility)!.openTimes.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = OpenTimesList.dequeueReusableCell(withIdentifier: "LocationDetailCell", for: indexPath)
cell.selectionStyle = .none
......@@ -131,7 +130,7 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab
return cell
}
func markAsFavoritePreviewAction(_ sendingAction: UIPreviewAction, sender: UIViewController) {
public func markAsFavoritePreviewAction(_ sendingAction: UIPreviewAction, sender: UIViewController) {
if(WOPUtilities.isFavoriteFacility(facility)) {
_ = WOPUtilities.removeFavoriteFacility(facility)
}
......
......@@ -12,13 +12,13 @@ import UIKit
// Based on this
// https://stackoverflow.com/questions/21167226/resizing-a-uilabel-to-accommodate-insets/21267507#21267507
// The entire reason for this subclass of UILabel is for the openClosedLabel in FacilityCollectionViewCell
class PaddedUILabel: UILabel {
public class WOPPaddedUILabel: UILabel {
var textInsets = UIEdgeInsets.zero {
public var textInsets = UIEdgeInsets.zero {
didSet { invalidateIntrinsicContentSize() }
}
override func textRect(forBounds bounds: CGRect, limitedToNumberOfLines numberOfLines: Int) -> CGRect {
override public func textRect(forBounds bounds: CGRect, limitedToNumberOfLines numberOfLines: Int) -> CGRect {
let insetRect = bounds.inset(by: textInsets)
let textRect = super.textRect(forBounds: insetRect, limitedToNumberOfLines: numberOfLines)
let invertedInsets = UIEdgeInsets(top: -textInsets.top,
......@@ -28,25 +28,25 @@ class PaddedUILabel: UILabel {
return textRect.inset(by: invertedInsets)
}
override func drawText(in rect: CGRect) {
override public func drawText(in rect: CGRect) {
super.drawText(in: rect.inset(by: textInsets))
}
}
@IBDesignable
extension PaddedUILabel {
public extension WOPPaddedUILabel {
// currently UIEdgeInsets is no supported IBDesignable type,
// so we have to fan it out here:
@IBInspectable
var leftTextInset: CGFloat {
public var leftTextInset: CGFloat {
set { textInsets.left = newValue }
get { return textInsets.left }
}
@IBInspectable
var rightTextInset: CGFloat {
public var rightTextInset: CGFloat {
set { textInsets.right = newValue }
get { return textInsets.right }
}
......
This diff is collapsed.
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