Adds Github view controller.
This commit is contained in:
parent
9893a16f87
commit
e19af2f5d0
|
|
@ -29,6 +29,7 @@
|
|||
C8813DAA1AD2EBF30072A050 /* RootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8813DA91AD2EBF30072A050 /* RootViewController.swift */; };
|
||||
C890A6581AEBD26B00AFF7E6 /* GitHubSignupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C890A6571AEBD26B00AFF7E6 /* GitHubSignupViewController.swift */; };
|
||||
C890A65A1AEBD28A00AFF7E6 /* GitHubAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C890A6591AEBD28A00AFF7E6 /* GitHubAPI.swift */; };
|
||||
C890A65D1AEC084100AFF7E6 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C890A65C1AEC084100AFF7E6 /* ViewController.swift */; };
|
||||
C8A56BCB1AD744E600B4673B /* RxSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C8A56BCA1AD744E600B4673B /* RxSwift.framework */; };
|
||||
C8A56BCC1AD744E600B4673B /* RxSwift.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C8A56BCA1AD744E600B4673B /* RxSwift.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
C8F57F441AD02DBE006B8702 /* RxCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C8F57F431AD02DBE006B8702 /* RxCocoa.framework */; };
|
||||
|
|
@ -87,6 +88,7 @@
|
|||
C8813DA91AD2EBF30072A050 /* RootViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RootViewController.swift; sourceTree = "<group>"; };
|
||||
C890A6571AEBD26B00AFF7E6 /* GitHubSignupViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GitHubSignupViewController.swift; sourceTree = "<group>"; };
|
||||
C890A6591AEBD28A00AFF7E6 /* GitHubAPI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GitHubAPI.swift; sourceTree = "<group>"; };
|
||||
C890A65C1AEC084100AFF7E6 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
|
||||
C8A56BCA1AD744E600B4673B /* RxSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = RxSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
C8F57F431AD02DBE006B8702 /* RxCocoa.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = RxCocoa.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
|
|
@ -135,6 +137,7 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
C86E2F2E1AE5A0CA00C31024 /* Examples */,
|
||||
C890A65C1AEC084100AFF7E6 /* ViewController.swift */,
|
||||
C833670E1AD029AE00C668A7 /* AppDelegate.swift */,
|
||||
C833670F1AD029AE00C668A7 /* Example.swift */,
|
||||
C83367101AD029AE00C668A7 /* Services */,
|
||||
|
|
@ -377,6 +380,7 @@
|
|||
C86E2F421AE5A0CA00C31024 /* WikipediaSearchCell.swift in Sources */,
|
||||
C890A65A1AEBD28A00AFF7E6 /* GitHubAPI.swift in Sources */,
|
||||
C83367231AD029AE00C668A7 /* Example.swift in Sources */,
|
||||
C890A65D1AEC084100AFF7E6 /* ViewController.swift in Sources */,
|
||||
C890A6581AEBD26B00AFF7E6 /* GitHubSignupViewController.swift in Sources */,
|
||||
C83367311AD029AE00C668A7 /* Wireframe.swift in Sources */,
|
||||
C8813DAA1AD2EBF30072A050 /* RootViewController.swift in Sources */,
|
||||
|
|
|
|||
|
|
@ -7,3 +7,33 @@
|
|||
//
|
||||
|
||||
import Foundation
|
||||
import RxSwift
|
||||
|
||||
class GitHubAPI {
|
||||
let dataScheduler: ImmediateScheduler
|
||||
let URLSession: NSURLSession
|
||||
|
||||
init(dataScheduler: ImmediateScheduler, URLSession: NSURLSession) {
|
||||
self.dataScheduler = dataScheduler
|
||||
self.URLSession = URLSession
|
||||
}
|
||||
|
||||
func usernameAvailable(username: String) -> Observable<Bool> {
|
||||
// this is ofc just mock, but good enough
|
||||
let URL = NSURL(string: "https://github.com/\(username)")!
|
||||
let request = NSURLRequest(URL: URL)
|
||||
return self.URLSession.rx_request(request) >- map { (maybeData, maybeResponse) in
|
||||
if let response = maybeResponse as? NSHTTPURLResponse {
|
||||
return response.statusCode == 404
|
||||
}
|
||||
else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func signup(username: String, password: String) -> Observable<Void> {
|
||||
// this is also just a mock
|
||||
return returnElement(()) >- throttle(0.700, MainScheduler.sharedInstance)
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,27 @@
|
|||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import RxSwift
|
||||
import RxCocoa
|
||||
|
||||
class GitHubSignupViewController : UIViewController {
|
||||
class GitHubSignupViewController : ViewController {
|
||||
weak var username: UITextField!
|
||||
weak var password: UITextField!
|
||||
weak var repeatedPassword: UITextField!
|
||||
weak var signup: UIButton!
|
||||
|
||||
var disposeBag = DisposeBag()
|
||||
|
||||
var $ = (
|
||||
API: GitHubAPI(
|
||||
dataScheduler: MainScheduler.sharedInstance,
|
||||
URLSession: NSURLSession.sharedSession()
|
||||
)
|
||||
)
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -10,25 +10,19 @@ import UIKit
|
|||
import RxSwift
|
||||
import RxCocoa
|
||||
|
||||
public class WikipediaSearchViewController: UIViewController {
|
||||
class WikipediaSearchViewController: ViewController {
|
||||
|
||||
private let disposeBag: DisposeBag = DisposeBag()
|
||||
private var viewModel: SearchViewModel? = nil
|
||||
|
||||
override public func awakeFromNib() {
|
||||
override func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
}
|
||||
|
||||
// lifecycle
|
||||
|
||||
override public func viewDidLoad() {
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
#if DEBUG
|
||||
if resourceCount != 1 {
|
||||
println("Number of resources = \(resourceCount)")
|
||||
assert(resourceCount == 1)
|
||||
}
|
||||
#endif
|
||||
let operationQueue = NSOperationQueue()
|
||||
operationQueue.maxConcurrentOperationCount = 2
|
||||
operationQueue.qualityOfService = NSQualityOfService.UserInitiated
|
||||
|
|
@ -92,9 +86,4 @@ public class WikipediaSearchViewController: UIViewController {
|
|||
// }
|
||||
}
|
||||
|
||||
deinit {
|
||||
#if DEBUG
|
||||
println("View controller disposed with \(resourceCount) resournces")
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
//
|
||||
// ViewController.swift
|
||||
// RxExample
|
||||
//
|
||||
// Created by Krunoslav Zaher on 4/25/15.
|
||||
// Copyright (c) 2015 Krunoslav Zaher. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import RxSwift
|
||||
|
||||
class ViewController: UIViewController {
|
||||
override func viewDidLoad() {
|
||||
#if DEBUG
|
||||
if resourceCount != 1 {
|
||||
println("Number of resources = \(resourceCount)")
|
||||
assert(resourceCount == 1)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
deinit {
|
||||
#if DEBUG
|
||||
println("View controller disposed with \(resourceCount) resournces")
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
@ -33,6 +33,52 @@
|
|||
<view key="view" contentMode="scaleToFill" id="LK1-fd-xyr">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Username" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="5st-ss-RHs">
|
||||
<rect key="frame" x="28" y="90" width="265" height="30"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Password" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="kSi-Uf-OwR">
|
||||
<rect key="frame" x="28" y="157" width="265" height="30"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="username validation" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Dba-AF-T8S">
|
||||
<rect key="frame" x="28" y="122" width="265" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<color key="textColor" red="1" green="0.0" blue="0.090283701899999999" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="password validation" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="w7z-xW-FLz">
|
||||
<rect key="frame" x="28" y="189" width="265" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<color key="textColor" red="1" green="0.0" blue="0.090283701899999999" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Password Repeat" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="C3W-qo-PSG">
|
||||
<rect key="frame" x="28" y="221" width="265" height="30"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="repeated password validation" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="HDF-SC-Wnw">
|
||||
<rect key="frame" x="28" y="253" width="265" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<color key="textColor" red="1" green="0.0" blue="0.090283701899999999" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="kN3-eg-qK4">
|
||||
<rect key="frame" x="28" y="308" width="265" height="44"/>
|
||||
<color key="backgroundColor" red="0.54117647058823526" green="0.8666666666666667" blue="0.42745098039215684" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<state key="normal" title="Sign up">
|
||||
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
</button>
|
||||
<activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" animating="YES" style="gray" translatesAutoresizingMaskIntoConstraints="NO" id="zqf-Ga-MVL">
|
||||
<rect key="frame" x="28" y="123" width="20" height="20"/>
|
||||
</activityIndicatorView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
<navigationItem key="navigationItem" title="GitHub Signup" id="Cwl-YW-IkD"/>
|
||||
|
|
@ -52,7 +98,7 @@
|
|||
<sections>
|
||||
<tableViewSection headerTitle="Examples" footerTitle="Showcase examples for Rx. You can easily test for proper resource cleanup during poping of the navigation stack" id="QC3-bK-dI7">
|
||||
<cells>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="pxT-4B-gDc" style="IBUITableViewCellStyleDefault" id="yAf-eB-mRo">
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="pxT-4B-gDc" detailTextLabel="xZJ-Xt-MqD" style="IBUITableViewCellStyleSubtitle" id="yAf-eB-mRo">
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="yAf-eB-mRo" id="M3Y-AJ-f8i">
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
|
|
@ -63,13 +109,19 @@
|
|||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="MVVM Example" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="xZJ-Xt-MqD">
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="11"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
<segue destination="Iwo-im-m6d" kind="push" identifier="ShowWikipediaSearch" id="Gfh-zm-u0w"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="LN4-l3-ara" style="IBUITableViewCellStyleDefault" id="Hab-23-dUs">
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="LN4-l3-ara" detailTextLabel="BaB-5r-hmY" style="IBUITableViewCellStyleSubtitle" id="Hab-23-dUs">
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Hab-23-dUs" id="5ox-J8-FhR">
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
|
|
@ -80,6 +132,12 @@
|
|||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="View Controller Example" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="BaB-5r-hmY">
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="11"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
|
|
|
|||
Loading…
Reference in New Issue