Skip to content

Commit

Permalink
Merge pull request #34 from ra1028/v0.6.0
Browse files Browse the repository at this point in the history
v0.6.0
  • Loading branch information
ra1028 authored Sep 19, 2018
2 parents 99a40fa + 913f97e commit d22741e
Show file tree
Hide file tree
Showing 30 changed files with 391 additions and 222 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ build/
## Documentation
docs/docsets/
docs/undocumented.json

## Gems
.bundle
vendor/bundle
5 changes: 4 additions & 1 deletion .jazzy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ author_url: https://github.com/ra1028
github_url: https://github.com/ra1028/DifferenceKit
module: DifferenceKit
readme: README.md
exclude: Sources/Extensions/AppKitExtension.swift
output: docs
theme: apple
clean: true
skip_undocumented: true
xcodebuild_arguments: [-workspace, 'DifferenceKit.xcworkspace', -scheme, 'DifferenceKit', -sdk, 'iphonesimulator']
xcodebuild_arguments:
- -sdk
- iphonesimulator
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,11 @@ matrix:
- 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
- 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
- xcodebuild build -scheme DifferenceKit -configuration Release -sdk watchsimulator -destination 'platform=watchOS Simulator,name=Apple Watch - 38mm' ENABLE_TESTABILITY=YES | xcpretty -c
- os: osx
language: objective-c
osx_image: xcode9.4
script:
- xcodebuild build -scheme DifferenceKit -configuration Release ENABLE_TESTABILITY=YES | xcpretty -c
- xcodebuild build -scheme DifferenceKit -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 8' | xcpretty -c
notifications:
email: false
15 changes: 11 additions & 4 deletions DifferenceKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'DifferenceKit'
spec.version = '0.5.3'
spec.version = '0.6.0'
spec.author = { 'ra1028' => 'r.fe51028.r@gmail.com' }
spec.homepage = 'https://github.com/ra1028/DifferenceKit'
spec.documentation_url = 'https://ra1028.github.io/DifferenceKit'
Expand All @@ -12,7 +12,7 @@ Pod::Spec.new do |spec|
spec.source = { :git => 'https://github.com/ra1028/DifferenceKit.git', :tag => spec.version.to_s }
spec.license = { :type => 'MIT', :file => 'LICENSE' }
spec.requires_arc = true
spec.default_subspecs = 'Core', 'UIExtensions'
spec.default_subspecs = 'Core', 'UIKitExtension'

spec.ios.deployment_target = '9.0'
spec.tvos.deployment_target = '9.0'
Expand All @@ -23,10 +23,10 @@ Pod::Spec.new do |spec|
subspec.source_files = 'Sources/*.swift'
end

spec.subspec 'UIExtensions' do |subspec|
spec.subspec 'UIKitExtension' do |subspec|
subspec.dependency 'DifferenceKit/Core'

source_files = 'Sources/UIExtensions/*.swift'
source_files = 'Sources/Extensions/UIKitExtension.swift'
frameworks = 'UIKit'

subspec.ios.source_files = source_files
Expand All @@ -35,4 +35,11 @@ Pod::Spec.new do |spec|
subspec.ios.frameworks = frameworks
subspec.tvos.frameworks = frameworks
end

spec.subspec 'AppKitExtension' do |subspec|
subspec.dependency 'DifferenceKit/Core'

