Skip to content

Commit 5b913a2

Browse files
authored
Merge pull request GitHawkApp#6 from GitHawkApp/example
Add examples project and update README
2 parents 6a49884 + 62c089c commit 5b913a2

33 files changed

+2024
-2
lines changed

Examples/Examples.xcodeproj/project.pbxproj

Lines changed: 410 additions & 0 deletions
Large diffs are not rendered by default.

Examples/Examples.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/Examples.xcworkspace/contents.xcworkspacedata

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/Examples/AppDelegate.swift

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// AppDelegate.swift
3+
// Examples
4+
//
5+
// Created by Ryan Nystrom on 1/28/18.
6+
// Copyright © 2018 Ryan Nystrom. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
@UIApplicationMain
12+
class AppDelegate: UIResponder, UIApplicationDelegate {
13+
14+
var window: UIWindow?
15+
16+
17+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
18+
// Override point for customization after application launch.
19+
return true
20+
}
21+
22+
func applicationWillResignActive(_ application: UIApplication) {
23+
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
24+
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
25+
}
26+
27+
func applicationDidEnterBackground(_ application: UIApplication) {
28+
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
29+
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30+
}
31+
32+
func applicationWillEnterForeground(_ application: UIApplication) {
33+
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
34+
}
35+
36+
func applicationDidBecomeActive(_ application: UIApplication) {
37+
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
38+
}
39+
40+
func applicationWillTerminate(_ application: UIApplication) {
41+
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42+
}
43+
44+
45+
}
46+
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"size" : "20x20",
6+
"scale" : "2x"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"size" : "20x20",
11+
"scale" : "3x"
12+
},
13+
{
14+
"idiom" : "iphone",
15+
"size" : "29x29",
16+
"scale" : "2x"
17+
},
18+
{
19+
"idiom" : "iphone",
20+
"size" : "29x29",
21+
"scale" : "3x"
22+
},
23+
{
24+
"idiom" : "iphone",
25+
"size" : "40x40",
26+
"scale" : "2x"
27+
},
28+
{
29+
"idiom" : "iphone",
30+
"size" : "40x40",
31+
"scale" : "3x"
32+
},
33+
{
34+
"idiom" : "iphone",
35+
"size" : "60x60",
36+
"scale" : "2x"
37+
},
38+
{
39+
"idiom" : "iphone",
40+
"size" : "60x60",
41+
"scale" : "3x"
42+
},
43+
{
44+
"idiom" : "ipad",
45+
"size" : "20x20",
46+
"scale" : "1x"
47+
},
48+
{
49+
"idiom" : "ipad",
50+
"size" : "20x20",
51+
"scale" : "2x"
52+
},
53+
{
54+
"idiom" : "ipad",
55+
"size" : "29x29",
56+
"scale" : "1x"
57+
},
58+
{
59+
"idiom" : "ipad",
60+
"size" : "29x29",
61+
"scale" : "2x"
62+
},
63+
{
64+
"idiom" : "ipad",
65+
"size" : "40x40",
66+
"scale" : "1x"
67+
},
68+
{
69+
"idiom" : "ipad",
70+
"size" : "40x40",
71+
"scale" : "2x"
72+
},
73+
{
74+
"idiom" : "ipad",
75+
"size" : "76x76",
76+
"scale" : "1x"
77+
},
78+
{
79+
"idiom" : "ipad",
80+
"size" : "76x76",
81+
"scale" : "2x"
82+
},
83+
{
84+
"idiom" : "ipad",
85+
"size" : "83.5x83.5",
86+
"scale" : "2x"
87+
}
88+
],
89+
"info" : {
90+
"version" : 1,
91+
"author" : "xcode"
92+
}
93+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<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">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
5+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
6+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
7+
</dependencies>
8+
<scenes>
9+
<!--View Controller-->
10+
<scene sceneID="EHf-IW-A2E">
11+
<objects>
12+
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
13+
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
14+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
15+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
17+
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
18+
</view>
19+
</viewController>
20+
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
21+
</objects>
22+
<point key="canvasLocation" x="53" y="375"/>
23+
</scene>
24+
</scenes>
25+
</document>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="xNF-HH-Cif">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
6+
<dependencies>
7+
<deployment identifier="iOS"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
9+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
10+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
11+
</dependencies>
12+
<scenes>
13+
<!--Navigation Controller-->
14+
<scene sceneID="dkD-v9-Eaz">
15+
<objects>
16+
<navigationController id="xNF-HH-Cif" sceneMemberID="viewController">
17+
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="74C-eu-rpG">
18+
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
19+
<autoresizingMask key="autoresizingMask"/>
20+
</navigationBar>
21+
<connections>
22+
<segue destination="osO-Rp-nHh" kind="relationship" relationship="rootViewController" id="SAd-fI-NMZ"/>
23+
</connections>
24+
</navigationController>
25+
<placeholder placeholderIdentifier="IBFirstResponder" id="wPL-nu-ol2" userLabel="First Responder" sceneMemberID="firstResponder"/>
26+
</objects>
27+
<point key="canvasLocation" x="204" y="215"/>
28+
</scene>
29+
<!--Examples-->
30+
<scene sceneID="P7f-0q-N7w">
31+
<objects>
32+
<viewController title="Examples" id="osO-Rp-nHh" customClass="ViewController" customModule="Examples" customModuleProvider="target" sceneMemberID="viewController">
33+
<view key="view" contentMode="scaleToFill" id="83i-eb-xa2">
34+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
35+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
36+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
37+
<viewLayoutGuide key="safeArea" id="spO-UG-XJt"/>
38+
</view>
39+
<navigationItem key="navigationItem" title="Examples" id="caB-xi-W4W"/>
40+
</viewController>
41+
<placeholder placeholderIdentifier="IBFirstResponder" id="DaE-zY-KU2" userLabel="First Responder" sceneMemberID="firstResponder"/>
42+
</objects>
43+
<point key="canvasLocation" x="1006" y="215"/>
44+
</scene>
45+
</scenes>
46+
</document>

