Skip to content

Commit d22741e

Browse files
authored
Merge pull request #34 from ra1028/v0.6.0
v0.6.0
2 parents 99a40fa + 913f97e commit d22741e

30 files changed

+391
-222
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ build/
2121
## Documentation
2222
docs/docsets/
2323
docs/undocumented.json
24+
25+
## Gems
26+
.bundle
27+
vendor/bundle

.jazzy.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ author_url: https://github.com/ra1028
33
github_url: https://github.com/ra1028/DifferenceKit
44
module: DifferenceKit
55
readme: README.md
6+
exclude: Sources/Extensions/AppKitExtension.swift
67
output: docs
78
theme: apple
89
clean: true
910
skip_undocumented: true
10-
xcodebuild_arguments: [-workspace, 'DifferenceKit.xcworkspace', -scheme, 'DifferenceKit', -sdk, 'iphonesimulator']
11+
xcodebuild_arguments:
12+
- -sdk
13+
- iphonesimulator

.travis.yml

+6
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,11 @@ matrix:
1212
- xcodebuild build-for-testing test-without-building -scheme DifferenceKit -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 8' ENABLE_TESTABILITY=YES | xcpretty - c
1313
- xcodebuild build-for-testing test-without-building -scheme DifferenceKit -configuration Release -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV' ENABLE_TESTABILITY=YES | xcpretty -c
1414
- xcodebuild build -scheme DifferenceKit -configuration Release -sdk watchsimulator -destination 'platform=watchOS Simulator,name=Apple Watch - 38mm' ENABLE_TESTABILITY=YES | xcpretty -c
15+
- os: osx
16+
language: objective-c
17+
osx_image: xcode9.4
18+
script:
19+
- xcodebuild build -scheme DifferenceKit -configuration Release ENABLE_TESTABILITY=YES | xcpretty -c
20+
- xcodebuild build -scheme DifferenceKit -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 8' | xcpretty -c
1521
notifications:
1622
email: false

DifferenceKit.podspec

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |spec|
22
spec.name = 'DifferenceKit'
3-
spec.version = '0.5.3'
3+
spec.version = '0.6.0'
44
spec.author = { 'ra1028' => '[email protected]' }
55
spec.homepage = 'https://github.com/ra1028/DifferenceKit'
66
spec.documentation_url = 'https://ra1028.github.io/DifferenceKit'
@@ -12,7 +12,7 @@ Pod::Spec.new do |spec|
1212
spec.source = { :git => 'https://github.com/ra1028/DifferenceKit.git', :tag => spec.version.to_s }
1313
spec.license = { :type => 'MIT', :file => 'LICENSE' }
1414
spec.requires_arc = true
15-
spec.default_subspecs = 'Core', 'UIExtensions'
15+
spec.default_subspecs = 'Core', 'UIKitExtension'
1616

1717
spec.ios.deployment_target = '9.0'
1818
spec.tvos.deployment_target = '9.0'
@@ -23,10 +23,10 @@ Pod::Spec.new do |spec|
2323
subspec.source_files = 'Sources/*.swift'
2424
end
2525

26-
spec.subspec 'UIExtensions' do |subspec|
26+
spec.subspec 'UIKitExtension' do |subspec|
2727
subspec.dependency 'DifferenceKit/Core'
2828

29-
source_files = 'Sources/UIExtensions/*.swift'
29+
source_files = 'Sources/Extensions/UIKitExtension.swift'
3030
frameworks = 'UIKit'
3131

3232
subspec.ios.source_files = source_files
@@ -35,4 +35,11 @@ Pod::Spec.new do |spec|
3535
subspec.ios.frameworks = frameworks
3636
subspec.tvos.frameworks = frameworks
3737
end
38+
39+
spec.subspec 'AppKitExtension' do |subspec|
40+
subspec.dependency 'DifferenceKit/Core'
41+
42+
subspec.osx.source_files = 'Sources/Extensions/AppKitExtension.swift'
43+
subspec.osx.frameworks = 'AppKit'
44+
end
3845
end

Examples/Example-macOS/Example-macOS.xcodeproj/project.pbxproj