subspec.osx.source_files = 'Sources/Extensions/AppKitExtension.swift'
subspec.osx.frameworks = 'AppKit'
end
end
22 changes: 12 additions & 10 deletions Examples/Example-macOS/Example-macOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
objects = {

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

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

Expand Down Expand Up @@ -98,8 +98,8 @@
isa = PBXGroup;
children = (
750C1E6D21515AF800034704 /* AppDelegate.swift */,
750C1E7B21515BCC00034704 /* ViewController.swift */,
750C1E7D21515BE900034704 /* StringCollectionViewItem.swift */,
750C1E7B21515BCC00034704 /* ShuffleEmoticonViewController.swift */,
6BE7D4F4215225A600D2F8E9 /* String+Differentiable.swift */,
750C1E6F21515AFB00034704 /* Assets.xcassets */,
750C1E7121515AFB00034704 /* MainMenu.xib */,
750C1E7421515AFB00034704 /* Info.plist */,
Expand Down Expand Up @@ -210,9 +210,9 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
750C1E7C21515BCC00034704 /* ViewController.swift in Sources */,
6BE7D4F5215225A600D2F8E9 /* String+Differentiable.swift in Sources */,
750C1E7C21515BCC00034704 /* ShuffleEmoticonViewController.swift in Sources */,
750C1E6E21515AF800034704 /* AppDelegate.swift in Sources */,
750C1E7E21515BE900034704 /* StringCollectionViewItem.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -289,7 +289,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -344,7 +344,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
Expand All @@ -368,6 +368,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.13;
PRODUCT_BUNDLE_IDENTIFIER = "org.cindori.Example-macOS";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -390,6 +391,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.13;
PRODUCT_BUNDLE_IDENTIFIER = "org.cindori.Example-macOS";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
12 changes: 1 addition & 11 deletions Examples/Example-macOS/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import Cocoa

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

final class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var window: NSWindow!

func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
}

func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}

}
14 changes: 7 additions & 7 deletions Examples/Example-macOS/Sources/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</connections>
</customObject>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<customObject id="Fby-Dz-qwF" customClass="ViewController" customModule="Example_macOS" customModuleProvider="target">
<customObject id="Fby-Dz-qwF" customClass="ShuffleEmoticonViewController" customModule="Example_macOS" customModuleProvider="target">
<connections>
<outlet property="collectionView" destination="vZL-9p-qx9" id="l8Q-kq-Jo5"/>
<outlet property="tableView" destination="6us-eS-zhT" id="WEV-2r-CDO"/>
Expand Down Expand Up @@ -716,7 +716,7 @@
<subviews>
<scrollView wantsLayer="YES" borderType="none" autohidesScrollers="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LAr-ro-6kM">
<rect key="frame" x="0.0" y="0.0" width="346" height="387"/>
<clipView key="contentView" id="2Pj-dT-iJ0">
<clipView key="contentView" drawsBackground="NO" id="2Pj-dT-iJ0">
<rect key="frame" x="0.0" y="0.0" width="346" height="387"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
Expand All @@ -735,11 +735,11 @@
</collectionView>
</subviews>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="Es9-pa-vVM">
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="Es9-pa-vVM">
<rect key="frame" x="0.0" y="371" width="346" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="wbg-vO-Hg8">
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="wbg-vO-Hg8">
<rect key="frame" x="234" y="1" width="15" height="143"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
Expand Down Expand Up @@ -782,7 +782,7 @@
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView identifier="StringCell" id="Dbv-wD-9Jq">
<tableCellView identifier="NSTableCellView" id="Dbv-wD-9Jq">
<rect key="frame" x="1" y="1" width="344" height="33"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
Expand Down Expand Up @@ -814,11 +814,11 @@
</tableView>
</subviews>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="iZO-4w-Q1u">
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="iZO-4w-Q1u">
<rect key="frame" x="0.0" y="371" width="344" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="uRZ-s5-org">
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="uRZ-s5-org">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
Expand Down
100 changes: 100 additions & 0 deletions Examples/Example-macOS/Sources/ShuffleEmoticonViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import Cocoa
import DifferenceKit

final class ShuffleEmoticonViewController: NSViewController {
@IBOutlet private weak var collectionView: NSCollectionView!
@IBOutlet private weak var tableView: NSTableView!

private var data = (0x1F600...0x1F647).compactMap { UnicodeScalar($0).map(String.init) }
private var dataInput: [String] {
get { return data }
set {
let changeset = StagedChangeset(source: data, target: newValue)
collectionView.reload(using: changeset) { data in
self.data = data
}
tableView.reload(using: changeset, with: .effectFade) { data in
self.data = data
}
}
}

@IBAction func shufflePress(_ button: NSButton) {
dataInput.shuffle()
}

override func awakeFromNib() {
super.awakeFromNib()

collectionView.register(EmoticonCollectionViewItem.self, forItemWithIdentifier: EmoticonCollectionViewItem.itemIdentifier)
}
}

extension ShuffleEmoticonViewController: NSCollectionViewDataSource {
func numberOfSections(in collectionView: NSCollectionView) -> Int {
return 1
}

func collectionView(_ collectionView: NSCollectionView, numberOfItemsInSection section: Int) -> Int {
return data.count
}

func collectionView(_ collectionView: NSCollectionView, itemForRepresentedObjectAt indexPath: IndexPath) -> NSCollectionViewItem {
let item = collectionView.makeItem(withIdentifier: EmoticonCollectionViewItem.itemIdentifier, for: indexPath) as! EmoticonCollectionViewItem
item.emoticon = data[indexPath.item]
return item
}
}

extension ShuffleEmoticonViewController: NSTableViewDataSource, NSTableViewDelegate {
func numberOfRows(in tableView: NSTableView) -> Int {
return data.count
}

func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
let view = tableView.makeView(withIdentifier: NSTableCellView.itemIdentifier, owner: tableView) as! NSTableCellView
view.textField?.stringValue = data[row]
return view
}
}

private extension NSTableCellView {
static var itemIdentifier: NSUserInterfaceItemIdentifier {
return NSUserInterfaceItemIdentifier(String(describing: self))
}
}

private final class EmoticonCollectionViewItem: NSCollectionViewItem {
static var itemIdentifier: NSUserInterfaceItemIdentifier {
return NSUserInterfaceItemIdentifier(String(describing: self))
}

var emoticon: String {
get { return _textField.stringValue }
set { _textField.stringValue = newValue }
}

private let _textField = NSTextField()

override func loadView() {
view = NSView(frame: NSRect(x: 0, y: 0, width: 60, height: 54))
}

override func viewDidLoad() {
super.viewDidLoad()
_textField.font = .systemFont(ofSize: 40)
_textField.alignment = .center
_textField.isEditable = false

_textField.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(_textField)

let constraints = [
_textField.topAnchor.constraint(equalTo: view.topAnchor),
_textField.bottomAnchor.constraint(equalTo: view.bottomAnchor),
_textField.leadingAnchor.constraint(equalTo: view.leadingAnchor),
_textField.trailingAnchor.constraint(equalTo: view.trailingAnchor)
]
NSLayoutConstraint.activate(constraints)
}
}
3 changes: 3 additions & 0 deletions Examples/Example-macOS/Sources/String+Differentiable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import DifferenceKit

extension String: Differentiable { }
25 changes: 0 additions & 25 deletions Examples/Example-macOS/Sources/StringCollectionViewItem.swift

This file was deleted.

Loading

0 comments on commit d22741e

Please sign in to comment.