Added Screenshots to iOS Demo

This commit is contained in:
Mathias Köhnke 2016-05-20 07:22:05 +02:00
parent cf6aadaaa4
commit deea89841f
6 changed files with 162 additions and 19 deletions

View File

@ -23,6 +23,11 @@
import Foundation
/**
Convenience functions for accessing the WKZombie shared instance functionality.
*/
//========================================
// MARK: Get Page
//========================================
@ -272,4 +277,25 @@ public func decode<T : JSONDecodable>(array: JSONParsable) -> Action<[T]> {
return WKZombie.sharedInstance.snap()
}
#endif
#endif
//========================================
// MARK: Debug Methods
//========================================
/**
Prints the current state of the WKZombie browser to the console.
*/
public func dump() {
WKZombie.sharedInstance.dump()
}
/**
Clears the cache/cookie data (such as login data, etc).
*/
public func clearCache() {
WKZombie.sharedInstance.clearCache()
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="QRH-i6-GfC">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="QRH-i6-GfC">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
@ -8,7 +8,7 @@
<!--Developer Portal Login-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="LoginViewController" customModule="WKZombieDemo" customModuleProvider="target" sceneMemberID="viewController">
<viewController id="BYZ-38-t0r" customClass="LoginViewController" customModule="Example_iOS" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
@ -43,7 +43,7 @@
<constraint firstAttribute="height" constant="1" id="nyY-50-dGl"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qgq-1m-uzi" customClass="Button" customModule="WKZombieDemo" customModuleProvider="target">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qgq-1m-uzi" customClass="Button" customModule="Example_iOS" customModuleProvider="target">
<rect key="frame" x="160" y="282" width="280" height="44"/>
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
@ -106,10 +106,10 @@
</objects>
<point key="canvasLocation" x="1368" y="418"/>
</scene>
<!--View Controller-->
<!--Provisoning Profiles-->
<scene sceneID="fO3-9w-kJQ">
<objects>
<tableViewController id="I9d-4F-Hou" customClass="ViewController" customModule="WKZombieDemo" customModuleProvider="target" sceneMemberID="viewController">
<tableViewController id="I9d-4F-Hou" customClass="ProfileViewController" customModule="Example_iOS" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="X9E-XB-oH5">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@ -126,7 +126,7 @@
<rect key="frame" x="15" y="0.0" width="570" height="43.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
@ -139,11 +139,68 @@
<outlet property="delegate" destination="I9d-4F-Hou" id="iKR-TQ-oOQ"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Provisoning Profiles" id="0Q4-06-6SJ">
<barButtonItem key="rightBarButtonItem" title="Screenshots" id="1sd-3O-H52">
<connections>
<segue destination="Wz5-Fi-eHO" kind="show" identifier="snapshotSegue" id="Io9-VL-bI5"/>
</connections>
</barButtonItem>
</navigationItem>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="UZe-QH-Nd0" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2129" y="418"/>
</scene>
<!--Screenshots-->
<scene sceneID="IjW-80-6Bg">
<objects>
<collectionViewController id="Wz5-Fi-eHO" customClass="SnapshotViewController" customModule="Example_iOS" customModuleProvider="target" sceneMemberID="viewController">
<collectionView key="view" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" id="Cvd-KA-v3u">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="0.96546052631578949" alpha="1" colorSpace="calibratedWhite"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="EPn-Tn-Jky">
<size key="itemSize" width="200" height="300"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/>
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
<cells>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="snapshotCell" id="zEY-RE-D8r" customClass="SnapshotCell" customModule="Example_iOS" customModuleProvider="target">
<rect key="frame" x="0.0" y="64" width="200" height="300"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="200" height="300"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="1sJ-yR-83v">
<rect key="frame" x="0.0" y="0.0" width="200" height="300"/>
</imageView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<constraints>
<constraint firstItem="1sJ-yR-83v" firstAttribute="top" secondItem="zEY-RE-D8r" secondAttribute="top" id="5Mx-St-7hI"/>
<constraint firstAttribute="bottom" secondItem="1sJ-yR-83v" secondAttribute="bottom" id="XBh-4L-S57"/>
<constraint firstItem="1sJ-yR-83v" firstAttribute="leading" secondItem="zEY-RE-D8r" secondAttribute="leading" id="Zsy-rw-khV"/>
<constraint firstAttribute="trailing" secondItem="1sJ-yR-83v" secondAttribute="trailing" id="bJ2-bD-UuX"/>
</constraints>
<connections>
<outlet property="imageView" destination="1sJ-yR-83v" id="L58-hA-YvO"/>
</connections>
</collectionViewCell>
</cells>
<connections>
<outlet property="dataSource" destination="Wz5-Fi-eHO" id="1QV-LQ-eET"/>
<outlet property="delegate" destination="Wz5-Fi-eHO" id="tjF-lZ-63c"/>
</connections>
</collectionView>
<navigationItem key="navigationItem" title="Screenshots" id="Z1D-H1-ha1"/>
</collectionViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="OpX-Sp-5bN" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2912" y="418"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="3Hv-kb-cAc">
<objects>

View File

@ -31,21 +31,21 @@ class LoginViewController : UIViewController {
@IBOutlet weak var activityIndicator: UIActivityIndicatorView!
@IBOutlet weak var loginButton : UIButton!
let url = NSURL(string: "https://developer.apple.com/membercenter/index.action")!
private let url = NSURL(string: "https://developer.apple.com/membercenter/index.action")!
private var snapshots = [Snapshot]()
override func viewDidLoad() {
super.viewDidLoad()
WKZombie.sharedInstance.snapshotHandler = { snapshot in
let image = snapshot.image!
print("snapshot")
WKZombie.sharedInstance.snapshotHandler = { [weak self] snapshot in
self?.snapshots.append(snapshot)
}
}
@IBAction func loginButtonTouched(button: UIButton) {
guard let user = nameTextField.text, password = passwordTextField.text else { return }
button.enabled = false
snapshots.removeAll()
activityIndicator.startAnimating()
getProvisioningProfiles(url, user: user, password: password)
}
@ -99,8 +99,9 @@ class LoginViewController : UIViewController {
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "detailSegue" {
if let vc = segue.destinationViewController as? ViewController, items = sender as? [HTMLTableColumn] {
if let vc = segue.destinationViewController as? ProfileViewController, items = sender as? [HTMLTableColumn] {
vc.items = items
vc.snapshots = snapshots
}
}
}

View File

@ -24,13 +24,13 @@
import UIKit
import WKZombie
class ViewController: UITableViewController {
class ProfileViewController: UITableViewController {
var items : [HTMLTableColumn]?
var snapshots : [Snapshot]?
override func viewDidLoad() {
super.viewDidLoad()
title = "Provisioning Profiles"
navigationItem.hidesBackButton = true
}
@ -44,5 +44,12 @@ class ViewController: UITableViewController {
cell.textLabel?.text = item?.text
return cell
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "snapshotSegue" {
let vc = segue.destinationViewController as? SnapshotViewController
vc?.snapshots = snapshots
}
}
}

View File

@ -0,0 +1,48 @@
//
// ScreenshotViewController.swift
// Example
//
// Created by Mathias Köhnke on 20/05/16.
// Copyright © 2016 Mathias Köhnke. All rights reserved.
//
import UIKit
import WKZombie
class SnapshotCell : UICollectionViewCell {
static let cellIdentifier = "snapshotCell"
@IBOutlet weak var imageView : UIImageView!
}
class SnapshotViewController: UICollectionViewController {
var snapshots : [Snapshot]?
override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return snapshots?.count ?? 0
}
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(SnapshotCell.cellIdentifier, forIndexPath: indexPath)
if let cell = cell as? SnapshotCell {
cell.imageView.image = snapshots?[indexPath.row].image
}
return cell
}
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
let width = (view.bounds.size.width / 2) - 1
let height = (view.bounds.size.height * width) / view.bounds.size.width
return CGSize(width: width, height: height)
}
}
extension SnapshotViewController : UICollectionViewDelegateFlowLayout {
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAtIndex section: Int) -> CGFloat {
return 1.0
}
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAtIndex section: Int) -> CGFloat {
return 2.0
}
}

