Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
399 changes: 399 additions & 0 deletions Poll/Poll.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Poll.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
37 changes: 37 additions & 0 deletions Poll/Poll/Controllers/CombinedViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// CombinedViewController.swift
// Poll
//
// Created by Ilgar Ilyasov on 8/30/18.
// Copyright © 2018 Lambda School. All rights reserved.
//

import UIKit

class CombinedViewController: UIViewController, VoteControlProtocol {

override func viewDidLoad() {
super.viewDidLoad()

}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

if segue.identifier == "VotingSegue" {

guard let votingVC = segue.destination as? VotingViewController else { return }

votingVC.voteController = voteController

} else if segue.identifier == "ResultsSegue" {

guard let resultsVC = segue.destination as? ResultsTableViewController else { return }

resultsVC.voteController = voteController
}

}

var voteController: VoteController?

}
33 changes: 33 additions & 0 deletions Poll/Poll/Controllers/PollingTabBarViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// PollingTabBarViewController.swift
// Poll
//
// Created by Ilgar Ilyasov on 8/30/18.
// Copyright © 2018 Lambda School. All rights reserved.
//

import UIKit

class PollingTabBarViewController: UITabBarController {

override func viewDidLoad() {
super.viewDidLoad()

passVoteControllerToChildViewController()
}

let voteController = VoteController()

func passVoteControllerToChildViewController() {

guard let viewControllers = viewControllers.self else { return }

for viewController in viewControllers {

if let viewController = viewController as? VoteControlProtocol {

viewController.voteController = voteController
}
}
}
}
33 changes: 33 additions & 0 deletions Poll/Poll/Controllers/ResultsTableViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// ResultsTableViewController.swift
// Poll
//
// Created by Ilgar Ilyasov on 8/30/18.
// Copyright © 2018 Lambda School. All rights reserved.
//

import UIKit

class ResultsTableViewController: UITableViewController, VoteControlProtocol {

var voteController: VoteController?

override func viewWillAppear(_ animated: Bool) {

tableView.reloadData()
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return voteController?.votes.count ?? 0
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "ResultTableViewCell", for: indexPath)
let vote = voteController?.votes[indexPath.row]

cell.textLabel?.text = vote?.name
cell.detailTextLabel?.text = vote?.response

return cell
}
}
20 changes: 20 additions & 0 deletions Poll/Poll/Controllers/VoteController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// VoteController.swift
// Poll
//
// Created by Ilgar Ilyasov on 8/30/18.
// Copyright © 2018 Lambda School. All rights reserved.
//

import Foundation

class VoteController {

private(set) var votes: [Vote] = []

func createVote(name: String, response: String) {

let newVote = Vote(name: name, response: response)
votes.append(newVote)
}
}
30 changes: 30 additions & 0 deletions Poll/Poll/Controllers/VotingViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// VotingViewController.swift
// Poll
//
// Created by Ilgar Ilyasov on 8/30/18.
// Copyright © 2018 Lambda School. All rights reserved.
//

import UIKit

