Displays dummy data in SaveStatesViewController
This commit is contained in:
parent
9dcec258c1
commit
544f1a1801
@ -50,6 +50,7 @@ class GridCollectionViewCell: UICollectionViewCell
|
||||
self.contentView.clipsToBounds = false
|
||||
|
||||
self.imageView.translatesAutoresizingMaskIntoConstraints = false
|
||||
self.imageView.contentMode = .ScaleAspectFit
|
||||
#if os(tvOS)
|
||||
self.imageView.adjustsImageWhenAncestorFocused = true
|
||||
#endif
|
||||
@ -135,7 +136,7 @@ private extension GridCollectionViewCell
|
||||
self.imageViewWidthConstraint.constant = self.maximumImageSize.width
|
||||
self.imageViewHeightConstraint.constant = self.maximumImageSize.height
|
||||
|
||||
self.textLabelVerticalSpacingConstraint.constant = self.maximumImageSize.height / 10.0
|
||||
self.textLabelVerticalSpacingConstraint.constant = 8
|
||||
self.textLabelFocusedVerticalSpacingConstraint?.constant = self.maximumImageSize.height / 10.0
|
||||
}
|
||||
}
|
||||
@ -12,7 +12,11 @@ class GridCollectionViewLayout: UICollectionViewFlowLayout
|
||||
{
|
||||
var itemWidth: CGFloat = 150 {
|
||||
didSet {
|
||||
self.invalidateLayout()
|
||||
// Only invalidate if needed, otherwise could potentially cause endless loop
|
||||
if oldValue != self.itemWidth
|
||||
{
|
||||
self.invalidateLayout()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -39,13 +39,19 @@ class PausePresentationController: UIPresentationController
|
||||
{
|
||||
guard let containerView = self.containerView else { return super.frameOfPresentedViewInContainerView() }
|
||||
|
||||
var contentHeight = self.presentedViewController.preferredContentSize.height
|
||||
let frame: CGRect
|
||||
let contentHeight = self.presentedViewController.preferredContentSize.height
|
||||
|
||||
if contentHeight == 0
|
||||
{
|
||||
contentHeight = containerView.bounds.height - UIApplication.sharedApplication().statusBarFrame.height
|
||||
let statusBarHeight = UIApplication.sharedApplication().statusBarFrame.height
|
||||
frame = CGRect(x: 0, y: statusBarHeight, width: containerView.bounds.width, height: containerView.bounds.height - statusBarHeight)
|
||||
}
|
||||
else
|
||||
{
|
||||
frame = CGRect(x: 0, y: containerView.bounds.height - contentHeight, width: containerView.bounds.width, height: containerView.bounds.height)
|
||||
}
|
||||
|
||||
let frame = CGRect(x: 0, y: containerView.bounds.height - contentHeight, width: containerView.bounds.width, height: containerView.bounds.height)
|
||||
return frame
|
||||
}
|
||||
|
||||
|
||||
@ -10,25 +10,90 @@ import UIKit
|
||||
|
||||
import Roxas
|
||||
|
||||
private let SaveStatesViewControllerContentInset: CGFloat = 20
|
||||
|
||||
class SaveStatesViewController: UICollectionViewController
|
||||
{
|
||||
private var backgroundView: RSTBackgroundView!
|
||||
|
||||
private var prototypeCell = GridCollectionViewCell()
|
||||
private var prototypeCellWidthConstraint: NSLayoutConstraint!
|
||||
}
|
||||
|
||||
extension SaveStatesViewController
|
||||
{
|
||||
override func viewDidLoad()
|
||||
{
|
||||
super.viewDidLoad()
|
||||
|
||||
self.backgroundView = RSTBackgroundView(frame: self.view.bounds)
|
||||
self.backgroundView.hidden = true
|
||||
self.backgroundView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
|
||||
self.backgroundView.textLabel.text = NSLocalizedString("No Save States", comment: "")
|
||||
self.backgroundView.textLabel.textColor = UIColor.whiteColor()
|
||||
self.backgroundView.detailTextLabel.text = NSLocalizedString("You can create a new save state by pressing the + button in the top right.", comment: "")
|
||||
self.backgroundView.detailTextLabel.textColor = UIColor.whiteColor()
|
||||
self.view.insertSubview(self.backgroundView, atIndex: 0)
|
||||
|
||||
// We update the layout in code because we need to use our SaveStatesViewControllerContentInset constant
|
||||
// The reason for this is we cannot query the layout for its sectionInset in viewDidLayoutSubviews, so might as well be explicit in code with a constant
|
||||
// Otherwise, we could configure this all in Interface Builder, but we'd still need to hardcode 20 in for viewDidLayoutSubviews
|
||||
let collectionViewLayout = self.collectionViewLayout as! GridCollectionViewLayout
|
||||
collectionViewLayout.sectionInset = UIEdgeInsets(top: SaveStatesViewControllerContentInset, left: SaveStatesViewControllerContentInset, bottom: SaveStatesViewControllerContentInset, right: SaveStatesViewControllerContentInset)
|
||||
collectionViewLayout.minimumInteritemSpacing = SaveStatesViewControllerContentInset
|
||||
collectionViewLayout.minimumLineSpacing = SaveStatesViewControllerContentInset
|
||||
|
||||
let portraitScreenWidth = UIScreen.mainScreen().coordinateSpace.convertRect(UIScreen.mainScreen().bounds, toCoordinateSpace: UIScreen.mainScreen().fixedCoordinateSpace).width
|
||||
collectionViewLayout.itemWidth = (portraitScreenWidth - ((SaveStatesViewControllerContentInset) * 3)) / 2
|
||||
|
||||
// Manually update prototype cell properties
|
||||
self.prototypeCellWidthConstraint = self.prototypeCell.contentView.widthAnchor.constraintEqualToConstant(collectionViewLayout.itemWidth)
|
||||
self.prototypeCellWidthConstraint.active = true
|
||||
}
|
||||
|
||||
override func didReceiveMemoryWarning()
|
||||
{
|
||||
super.didReceiveMemoryWarning()
|
||||
}
|
||||
}
|
||||
|
||||
private extension SaveStatesViewController
|
||||
{
|
||||
func configureCollectionViewCell(cell: GridCollectionViewCell, forIndexPath indexPath: NSIndexPath)
|
||||
{
|
||||
cell.imageView.backgroundColor = UIColor.whiteColor()
|
||||
cell.imageView.image = UIImage(named: "DeltaPlaceholder")
|
||||
|
||||
cell.maximumImageSize = CGSizeMake(self.prototypeCellWidthConstraint.constant, (self.prototypeCellWidthConstraint.constant / 4.0) * 3.0)
|
||||
|
||||
cell.textLabel.textColor = UIColor.whiteColor()
|
||||
cell.textLabel.font = UIFont.preferredFontForTextStyle(UIFontTextStyleSubheadline)
|
||||
cell.textLabel.text = "Save State"
|
||||
}
|
||||
}
|
||||
|
||||
extension SaveStatesViewController
|
||||
{
|
||||
override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int
|
||||
{
|
||||
return 12
|
||||
}
|
||||
|
||||
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
|
||||
{
|
||||
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(RSTGenericCellIdentifier, forIndexPath: indexPath) as! GridCollectionViewCell
|
||||
self.configureCollectionViewCell(cell, forIndexPath: indexPath)
|
||||
return cell
|
||||
}
|
||||
}
|
||||
|
||||
extension SaveStatesViewController: UICollectionViewDelegateFlowLayout
|
||||
{
|
||||
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize
|
||||
{
|
||||
self.configureCollectionViewCell(self.prototypeCell, forIndexPath: indexPath)
|
||||
|
||||
let size = self.prototypeCell.contentView.systemLayoutSizeFittingSize(UILayoutFittingCompressedSize)
|
||||
return size
|
||||
}
|
||||
}
|
||||
23
Resources/Assets.xcassets/DeltaPlaceholder.imageset/Contents.json
vendored
Normal file
23
Resources/Assets.xcassets/DeltaPlaceholder.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "DeltaPlaceholder.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "DeltaPlaceholder@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "DeltaPlaceholder@3x.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
BIN
Resources/Assets.xcassets/DeltaPlaceholder.imageset/DeltaPlaceholder.png
vendored
Normal file
BIN
Resources/Assets.xcassets/DeltaPlaceholder.imageset/DeltaPlaceholder.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.4 KiB |
BIN
Resources/Assets.xcassets/DeltaPlaceholder.imageset/DeltaPlaceholder@2x.png
vendored
Normal file
BIN
Resources/Assets.xcassets/DeltaPlaceholder.imageset/DeltaPlaceholder@2x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
BIN
Resources/Assets.xcassets/DeltaPlaceholder.imageset/DeltaPlaceholder@3x.png
vendored
Normal file
BIN
Resources/Assets.xcassets/DeltaPlaceholder.imageset/DeltaPlaceholder@3x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
Loading…
Reference in New Issue
Block a user