Skip to content

Commit f78eaf0

Browse files
committed
AppChat: Version 1.0, 2016-10-27
First release This sample demonstrates how to incorporate 3D Touch into an iOS App. It makes use of Home Screen Quick Actions (both static and dynamic), Peek and Pop, Peek Actions and UIPreviewInteraction. Signed-off-by: Liu Lantao <[email protected]>
1 parent b374fb8 commit f78eaf0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2169
-0
lines changed

AppChat/AppChat.xcodeproj/project.pbxproj

+495
Large diffs are not rendered by default.

AppChat/AppChat.xcodeproj/project.xcworkspace/contents.xcworkspacedata

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AppChat/AppChat/AppDelegate.swift

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
Copyright (C) 2016 Apple Inc. All Rights Reserved.
3+
See LICENSE.txt for this sample’s licensing information
4+
5+
Abstract:
6+
The app delegate.
7+
*/
8+
9+
import UIKit
10+
11+
@UIApplicationMain
12+
class AppDelegate: UIResponder, UIApplicationDelegate {
13+
14+
var window: UIWindow?
15+
var rootViewController: UIViewController? {
16+
return window?.rootViewController
17+
}
18+
19+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
20+
var performAdditionalHandling = true
21+
22+
window?.makeKeyAndVisible()
23+
if let shortcutItem = launchOptions?[.shortcutItem] as? UIApplicationShortcutItem, let rootViewController = rootViewController {
24+
let didHandleShortcutItem = ShortcutItemHandler.handle(shortcutItem, with: rootViewController)
25+
performAdditionalHandling = !didHandleShortcutItem
26+
}
27+
28+
ShortcutItemHandler.updateDynamicShortcutItems(for: application)
29+
30+
return performAdditionalHandling
31+
}
32+
33+
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
34+
var didHandleShortcutItem = false
35+
36+
if let rootViewController = rootViewController {
37+
didHandleShortcutItem = ShortcutItemHandler.handle(shortcutItem, with: rootViewController)
38+
}
39+
40+
completionHandler(didHandleShortcutItem)
41+
}
42+
}
43+
44+
extension UIApplication {
45+
func present(alert: UIAlertController, animated: Bool = true) {
46+
UIApplication.shared.keyWindow?.rootViewController?.present(alert, animated: animated)
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"images" : [
3+
{
4+
"size" : "29x29",
5+
"idiom" : "iphone",
6+
"filename" : "[email protected]",
7+
"scale" : "2x"
8+
},
9+
{
10+
"size" : "29x29",
11+
"idiom" : "iphone",
12+
"filename" : "[email protected]",
13+
"scale" : "3x"
14+
},
15+
{
16+
"size" : "40x40",
17+
"idiom" : "iphone",
18+
"filename" : "[email protected]",
19+
"scale" : "2x"
20+
},
21+
{
22+
"size" : "40x40",
23+
"idiom" : "iphone",
24+
"filename" : "[email protected]",
25+
"scale" : "3x"
26+
},
27+
{
28+
"size" : "60x60",
29+
"idiom" : "iphone",
30+
"filename" : "[email protected]",
31+
"scale" : "2x"
32+
},
33+
{
34+
"size" : "60x60",
35+
"idiom" : "iphone",
36+
"filename" : "[email protected]",
37+
"scale" : "3x"
38+
},
39+
{
40+
"size" : "29x29",
41+
"idiom" : "ipad",
42+
"filename" : "Icon-Small.png",
43+
"scale" : "1x"
44+
},
45+
{
46+
"size" : "29x29",
47+
"idiom" : "ipad",
48+
"filename" : "[email protected]",
49+
"scale" : "2x"
50+
},
51+
{
52+
"size" : "40x40",
53+
"idiom" : "ipad",
54+
"filename" : "[email protected]",
55+
"scale" : "1x"
56+
},
57+
{
58+
"size" : "40x40",
59+
"idiom" : "ipad",
60+
"filename" : "[email protected]",
61+
"scale" : "2x"
62+
},
63+
{
64+
"size" : "76x76",
65+
"idiom" : "ipad",
66+
"filename" : "Icon-76.png",
67+
"scale" : "1x"
68+
},
69+
{
70+
"size" : "76x76",
71+
"idiom" : "ipad",
72+
"filename" : "[email protected]",
73+
"scale" : "2x"
74+
},
75+
{
76+
"size" : "83.5x83.5",
77+
"idiom" : "ipad",
78+
"filename" : "[email protected]",
79+
"scale" : "2x"
80+
}
81+
],
82+
"info" : {
83+
"version" : 1,
84+
"author" : "xcode"
85+
}
86+
}
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
<samplecode>
3+
<abstract>
4+
Localized strings used in the Info.plist file.
5+
</abstract>
6+
</samplecode>
7+
*/
8+
9+
"NSContactsUsageDescription" = "AppChat will try to match your friends with the contacts on your device.";
10+
11+
"NSCameraUsageDescription" = "AppChat uses the camera to take photos for chats.";
12+
13+
"SHORTCUT_TITLE_NEWCHAT" = "New Chat";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8150" systemVersion="15A204g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
5+
</dependencies>
6+
<scenes>
7+
<!--View Controller-->
8+
<scene sceneID="EHf-IW-A2E">
9+
<objects>
10+
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
11+
<layoutGuides>
12+
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
13+
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
14+
</layoutGuides>
15+
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
16+
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
17+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
18+
<animations/>
19+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
20+
</view>
21+
</viewController>
22+
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
23+
</objects>
24+
<point key="canvasLocation" x="53" y="375"/>
25+
</scene>
26+
</scenes>
27+
</document>
+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11129.11" systemVersion="15F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="KxG-EO-L4l">
3+
<dependencies>
4+
<deployment identifier="iOS"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11103.9"/>
6+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
7+
</dependencies>
8+
<scenes>
9+
<!--Navigation Controller-->
10+
<scene sceneID="9SA-Mf-wTW">
11+
<objects>
12+
<navigationController id="KxG-EO-L4l" sceneMemberID="viewController">
13+
<navigationBar key="navigationBar" contentMode="scaleToFill" id="v8m-ia-bY8">
14+
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
15+
<autoresizingMask key="autoresizingMask"/>
16+
</navigationBar>
17+
<connections>
18+
<segue destination="8f4-oE-Jp8" kind="relationship" relationship="rootViewController" id="IJm-Oc-yQ1"/>
19+
</connections>
20+
</navigationController>
21+
<placeholder placeholderIdentifier="IBFirstResponder" id="0V8-dC-09h" userLabel="First Responder" sceneMemberID="firstResponder"/>
22+
</objects>
23+
<point key="canvasLocation" x="-170.79022226486086" y="-24.7376311844078"/>
24+
</scene>
25+
<!--AppChat-->
26+
<scene sceneID="Jdk-Is-YOt">
27+
<objects>
28+
<tableViewController id="8f4-oE-Jp8" customClass="ChatTableViewController" customModule="AppChat" customModuleProvider="target" sceneMemberID="viewController">
29+
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="60" sectionHeaderHeight="28" sectionFooterHeight="28" id="CnS-wC-uIv">
30+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
31+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
32+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
33+
<prototypes>
34+
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="ChatTableViewCell" textLabel="7wi-9Z-osP" detailTextLabel="R6b-P1-aL8" imageView="iQY-My-G5N" rowHeight="60" style="IBUITableViewCellStyleSubtitle" id="ytM-2q-vAP" customClass="ChatTableViewCell" customModule="AppChat" customModuleProvider="target">
35+
<frame key="frameInset" minY="92" width="375" height="60"/>
36+
<autoresizingMask key="autoresizingMask"/>
37+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ytM-2q-vAP" id="7hR-oH-DS1">
38+
<frame key="frameInset" width="375" height="59"/>
39+
<autoresizingMask key="autoresizingMask"/>
40+
<subviews>
41+
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Chat from Lexi Torres" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="7wi-9Z-osP">
42+
<frame key="frameInset" minX="89" minY="12" width="164" height="21"/>
43+
<autoresizingMask key="autoresizingMask"/>
44+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
45+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
46+
<nil key="highlightedColor"/>
47+
</label>
48+
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="0 seconds ago" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="R6b-P1-aL8">
49+
<frame key="frameInset" minX="89" minY="33" width="83" height="15"/>
50+
<autoresizingMask key="autoresizingMask"/>
51+
<fontDescription key="fontDescription" type="system" pointSize="12"/>
52+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
53+
<nil key="highlightedColor"/>
54+
</label>
55+
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleAspectFit" image="ProfilePhoto-LexiTorres.jpg" id="iQY-My-G5N">
56+
<frame key="frameInset" minX="15" width="59" height="59"/>
57+
<autoresizingMask key="autoresizingMask"/>
58+
</imageView>
59+
</subviews>
60+
</tableViewCellContentView>
61+
<connections>
62+
<segue destination="6Ly-0W-3A4" kind="show" id="ap3-1g-PXW"/>
63+
</connections>
64+
</tableViewCell>
65+
</prototypes>
66+
<connections>
67+
<outlet property="dataSource" destination="8f4-oE-Jp8" id="1KR-Jd-c4V"/>
68+
<outlet property="delegate" destination="8f4-oE-Jp8" id="NP8-Ka-Cad"/>
69+
</connections>
70+
</tableView>
71+
<navigationItem key="navigationItem" title="AppChat" id="G6L-ny-A5r">
72+
<barButtonItem key="rightBarButtonItem" systemItem="compose" id="1te-Ba-I01">
73+
<connections>
74+
<action selector="createNewChat:" destination="8f4-oE-Jp8" id="AHQ-bG-wIY"/>
75+
</connections>
76+
</barButtonItem>
77+
</navigationItem>
78+
</tableViewController>
79+
<placeholder placeholderIdentifier="IBFirstResponder" id="EbV-HZ-cHs" userLabel="First Responder" sceneMemberID="firstResponder"/>
80+
</objects>
81+
<point key="canvasLocation" x="705.74115139352" y="-24.737631184407899"/>
82+
</scene>
83+
<!--Chat from Lexi Torres-->
84+
<scene sceneID="Nui-V1-r0A">
85+
<objects>
86+
<viewController storyboardIdentifier="ChatDetailViewController" title="Chat from Lexi Torres" id="6Ly-0W-3A4" customClass="ChatDetailViewController" customModule="AppChat" customModuleProvider="target" sceneMemberID="viewController">
87+
<layoutGuides>
88+
<viewControllerLayoutGuide type="top" id="Rsn-nU-D9B"/>
89+
<viewControllerLayoutGuide type="bottom" id="BII-8g-BtT"/>
90+
</layoutGuides>
91+
<view key="view" clipsSubviews="YES" contentMode="scaleToFill" id="XeI-cs-E9s">
92+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
93+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
94+
<subviews>
95+
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ChatImage-1.jpg" translatesAutoresizingMaskIntoConstraints="NO" id="mtk-x2-k5n"/>
96+
</subviews>
97+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
98+
<constraints>
99+
<constraint firstItem="mtk-x2-k5n" firstAttribute="height" secondItem="XeI-cs-E9s" secondAttribute="height" id="7hK-Hk-frI"/>
100+
<constraint firstItem="mtk-x2-k5n" firstAttribute="centerX" secondItem="XeI-cs-E9s" secondAttribute="centerX" id="XDv-Xn-WSh"/>
101+
<constraint firstItem="mtk-x2-k5n" firstAttribute="centerY" secondItem="XeI-cs-E9s" secondAttribute="centerY" id="aYZ-DC-Mwt"/>
102+
<constraint firstItem="mtk-x2-k5n" firstAttribute="width" secondItem="XeI-cs-E9s" secondAttribute="width" id="yEV-mq-SoK"/>
103+
</constraints>
104+
</view>
105+
<connections>
106+
<outlet property="imageView" destination="mtk-x2-k5n" id="jEs-ba-19u"/>
107+
</connections>
108+
</viewController>
109+
<placeholder placeholderIdentifier="IBFirstResponder" id="ifq-Db-X5G" userLabel="First Responder" sceneMemberID="firstResponder"/>
110+
</objects>
111+
<point key="canvasLocation" x="1621.5999999999999" y="-25.637181409295355"/>
112+
</scene>
113+
</scenes>
114+
<resources>
115+
<image name="ChatImage-1.jpg" width="1667" height="2500"/>
116+
<image name="ProfilePhoto-LexiTorres.jpg" width="440" height="440"/>
117+
</resources>
118+
</document>
758 KB
Loading
1.12 MB
Loading
1.61 MB
Loading
1.71 MB
Loading
6.62 MB
Loading
1.57 MB
Loading
830 KB
Loading
625 KB
Loading
6.06 MB
Loading

0 commit comments

Comments
 (0)