Skip to content

Commit 347d29d

Browse files
committed
Add App Extension example
1 parent 904357c commit 347d29d

File tree

7 files changed

+320
-6
lines changed

7 files changed

+320
-6
lines changed

Example/Podfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ target 'RxKeyboardExample' do
1212
pod 'SwiftyColor'
1313
pod 'SwiftyImage'
1414
pod 'CGFloatLiteral'
15+
16+
target 'RxKeyboardShareExtension'
1517
end

Example/Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ PODS:
44
- ReusableKit (1.1.0)
55
- RxCocoa (3.1.0):
66
- RxSwift (~> 3.1)
7-
- RxKeyboard (0.4.0):
7+
- RxKeyboard (0.4.1):
88
- RxCocoa (>= 3.0)
99
- RxSwift (>= 3.0)
1010
- RxSwift (3.1.0)
@@ -34,14 +34,14 @@ SPEC CHECKSUMS:
3434
ManualLayout: 68ac8cfa6b5f656f7a9fadec3730208b95986880
3535
ReusableKit: 89e743a120bab0d95848bff27e481833c2768905
3636
RxCocoa: 50d7564866da9299161e86a263ce12a0873904d8
37-
RxKeyboard: cf7f4463f27e580a3542127877ef9e3a71183744
37+
RxKeyboard: 6bd1a1e1e199d869699ed8da2307b474137ec28f
3838
RxSwift: 83ff553e7593fdfdcb2562933a64c0284dffdadc
3939
SnapKit: 12b24f569cb7c143acc9c22b9d91b23e7b1c84a2
4040
SwiftyColor: 7fa09db14051bc5d7f539e1c4576665975225992
4141
SwiftyImage: 79090f8b96057b3e91064de172936b97855086e6
4242
Then: 8496793c8fcac95482b943909b440724c7d8d82c
4343
UITextView+Placeholder: 77680995fcdd07c3f52ec92fe1150874a2ac89ff
4444

45-
PODFILE CHECKSUM: 49cf5def62bcfa2dfbe0c5118a9372a4162ec992
45+
PODFILE CHECKSUM: 586f03c5a1d10260c3fad008f55a493a57b525a5
4646

47-
COCOAPODS: 1.1.1
47+
COCOAPODS: 1.2.1

Example/RxKeyboardExample.xcodeproj/project.pbxproj

Lines changed: 197 additions & 2 deletions
Large diffs are not rendered by default.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="j1y-V4-xli">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
5+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
6+
</dependencies>
7+
<scenes>
8+
<!--Share View Controller-->
9+
<scene sceneID="ceB-am-kn3">
10+
<objects>
11+
<viewController id="j1y-V4-xli" customClass="ShareViewController" customModuleProvider="target" sceneMemberID="viewController">
12+
<layoutGuides>
13+
<viewControllerLayoutGuide type="top" id="8bI-gs-bmD"/>
14+
<viewControllerLayoutGuide type="bottom" id="d5i-Ba-RvD"/>
15+
</layoutGuides>
16+
<view key="view" opaque="NO" contentMode="scaleToFill" id="wbc-yd-nQP">
17+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
18+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
19+
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
20+
</view>
21+
</viewController>
22+
<placeholder placeholderIdentifier="IBFirstResponder" id="CEy-Cv-SGf" userLabel="First Responder" sceneMemberID="firstResponder"/>
23+
</objects>
24+
</scene>
25+
</scenes>
26+
</document>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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>en</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>RxKeyboardShareExtension</string>
9+
<key>CFBundleExecutable</key>
10+
<string>$(EXECUTABLE_NAME)</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>$(PRODUCT_NAME)</string>
17+
<key>CFBundlePackageType</key>
18+
<string>XPC!</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>1.0</string>
21+
<key>CFBundleVersion</key>
22+
<string>1</string>
23+
<key>NSExtension</key>
24+
<dict>
25+
<key>NSExtensionAttributes</key>
26+
<dict>
27+
<key>NSExtensionActivationRule</key>
28+
<string>TRUEPREDICATE</string>
29+
</dict>
30+
<key>NSExtensionMainStoryboard</key>
31+
<string>MainInterface</string>
32+
<key>NSExtensionPointIdentifier</key>
33+
<string>com.apple.share-services</string>
34+
</dict>
35+
</dict>
36+
</plist>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//
2+
// ShareViewController.swift
3+
// RxKeyboardShareExtension
4+
//
5+
// Created by Suyeol Jeon on 04/05/2017.
6+
// Copyright © 2017 Suyeol Jeon. All rights reserved.
7+
//
8+
9+
import UIKit
10+
import Social
11+
import RxKeyboard
12+
import RxSwift
13+
import SnapKit
14+
15+
class ShareViewController: UIViewController {
16+
let disposeBag = DisposeBag()
17+
let textView = UITextView()
18+
let toolbar = UIToolbar()
19+
20+
override func viewDidLoad() {
21+
super.viewDidLoad()
22+
self.textView.font = UIFont.systemFont(ofSize: 50)
23+
self.textView.text = (0...100).map { "\($0)" }.joined(separator: "\n")
24+
self.textView.keyboardDismissMode = .interactive
25+
self.view.addSubview(self.textView)
26+
self.view.addSubview(self.toolbar)
27+
28+
self.textView.snp.makeConstraints { make in
29+
make.edges.equalToSuperview()
30+
}
31+
self.toolbar.snp.makeConstraints { make in
32+
make.left.right.equalToSuperview()
33+
make.bottom.equalToSuperview()
34+
}
35+
36+
// Set `gestureValue` for using interactive keyboard tracking
37+
RxKeyboard.instance.gestureView = self.view
38+
RxKeyboard.instance.visibleHeight
39+
.drive(onNext: { [weak self] visibleHeight in
40+
guard let `self` = self else { return }
41+
self.toolbar.snp.updateConstraints { make in
42+
make.bottom.equalTo(-visibleHeight)
43+
}
44+
self.view.setNeedsLayout()
45+
UIView.animate(withDuration: 0) {
46+
self.textView.contentInset.bottom = visibleHeight + self.toolbar.frame.height
47+
self.textView.scrollIndicatorInsets.bottom = self.textView.contentInset.bottom
48+
self.view.layoutIfNeeded()
49+
}
50+
})
51+
.addDisposableTo(self.disposeBag)
52+
}
53+
}

RxKeyboard.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@
277277
03A258D41DA94EC50035A85B /* Debug */ = {
278278
isa = XCBuildConfiguration;
279279
buildSettings = {
280+
APPLICATION_EXTENSION_API_ONLY = NO;
280281
CLANG_ENABLE_MODULES = YES;
281282
CODE_SIGN_IDENTITY = "";
282283
DEFINES_MODULE = YES;
@@ -302,6 +303,7 @@
302303
03A258D51DA94EC50035A85B /* Release */ = {
303304
isa = XCBuildConfiguration;
304305
buildSettings = {
306+
APPLICATION_EXTENSION_API_ONLY = NO;
305307
CLANG_ENABLE_MODULES = YES;
306308
CODE_SIGN_IDENTITY = "";
307309
DEFINES_MODULE = YES;

0 commit comments

Comments
 (0)