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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "60x45",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x45",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "67x50",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "74x55",
"scale" : "2x"
},
{
"size" : "27x20",
"idiom" : "universal",
"scale" : "2x",
"platform" : "ios"
},
{
"size" : "27x20",
"idiom" : "universal",
"scale" : "3x",
"platform" : "ios"
},
{
"size" : "32x24",
"idiom" : "universal",
"scale" : "2x",
"platform" : "ios"
},
{
"size" : "32x24",
"idiom" : "universal",
"scale" : "3x",
"platform" : "ios"
},
{
"size" : "1024x768",
"idiom" : "ios-marketing",
"scale" : "1x",
"platform" : "ios"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "poll-hands1.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "poll-hands1-1.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "poll-hands1-2.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
166 changes: 166 additions & 0 deletions iMessagesExample/MessagesExtension/Base.lproj/MainInterface.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11542" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="ecZ-Lb-JcP">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11524"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Title-->
<scene sceneID="7MM-of-jgj">
<objects>
<viewController storyboardIdentifier="ExpandedVC" id="ObA-dk-sSI" customClass="ExpandedViewController" customModule="MessagesExtension" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="qkL-Od-lgU"/>
<viewControllerLayoutGuide type="bottom" id="n38-gi-rB5"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="zMn-AG-sqS">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Poll Variant" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Rb6-kc-P87">
<rect key="frame" x="16" y="280.5" width="343" height="30"/>
<nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
<connections>
<outlet property="delegate" destination="ObA-dk-sSI" id="Y8v-4s-Q11"/>
</connections>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="y4f-6N-Znl">
<rect key="frame" x="133.5" y="318.5" width="48" height="30"/>
<state key="normal" title="Cancel"/>
<connections>
<action selector="cancelPressed:" destination="ObA-dk-sSI" eventType="touchUpInside" id="29R-tN-EAc"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="H3Y-Y0-Sgm">
<rect key="frame" x="200.5" y="318.5" width="34" height="30"/>
<state key="normal" title="Save"/>
<connections>
<action selector="savePressed:" destination="ObA-dk-sSI" eventType="touchUpInside" id="IgQ-43-C6K"/>
</connections>
</button>
<tableView hidden="YES" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="02W-Ka-Yz0">
<rect key="frame" x="0.0" y="20" width="375" height="585"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Basic" textLabel="Ixt-dc-Fae" style="IBUITableViewCellStyleDefault" id="9xi-hS-hOL">
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="9xi-hS-hOL" id="ZCL-5z-9ih">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Ixt-dc-Fae">
<rect key="frame" x="15" y="0.0" width="345" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<sections/>
<connections>
<outlet property="dataSource" destination="ObA-dk-sSI" id="UKN-pL-8MI"/>
<outlet property="delegate" destination="ObA-dk-sSI" id="DiP-vc-NhI"/>
</connections>
</tableView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="R2v-MZ-fvg">
<rect key="frame" x="132" y="621" width="111" height="30"/>
<state key="normal" title="Add new variant"/>
<connections>
<action selector="addNewVariantPressed:" destination="ObA-dk-sSI" eventType="touchUpInside" id="bBN-Ro-z1s"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="02W-Ka-Yz0" secondAttribute="trailing" id="77c-4L-wfx"/>
<constraint firstItem="y4f-6N-Znl" firstAttribute="centerX" secondItem="zMn-AG-sqS" secondAttribute="centerX" constant="-30" id="CfA-5h-g6w"/>
<constraint firstAttribute="trailing" secondItem="Rb6-kc-P87" secondAttribute="trailing" constant="16" id="I3K-I8-RxP"/>
<constraint firstItem="02W-Ka-Yz0" firstAttribute="top" secondItem="qkL-Od-lgU" secondAttribute="bottom" id="RdV-br-noX"/>
<constraint firstItem="Rb6-kc-P87" firstAttribute="leading" secondItem="zMn-AG-sqS" secondAttribute="leading" constant="16" id="T0X-4k-tcW"/>
<constraint firstItem="H3Y-Y0-Sgm" firstAttribute="centerX" secondItem="zMn-AG-sqS" secondAttribute="centerX" constant="30" id="XYQ-PG-T6S"/>
<constraint firstItem="y4f-6N-Znl" firstAttribute="centerY" secondItem="zMn-AG-sqS" secondAttribute="centerY" id="ZQh-F5-1fw"/>
<constraint firstItem="H3Y-Y0-Sgm" firstAttribute="top" secondItem="Rb6-kc-P87" secondAttribute="bottom" constant="8" id="a10-gv-g8q"/>
<constraint firstItem="02W-Ka-Yz0" firstAttribute="leading" secondItem="zMn-AG-sqS" secondAttribute="leading" id="cIB-Nx-oKk"/>
<constraint firstItem="n38-gi-rB5" firstAttribute="top" secondItem="R2v-MZ-fvg" secondAttribute="bottom" constant="16" id="fMS-Tj-Su6"/>
<constraint firstItem="R2v-MZ-fvg" firstAttribute="top" secondItem="02W-Ka-Yz0" secondAttribute="bottom" constant="16" id="hED-4g-Vi3"/>
<constraint firstItem="R2v-MZ-fvg" firstAttribute="centerX" secondItem="zMn-AG-sqS" secondAttribute="centerX" id="isE-Rb-qx0"/>
<constraint firstItem="H3Y-Y0-Sgm" firstAttribute="centerY" secondItem="zMn-AG-sqS" secondAttribute="centerY" id="rpB-mM-9NI"/>
</constraints>
</view>
<navigationItem key="navigationItem" title="Title" id="C1w-48-VcR">
<barButtonItem key="rightBarButtonItem" title="+" id="J7V-6D-02b"/>
</navigationItem>
<connections>
<outlet property="addNewVariant" destination="R2v-MZ-fvg" id="fom-aI-rKG"/>
<outlet property="pollVariantTextField" destination="Rb6-kc-P87" id="uDG-EF-pEq"/>
<outlet property="tableView" destination="02W-Ka-Yz0" id="5l7-3H-hCd"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="X47-rx-isc" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="769.60000000000002" y="392.20389805097454"/>
</scene>
<!--Compact View Controller-->
<scene sceneID="ljb-92-1i3">
<objects>
<viewController storyboardIdentifier="CompactVC" id="WPR-hO-rLV" customClass="CompactViewController" customModule="MessagesExtension" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="n87-4f-hr4"/>
<viewControllerLayoutGuide type="bottom" id="UOU-rG-TLA"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="UJi-pV-kpd">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="43V-Fb-fDJ">
<rect key="frame" x="150" y="318.5" width="75" height="30"/>
<state key="normal" title="Create Poll"/>
<connections>
<action selector="actionButtonPressed:" destination="WPR-hO-rLV" eventType="touchUpInside" id="GMn-vu-bdZ"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="43V-Fb-fDJ" firstAttribute="centerX" secondItem="UJi-pV-kpd" secondAttribute="centerX" id="4wZ-4f-vTC"/>
<constraint firstItem="43V-Fb-fDJ" firstAttribute="centerY" secondItem="UJi-pV-kpd" secondAttribute="centerY" id="C3H-zy-mT3"/>
</constraints>
</view>
<connections>
<outlet property="actionButton" destination="43V-Fb-fDJ" id="7z4-4H-ebC"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="zg6-AW-cGU" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="770" y="1124"/>
</scene>
<!--Messages View Controller-->
<scene sceneID="gxa-zs-Rky">
<objects>
<viewController id="ecZ-Lb-JcP" customClass="MessagesViewController" customModule="MessagesExtension" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="HNB-1L-c7e"/>
<viewControllerLayoutGuide type="bottom" id="UkB-SE-Ech"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="ZhF-VS-oK5">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="q3z-Kc-ftO" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-2" y="456"/>
</scene>
</scenes>
</document>
36 changes: 36 additions & 0 deletions iMessagesExample/MessagesExtension/CompactViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// CompactViewController.swift
// VoteApp
//
// Created by Ellina Kuznecova on 01.11.16.
// Copyright © 2016 Ellina Kuznetcova. All rights reserved.
//

import UIKit

protocol CompactViewControllerDelegate: class {
func createPollPressed()
func sendMessage()
}

class CompactViewController: UIViewController {
@IBOutlet weak var actionButton: UIButton!

var options: [PollOption] = []
weak var delegate: CompactViewControllerDelegate?

override func viewDidLoad() {
super.viewDidLoad()

let actionButtonTitle = self.options.count > 0 ? "Send Poll" : "Create Poll"
self.actionButton.setTitle(actionButtonTitle, for: .normal)
}

@IBAction func actionButtonPressed(_ sender: AnyObject) {
if self.options.count > 0 {
self.delegate?.sendMessage()
} else {
self.delegate?.createPollPressed()
}
}
}
71 changes: 71 additions & 0 deletions iMessagesExample/MessagesExtension/ExpandedViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//
// ExpandedViewController.swift
// VoteApp
//
// Created by Ellina Kuznecova on 01.11.16.
// Copyright © 2016 Ellina Kuznetcova. All rights reserved.
//

import UIKit

protocol ExpandedViewControllerDelegate: class {
func pollUpdated(poll: PollEntity)
}

class ExpandedViewController: UIViewController {
@IBOutlet weak var pollVariantTextField: UITextField!
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var addNewVariant: UIButton!

weak var delegate: ExpandedViewControllerDelegate?
var data: PollEntity!

override func viewDidLoad() {
super.viewDidLoad()

self.changeViewsState(to: self.data.options.count == 0)
}

@IBAction func addNewVariantPressed(_ sender: AnyObject) {
self.changeViewsState(to: true)
}

@IBAction func savePressed(_ sender: AnyObject) {
guard let text = self.pollVariantTextField.text, text != "" else {return}
self.data.options.append(PollOption(name: text))
self.pollVariantTextField.text = ""
self.tableView.reloadData()
self.delegate?.pollUpdated(poll: self.data)
self.changeViewsState(to: false)
}

@IBAction func cancelPressed(_ sender: AnyObject) {
self.changeViewsState(to: false)
}

private func changeViewsState(to visibility: Bool) {
self.tableView.isHidden = visibility
self.addNewVariant.isHidden = visibility
}
}

extension ExpandedViewController: UITableViewDataSource {

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.data.options.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Basic")!
cell.textLabel?.text = self.data.options[indexPath.row].name
return cell
}
}

extension ExpandedViewController: UITextFieldDelegate {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
self.view.endEditing(true)
self.savePressed(self)
return true
}
}
Loading