+12-10
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
6BE7D4F5215225A600D2F8E9 /* String+Differentiable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6BE7D4F4215225A600D2F8E9 /* String+Differentiable.swift */; };
1011
750C1E6E21515AF800034704 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750C1E6D21515AF800034704 /* AppDelegate.swift */; };
1112
750C1E7021515AFB00034704 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 750C1E6F21515AFB00034704 /* Assets.xcassets */; };
1213
750C1E7321515AFB00034704 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 750C1E7121515AFB00034704 /* MainMenu.xib */; };
13-
750C1E7C21515BCC00034704 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750C1E7B21515BCC00034704 /* ViewController.swift */; };
14-
750C1E7E21515BE900034704 /* StringCollectionViewItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750C1E7D21515BE900034704 /* StringCollectionViewItem.swift */; };
14+
750C1E7C21515BCC00034704 /* ShuffleEmoticonViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750C1E7B21515BCC00034704 /* ShuffleEmoticonViewController.swift */; };
1515
7541B1E3215173F400769EEC /* DifferenceKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7541B1E0215173EA00769EEC /* DifferenceKit.framework */; };
1616
7541B1E4215173F400769EEC /* DifferenceKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 7541B1E0215173EA00769EEC /* DifferenceKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
1717
/* End PBXBuildFile section */
@@ -55,13 +55,13 @@
5555
/* End PBXCopyFilesBuildPhase section */
5656

5757
/* Begin PBXFileReference section */
58+
6BE7D4F4215225A600D2F8E9 /* String+Differentiable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Differentiable.swift"; sourceTree = "<group>"; };
5859
750C1E6A21515AF800034704 /* Example-macOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Example-macOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
5960
750C1E6D21515AF800034704 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
6061
750C1E6F21515AFB00034704 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
6162
750C1E7221515AFB00034704 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
6263
750C1E7421515AFB00034704 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
63-
750C1E7B21515BCC00034704 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
64-
750C1E7D21515BE900034704 /* StringCollectionViewItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringCollectionViewItem.swift; sourceTree = "<group>"; };
64+
750C1E7B21515BCC00034704 /* ShuffleEmoticonViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShuffleEmoticonViewController.swift; sourceTree = "<group>"; };
6565
7541B1DA215173EA00769EEC /* DifferenceKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = DifferenceKit.xcodeproj; path = ../../DifferenceKit.xcodeproj; sourceTree = "<group>"; };
6666
/* End PBXFileReference section */
6767

@@ -98,8 +98,8 @@
9898
isa = PBXGroup;
9999
children = (
100100
750C1E6D21515AF800034704 /* AppDelegate.swift */,
101-
750C1E7B21515BCC00034704 /* ViewController.swift */,
102-
750C1E7D21515BE900034704 /* StringCollectionViewItem.swift */,
101+
750C1E7B21515BCC00034704 /* ShuffleEmoticonViewController.swift */,
102+
6BE7D4F4215225A600D2F8E9 /* String+Differentiable.swift */,
103103
750C1E6F21515AFB00034704 /* Assets.xcassets */,
104104
750C1E7121515AFB00034704 /* MainMenu.xib */,
105105
750C1E7421515AFB00034704 /* Info.plist */,
@@ -210,9 +210,9 @@
210210
isa = PBXSourcesBuildPhase;
211211
buildActionMask = 2147483647;
212212
files = (
213-
750C1E7C21515BCC00034704 /* ViewController.swift in Sources */,
213+
6BE7D4F5215225A600D2F8E9 /* String+Differentiable.swift in Sources */,
214+
750C1E7C21515BCC00034704 /* ShuffleEmoticonViewController.swift in Sources */,
214215
750C1E6E21515AF800034704 /* AppDelegate.swift in Sources */,
215-
750C1E7E21515BE900034704 /* StringCollectionViewItem.swift in Sources */,
216216
);
217217
runOnlyForDeploymentPostprocessing = 0;
218218
};
@@ -289,7 +289,7 @@
289289
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
290290
GCC_WARN_UNUSED_FUNCTION = YES;
291291
GCC_WARN_UNUSED_VARIABLE = YES;
292-
MACOSX_DEPLOYMENT_TARGET = 10.14;
292+
MACOSX_DEPLOYMENT_TARGET = 10.13;
293293
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
294294
MTL_FAST_MATH = YES;
295295
ONLY_ACTIVE_ARCH = YES;
@@ -344,7 +344,7 @@
344344
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
345345
GCC_WARN_UNUSED_FUNCTION = YES;
346346
GCC_WARN_UNUSED_VARIABLE = YES;
347-
MACOSX_DEPLOYMENT_TARGET = 10.14;
347+
MACOSX_DEPLOYMENT_TARGET = 10.13;
348348
MTL_ENABLE_DEBUG_INFO = NO;
349349
MTL_FAST_MATH = YES;
350350
SDKROOT = macosx;
@@ -368,6 +368,7 @@
368368
"$(inherited)",
369369
"@executable_path/../Frameworks",
370370
);
371+
MACOSX_DEPLOYMENT_TARGET = 10.13;
371372
PRODUCT_BUNDLE_IDENTIFIER = "org.cindori.Example-macOS";
372373
PRODUCT_NAME = "$(TARGET_NAME)";
373374
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -390,6 +391,7 @@
390391
"$(inherited)",
391392
"@executable_path/../Frameworks",
392393
);
394+
MACOSX_DEPLOYMENT_TARGET = 10.13;
393395
PRODUCT_BUNDLE_IDENTIFIER = "org.cindori.Example-macOS";
394396
PRODUCT_NAME = "$(TARGET_NAME)";
395397
PROVISIONING_PROFILE_SPECIFIER = "";
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
import Cocoa
22