View File

@ -17,9 +17,10 @@
BF01D1771CB6F3720095BCE4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BF01D16D1CB6F3720095BCE4 /* Assets.xcassets */; };
BF01D17A1CB6F3720095BCE4 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF01D1731CB6F3720095BCE4 /* Button.swift */; };
BF01D17B1CB6F3720095BCE4 /* LoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF01D1741CB6F3720095BCE4 /* LoginViewController.swift */; };
BF01D17C1CB6F3720095BCE4 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF01D1751CB6F3720095BCE4 /* ViewController.swift */; };
BF01D17C1CB6F3720095BCE4 /* ProfileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF01D1751CB6F3720095BCE4 /* ProfileViewController.swift */; };
BF01D1811CB6F3950095BCE4 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BF01D17D1CB6F3950095BCE4 /* LaunchScreen.storyboard */; };
BF01D1821CB6F3950095BCE4 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BF01D17F1CB6F3950095BCE4 /* Main.storyboard */; };
BF455D281CEECF60006D97D0 /* SnapshotViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF455D271CEECF60006D97D0 /* SnapshotViewController.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@ -41,9 +42,10 @@
BF01D16D1CB6F3720095BCE4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
BF01D1731CB6F3720095BCE4 /* Button.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = "<group>"; };
BF01D1741CB6F3720095BCE4 /* LoginViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginViewController.swift; sourceTree = "<group>"; };
BF01D1751CB6F3720095BCE4 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
BF01D1751CB6F3720095BCE4 /* ProfileViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileViewController.swift; sourceTree = "<group>"; };
BF01D17E1CB6F3950095BCE4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
BF01D1801CB6F3950095BCE4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
BF455D271CEECF60006D97D0 /* SnapshotViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SnapshotViewController.swift; sourceTree = "<group>"; };
E524A5A77547899C72AB259A /* Pods-Example OSX.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example OSX.release.xcconfig"; path = "Pods/Target Support Files/Pods-Example OSX/Pods-Example OSX.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -105,7 +107,8 @@
BF01D16C1CB6F3720095BCE4 /* AppDelegate.swift */,
BF01D1731CB6F3720095BCE4 /* Button.swift */,
BF01D1741CB6F3720095BCE4 /* LoginViewController.swift */,
BF01D1751CB6F3720095BCE4 /* ViewController.swift */,
BF01D1751CB6F3720095BCE4 /* ProfileViewController.swift */,
BF455D271CEECF60006D97D0 /* SnapshotViewController.swift */,
BF01D1831CB6F3A20095BCE4 /* Resources */,
);
path = "Example iOS";
@ -345,7 +348,8 @@
files = (
BF01D17B1CB6F3720095BCE4 /* LoginViewController.swift in Sources */,
BF01D1761CB6F3720095BCE4 /* AppDelegate.swift in Sources */,
BF01D17C1CB6F3720095BCE4 /* ViewController.swift in Sources */,
BF01D17C1CB6F3720095BCE4 /* ProfileViewController.swift in Sources */,
BF455D281CEECF60006D97D0 /* SnapshotViewController.swift in Sources */,
BF01D17A1CB6F3720095BCE4 /* Button.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;