Skip to content

Instantly share code, notes, and snippets.

View chelseatroy's full-sized avatar

Chelsea Troy chelseatroy

View GitHub Profile
@chelseatroy
chelseatroy / ExampleViewController.swift
Last active September 7, 2016 17:17
ViewController Dependency Injection
public class ExampleViewController: UIViewController {
var dependableService: DependableService
@IBOutlet var someTextLabel: UITextLabel!
class func loadFromStoryboard(
dependableService: DependableService) -> ExampleViewController {
let controller = UIStoryboard(name:"Main", bundle:NSBundle(forClass:self))
.instantiateViewControllerWithIdentifier("ExampleViewController")
as! ExampleViewController
@chelseatroy
chelseatroy / CandiesMasterDetailFeature.swift
Last active September 8, 2016 22:34
Annotated iOS Feature Test
import XCTest
import Hamcrest
import PactConsumerSwift
class CandiesMasterDetailFeature: XCTestCase {
override func setUp() {
super.setUp()
continueAfterFailure = false //So the moment that an assertion in the test fails, we will not continue with the test
flipButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (mCardSideShowing.equals(CardSide.FRONT)) {
getActivity().getFragmentManager()
.beginTransaction()
.setCustomAnimations(R.animator.card_flip_right_in, R.animator.card_flip_right_out, R.animator.card_flip_left_in, R.animator.card_flip_left_out)
.replace(R.id.card_fragment_container, new CardBackFragment())
.commit();
repositories{
flatDir{
dirs 'libs'
}
}
dependencies {
//Design and Aminations
compile 'com.android.support:cardview-v7:23.1.1'
compile (name:'library-2.4.1', ext:'aar')
@chelseatroy
chelseatroy / ExampleViewControllerTest.swift
Last active January 25, 2017 02:01
Test Screen Transition iOS
import XCTest
import Hamcrest
@testable import MyExampleApp
class ExampleViewControllerTest: XCTestCase {
...
func testNavigatesToOtherScreen() {
@chelseatroy
chelseatroy / ExampleViewController.swift
Created January 25, 2017 02:04
Screen Transition iOS
class ExampleViewController: UIViewController {
...
@IBAction func didTapButtonToGoToOtherViewController(sender: AnyObject) {
self.performSegueWithIdentifier("otherViewControllerSegue", sender: nil)
}
}
@chelseatroy
chelseatroy / ExampleViewController.swift
Created January 26, 2017 00:49
Load from Storyboard iOS Example
import UIKit
class ExampleViewController: UIViewController {
class func loadFromStoryboard(exampleService: ExampleService) -> ExampleViewController {
let exampleViewController:ExampleViewController =
UIStoryboard(name:"Main", bundle:NSBundle(forClass:self))
.instantiateViewControllerWithIdentifier("ExampleViewController")
as! ExampleViewController
@chelseatroy
chelseatroy / AppEnvironment.swift
Created January 26, 2017 01:52
Load from Storyboard Example iOS
import Foundation
class AppEnvironment: NSObject {
static let sharedEnvironment = AppEnvironment()
let exampleService: ExampleService
override init() {
self.exampleService = ExampleService()
@chelseatroy
chelseatroy / ListOfFruitsViewController.swift
Last active January 26, 2017 02:16
Passing Information With Segues Example iOS
import UIKit
import FutureKit
class ListOfFruitsViewController: UITableViewController {
...
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if (segue.identifier == "goToFruitDetailsSegue") {
if let
@chelseatroy
chelseatroy / FruitDetailViewController.swift
Last active January 26, 2017 02:18
Passing Information With Segues Example iOS Raw
import UIKit
class FruitDetailViewController: UIViewController {
var fruit: FruitAppFruit?
...
}