33
@NSApplicationMain
4-
class AppDelegate: NSObject, NSApplicationDelegate {
5-
4+
final class AppDelegate: NSObject, NSApplicationDelegate {
65
@IBOutlet weak var window: NSWindow!
7-
8-
func applicationDidFinishLaunching(_ aNotification: Notification) {
9-
// Insert code here to initialize your application
10-
}
11-
12-
func applicationWillTerminate(_ aNotification: Notification) {
13-
// Insert code here to tear down your application
14-
}
15-
166
}

Examples/Example-macOS/Sources/Base.lproj/MainMenu.xib

+7-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</connections>
1919
</customObject>
2020
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
21-
<customObject id="Fby-Dz-qwF" customClass="ViewController" customModule="Example_macOS" customModuleProvider="target">
21+
<customObject id="Fby-Dz-qwF" customClass="ShuffleEmoticonViewController" customModule="Example_macOS" customModuleProvider="target">
2222
<connections>
2323
<outlet property="collectionView" destination="vZL-9p-qx9" id="l8Q-kq-Jo5"/>
2424
<outlet property="tableView" destination="6us-eS-zhT" id="WEV-2r-CDO"/>
@@ -716,7 +716,7 @@
716716
<subviews>
717717
<scrollView wantsLayer="YES" borderType="none" autohidesScrollers="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LAr-ro-6kM">
718718
<rect key="frame" x="0.0" y="0.0" width="346" height="387"/>
719-
<clipView key="contentView" id="2Pj-dT-iJ0">
719+
<clipView key="contentView" drawsBackground="NO" id="2Pj-dT-iJ0">
720720
<rect key="frame" x="0.0" y="0.0" width="346" height="387"/>
721721
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
722722
<subviews>
@@ -735,11 +735,11 @@
735735
</collectionView>
736736
</subviews>
737737
</clipView>
738-
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="Es9-pa-vVM">
738+
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="Es9-pa-vVM">
739739
<rect key="frame" x="0.0" y="371" width="346" height="16"/>
740740
<autoresizingMask key="autoresizingMask"/>
741741
</scroller>
742-
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="wbg-vO-Hg8">
742+
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="wbg-vO-Hg8">
743743
<rect key="frame" x="234" y="1" width="15" height="143"/>
744744
<autoresizingMask key="autoresizingMask"/>
745745
</scroller>
@@ -782,7 +782,7 @@
782782
</textFieldCell>
783783
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
784784
<prototypeCellViews>
785-
<tableCellView identifier="StringCell" id="Dbv-wD-9Jq">
785+
<tableCellView identifier="NSTableCellView" id="Dbv-wD-9Jq">
786786
<rect key="frame" x="1" y="1" width="344" height="33"/>
787787
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
788788
<subviews>
@@ -814,11 +814,11 @@
814814
</tableView>
815815
</subviews>
816816
</clipView>
817-
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="iZO-4w-Q1u">
817+
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="iZO-4w-Q1u">
818818
<rect key="frame" x="0.0" y="371" width="344" height="16"/>
819819
<autoresizingMask key="autoresizingMask"/>
820820
</scroller>
821-
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="uRZ-s5-org">
821+
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="uRZ-s5-org">
822822
<rect key="frame" x="224" y="17" width="15" height="102"/>
823823
<autoresizingMask key="autoresizingMask"/>
824824
</scroller>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import Cocoa
2+
import DifferenceKit
3+
4+
final class ShuffleEmoticonViewController: NSViewController {
5+
@IBOutlet private weak var collectionView: NSCollectionView!
6+
@IBOutlet private weak var tableView: NSTableView!
7+
8+
private var data = (0x1F600...0x1F647).compactMap { UnicodeScalar($0).map(String.init) }
9+
private var dataInput: [String] {
10+
get { return data }
11+
set {
12+
let changeset = StagedChangeset(source: data, target: newValue)
13+
collectionView.reload(using: changeset) { data in
14+
self.data = data
15+
}
16+
tableView.reload(using: changeset, with: .effectFade) { data in
17+
self.data = data
18+
}
19+
}
20+
}
21+
22+
@IBAction func shufflePress(_ button: NSButton) {
23+
dataInput.shuffle()
24+
}
25+
26+
override func awakeFromNib() {
27+
super.awakeFromNib()
28+
29+
collectionView.register(EmoticonCollectionViewItem.self, forItemWithIdentifier: EmoticonCollectionViewItem.itemIdentifier)
30+
}
31+
}
32+
33+
extension ShuffleEmoticonViewController: NSCollectionViewDataSource {
34+
func numberOfSections(in collectionView: NSCollectionView) -> Int {
35+
return 1
36+
}
37+
38+
func collectionView(_ collectionView: NSCollectionView, numberOfItemsInSection section: Int) -> Int {
39+
return data.count
40+
}
41+
42+
func collectionView(_ collectionView: NSCollectionView, itemForRepresentedObjectAt indexPath: IndexPath) -> NSCollectionViewItem {
43+
let item = collectionView.makeItem(withIdentifier: EmoticonCollectionViewItem.itemIdentifier, for: indexPath) as! EmoticonCollectionViewItem
44+
item.emoticon = data[indexPath.item]
45+
return item
46+
}
47+
}
48+
49+
extension ShuffleEmoticonViewController: NSTableViewDataSource, NSTableViewDelegate {
50+
func numberOfRows(in tableView: NSTableView) -> Int {
51+
return data.count
52+
}
53+
54+
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
55+
let view = tableView.makeView(withIdentifier: NSTableCellView.itemIdentifier, owner: tableView) as! NSTableCellView
56+
view.textField?.stringValue = data[row]
57+
return view
58+
}
59+
}
60+
61+
private extension NSTableCellView {
62+
static var itemIdentifier: NSUserInterfaceItemIdentifier {
63+
return NSUserInterfaceItemIdentifier(String(describing: self))
64+
}
65+
}
66+
67+
private final class EmoticonCollectionViewItem: NSCollectionViewItem {
68+
static var itemIdentifier: NSUserInterfaceItemIdentifier {
69+
return NSUserInterfaceItemIdentifier(String(describing: self))
70+
}
71+
72+
var emoticon: String {
73+
get { return _textField.stringValue }
74+
set { _textField.stringValue = newValue }
75+
}
76+
77+
private let _textField = NSTextField()
78+
79+
override func loadView() {
80+
view = NSView(frame: NSRect(x: 0, y: 0, width: 60, height: 54))
81+
}
82+
83+
override func viewDidLoad() {
84+
super.viewDidLoad()
85+
_textField.font = .systemFont(ofSize: 40)
86+
_textField.alignment = .center
87+
_textField.isEditable = false
88+
89+
_textField.translatesAutoresizingMaskIntoConstraints = false
90+
view.addSubview(_textField)
91+
92+
let constraints = [
93+
_textField.topAnchor.constraint(equalTo: view.topAnchor),
94+
_textField.bottomAnchor.constraint(equalTo: view.bottomAnchor),
95+
_textField.leadingAnchor.constraint(equalTo: view.leadingAnchor),
96+
_textField.trailingAnchor.constraint(equalTo: view.trailingAnchor)
97+
]
98+
NSLayoutConstraint.activate(constraints)
99+
}
100+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import DifferenceKit
2+
3+
extension String: Differentiable { }

Examples/Example-macOS/Sources/StringCollectionViewItem.swift

-25
This file was deleted.

0 commit comments

Comments
 (0)