class VotingViewController: UIViewController, VoteControlProtocol {

override func viewDidLoad() {
super.viewDidLoad()
}

@IBAction func submitButtonAction(_ sender: Any) {

guard let name = nameTextField.text,
let response = responseTextField.text else { return }

voteController?.createVote(name: name, response: response)
}

@IBOutlet weak var nameTextField: UITextField!
@IBOutlet weak var responseTextField: UITextField!

var voteController: VoteController?

}
25 changes: 25 additions & 0 deletions Poll/Poll/Stroyboards/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
62 changes: 62 additions & 0 deletions Poll/Poll/Stroyboards/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="tcS-qm-cXu">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Polling Tab Bar View Controller-->
<scene sceneID="Syg-up-i19">
<objects>
<tabBarController id="tcS-qm-cXu" customClass="PollingTabBarViewController" customModule="Poll" customModuleProvider="target" sceneMemberID="viewController">
<tabBar key="tabBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="den-Vl-dmP">
<rect key="frame" x="0.0" y="0.0" width="375" height="49"/>
<autoresizingMask key="autoresizingMask"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</tabBar>
<connections>
<segue destination="Pnu-tE-JKA" kind="relationship" relationship="viewControllers" id="k9j-ni-IgZ"/>
<segue destination="M6B-zS-y2I" kind="relationship" relationship="viewControllers" id="DfM-EC-6lM"/>
<segue destination="Nky-p5-ZrS" kind="relationship" relationship="viewControllers" id="Pa4-B4-3v6"/>
</connections>
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="QdL-Ud-aXe" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-404" y="-8"/>
</scene>
<!--Voting-->
<scene sceneID="Kif-jM-kva">
<objects>
<viewControllerPlaceholder storyboardName="Voting" id="Pnu-tE-JKA" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="Voting" id="UBy-34-4Vk"/>
</viewControllerPlaceholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="fbQ-U4-RVN" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="229" y="-297"/>
</scene>
<!--Results-->
<scene sceneID="PY8-Ur-kLb">
<objects>
<viewControllerPlaceholder storyboardName="Results" id="M6B-zS-y2I" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="Results" id="zHp-1w-KdS"/>
</viewControllerPlaceholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="PSF-wU-Yf3" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="230" y="-10"/>
</scene>
<!--Combined-->
<scene sceneID="JfK-3Y-zdV">
<objects>
<viewControllerPlaceholder storyboardName="Combined" id="Nky-p5-ZrS" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="Combined" id="MSK-uS-ulU"/>
</viewControllerPlaceholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="fsa-5U-O3Q" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="229" y="279"/>
</scene>
</scenes>
</document>
71 changes: 71 additions & 0 deletions Poll/Poll/Stroyboards/Combined.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="qMY-Ik-GT6">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Combined-->
<scene sceneID="MbT-52-0X6">
<objects>
<viewController id="qMY-Ik-GT6" customClass="CombinedViewController" customModule="Poll" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="ukv-5O-qRD">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<containerView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="c83-3k-whv">
<rect key="frame" x="0.0" y="0.0" width="375" height="330"/>
<connections>
<segue destination="Y4t-w9-Etj" kind="embed" identifier="VotingSegue" id="Q6E-oL-gp0"/>
</connections>
</containerView>
<containerView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="tWF-qj-hNx">
<rect key="frame" x="0.0" y="330" width="375" height="288"/>
<connections>
<segue destination="jeC-iG-Una" kind="embed" identifier="ResultsSegue" id="9nC-kr-p1u"/>
</connections>
</containerView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="c83-3k-whv" firstAttribute="leading" secondItem="ukv-5O-qRD" secondAttribute="leading" id="Pvo-es-Dp8"/>
<constraint firstItem="tWF-qj-hNx" firstAttribute="top" secondItem="ukv-5O-qRD" secondAttribute="top" constant="330" id="PxM-ER-mUi"/>
<constraint firstItem="tWF-qj-hNx" firstAttribute="top" secondItem="c83-3k-whv" secondAttribute="bottom" id="QVF-qy-iUn"/>
<constraint firstItem="c83-3k-whv" firstAttribute="top" secondItem="ukv-5O-qRD" secondAttribute="top" id="T1C-Bj-G8g"/>
<constraint firstItem="c83-3k-whv" firstAttribute="trailing" secondItem="tWF-qj-hNx" secondAttribute="trailing" id="Tx2-5Z-oXX"/>
<constraint firstItem="tWF-qj-hNx" firstAttribute="bottom" secondItem="cwk-8v-yO5" secondAttribute="bottom" id="V6s-Dg-6VC"/>
<constraint firstItem="c83-3k-whv" firstAttribute="leading" secondItem="tWF-qj-hNx" secondAttribute="leading" id="gpp-Lm-diG"/>
<constraint firstAttribute="trailing" secondItem="c83-3k-whv" secondAttribute="trailing" id="sLI-Hh-itQ"/>
</constraints>
<viewLayoutGuide key="safeArea" id="cwk-8v-yO5"/>
</view>
<tabBarItem key="tabBarItem" title="Combined" id="WEC-l4-p8O"/>
<simulatedTabBarMetrics key="simulatedBottomBarMetrics"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="zdw-qU-dFN" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="117.59999999999999" y="241.52923538230885"/>
</scene>
<!--Results-->
<scene sceneID="Psu-uA-baf">
<objects>
<viewControllerPlaceholder storyboardName="Results" id="jeC-iG-Una" sceneMemberID="viewController"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="quF-cV-okM" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="713" y="379"/>
</scene>
<!--Voting-->
<scene sceneID="L8e-LK-HqS">
<objects>
<viewControllerPlaceholder storyboardName="Voting" id="Y4t-w9-Etj" sceneMemberID="viewController"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="6QQ-ez-eM5" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="713" y="70"/>
</scene>
</scenes>
</document>
Loading