Examples/Examples/Info.plist

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>APPL</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleVersion</key>
20+
<string>1</string>
21+
<key>LSRequiresIPhoneOS</key>
22+
<true/>
23+
<key>UILaunchStoryboardName</key>
24+
<string>LaunchScreen</string>
25+
<key>UIMainStoryboardFile</key>
26+
<string>Main</string>
27+
<key>UIRequiredDeviceCapabilities</key>
28+
<array>
29+
<string>armv7</string>
30+
</array>
31+
<key>UISupportedInterfaceOrientations</key>
32+
<array>
33+
<string>UIInterfaceOrientationPortrait</string>
34+
<string>UIInterfaceOrientationLandscapeLeft</string>
35+
<string>UIInterfaceOrientationLandscapeRight</string>
36+
</array>
37+
<key>UISupportedInterfaceOrientations~ipad</key>
38+
<array>
39+
<string>UIInterfaceOrientationPortrait</string>
40+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
41+
<string>UIInterfaceOrientationLandscapeLeft</string>
42+
<string>UIInterfaceOrientationLandscapeRight</string>
43+
</array>
44+
</dict>
45+
</plist>
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
//
2+
// ViewController.swift
3+
// Examples
4+
//
5+
// Created by Ryan Nystrom on 1/28/18.
6+
// Copyright © 2018 Ryan Nystrom. All rights reserved.
7+
//
8+
9+
import UIKit
10+
import MessageViewController
11+
12+
class ViewController: MessageViewController, UITableViewDataSource, UITableViewDelegate, MessageAutocompleteControllerDelegate {
13+
14+
var data = "Lorem ipsum dolor sit amet|consectetur adipiscing elit|sed do eiusmod|tempor incididunt|ut labore et dolore|magna aliqua| Ut enim ad minim|veniam, quis nostrud|exercitation ullamco|laboris nisi ut aliquip|ex ea commodo consequat|Duis aute|irure dolor in reprehenderit|in voluptate|velit esse cillum|dolore eu|fugiat nulla pariatur|Excepteur sint occaecat|cupidatat non proident|sunt in culpa|qui officia|deserunt|mollit anim id est laborum"
15+
.components(separatedBy: "|")
16+
let users = ["rnystrom", "BasThomas", "jessesquires", "Sherlouk"]
17+
var autocompleteUsers = [String]()
18+
let tableView = UITableView()
19+
20+
override func viewDidLoad() {
21+
super.viewDidLoad()
22+
tableView.dataSource = self
23+
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
24+
view.addSubview(tableView)
25+
26+
borderColor = .lightGray
27+
28+
messageView.inset = UIEdgeInsets(top: 8, left: 16, bottom: 8, right: 16)
29+
messageView.textView.placeholderText = "New message..."
30+
messageView.textView.placeholderTextColor = .lightGray
31+
messageView.font = UIFont.systemFont(ofSize: 17)
32+
33+
messageView.set(buttonTitle: "Send", for: .normal)
34+
messageView.addButton(target: self, action: #selector(onButton))
35+
messageView.buttonTint = .blue
36+
37+
messageAutocompleteController.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
38+
messageAutocompleteController.tableView.dataSource = self
39+
messageAutocompleteController.tableView.delegate = self
40+
messageAutocompleteController.register(prefix: "@")
41+
messageAutocompleteController.delegate = self
42+
43+
setup(scrollView: tableView)
44+
}
45+
46+
@objc func onButton() {
47+
data.append(messageView.text)
48+
messageView.text = ""
49+
tableView.reloadData()
50+
tableView.scrollToRow(
51+
at: IndexPath(row: data.count - 1, section: 0),
52+
at: .bottom,
53+
animated: true
54+
)
55+
}
56+
57+
// MARK: UITableViewDataSource
58+
59+
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
60+
return tableView === self.tableView
61+
? data.count
62+
: autocompleteUsers.count
63+
}
64+
65+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
66+
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
67+
if tableView === self.tableView {
68+
cell.textLabel?.text = data[indexPath.row]
69+
} else {
70+
cell.textLabel?.text = autocompleteUsers[indexPath.row]
71+
}
72+
return cell
73+
}
74+
75+
// MARK: UITableViewDelegate
76+
77+
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
78+
tableView.deselectRow(at: indexPath, animated: true)
79+
if tableView === messageAutocompleteController.tableView {
80+
messageAutocompleteController.accept(autocomplete: autocompleteUsers[indexPath.row])
81+
}
82+
}
83+
84+
// MARK: MessageAutocompleteControllerDelegate
85+
86+
func didFind(controller: MessageAutocompleteController, prefix: String, word: String) {
87+
autocompleteUsers = users.filter { word.isEmpty || $0.lowercased().contains(word.lowercased()) }
88+
controller.show(true)
89+
}
90+
91+
}
92+

Examples/Podfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
use_frameworks!
2+
platform :ios, '11.0'
3+
4+
target 'Examples' do
5+
pod 'MessageViewController', :path => '../MessageViewController.podspec'
6+
end

Examples/Podfile.lock

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
PODS:
2+
- MessageViewController (0.1.1)
3+
4+
DEPENDENCIES:
5+
- MessageViewController (from `../MessageViewController.podspec`)
6+
7+
EXTERNAL SOURCES:
8+
MessageViewController:
9+
:path: ../MessageViewController.podspec
10+
11+
SPEC CHECKSUMS:
12+
MessageViewController: 619f0c8253f4eb36f69c906d5a38592de857a433
13+
14+
PODFILE CHECKSUM: 74208e93c3daf191e681c80fcdf956f1603f9016
15+
16+
COCOAPODS: 1.4.0.rc.1

0 commit comments

Comments
 (0)