Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: 2
jobs:
build-and-test:
macos:
xcode: "9.3.0"
shell: /bin/bash --login -o pipefail
steps:
- checkout
- run: brew upgrade Carthage
- run: carthage bootstrap
- run: brew install swiftlint
- run: xcodebuild -project Spots.xcodeproj -scheme "Spots-macOS" -sdk macosx clean
- run: xcodebuild -project Spots.xcodeproj -scheme "Spots-macOS" -sdk macosx -enableCodeCoverage YES test
- run: bash <(curl -s https://codecov.io/bash) -cF osx -J 'Spots'
- run: xcodebuild -project Spots.xcodeproj -scheme "Spots-iOS" -sdk iphonesimulator clean
- run: xcodebuild -project Spots.xcodeproj -scheme "Spots-iOS" -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=11.3,name=iPhone X' -enableCodeCoverage YES test
- run: bash <(curl -s https://codecov.io/bash) -cF ios -J 'Spots'
- run: xcodebuild -project Spots.xcodeproj -scheme "Spots-tvOS" -destination 'platform=tvOS Simulator,name=Apple TV,OS=11.3' clean
- run: xcodebuild -project Spots.xcodeproj -scheme "Spots-tvOS" -destination 'platform=tvOS Simulator,name=Apple TV,OS=11.3' -enableCodeCoverage YES test
- run: bash <(curl -s https://codecov.io/bash) -cF tvos -J 'Spots'

workflows:
version: 2
build-and-test:
jobs:
- build-and-test
4 changes: 0 additions & 4 deletions .mention-bot

This file was deleted.

4 changes: 0 additions & 4 deletions .slather.yml

This file was deleted.

21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "hyperoslo/Cache" "4.1.2"
github "hyperoslo/Cache" "4.2.0"
2 changes: 1 addition & 1 deletion Sources/Shared/Classes/ComponentManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ public class ComponentManager {
/// - parameter component: The component that should be mutated.
/// - parameter animation: A Animation that is used when performing the mutation (only works for Listable objects)
@available(*, deprecated: 7.0, message: "Deprecated in favor for reloadIfNeeded with items")
public func reloadIfNeeded(json: [String : Any], component: Component, withAnimation animation: Animation = .automatic, completion: Completion = nil) {
public func reloadIfNeeded(json: [String: Any], component: Component, withAnimation animation: Animation = .automatic, completion: Completion = nil) {
Dispatch.interactive {
let jsonEncoder = JSONEncoder()
let jsonDecoder = JSONDecoder()
Expand Down
4 changes: 2 additions & 2 deletions Sources/Shared/Classes/SpotsControllerManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public class SpotsControllerManager {
/// - parameter compare: A closure that is used for comparing a ComponentModel collections
/// - parameter animated: An animation closure that can be used to perform custom animations when reloading
/// - parameter completion: A closure that will be run after reload has been performed on all components
public func reloadIfNeeded(_ json: [String : Any],
public func reloadIfNeeded(_ json: [String: Any],
controller: SpotsController,
compare: @escaping CompareClosure = { lhs, rhs in return lhs !== rhs },
animated: ((_ view: View) -> Void)? = nil,
Expand Down Expand Up @@ -461,7 +461,7 @@ public class SpotsControllerManager {
///- parameter controller: A SpotsController instance.
///- parameter animated: An animation closure that can be used to perform custom animations when reloading
///- parameter completion: A closure that will be run after reload has been performed on all components
public func reload(json: [String : Any], controller: SpotsController, animated: ((_ view: View) -> Void)? = nil, completion: Completion = nil) {
public func reload(json: [String: Any], controller: SpotsController, animated: ((_ view: View) -> Void)? = nil, completion: Completion = nil) {
Dispatch.main { [weak self] in
guard let strongSelf = self else {
completion?()
Expand Down
2 changes: 1 addition & 1 deletion Sources/Shared/Extensions/Array+Extensions.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public extension Array where Element : Indexable {
public extension Array where Element: Indexable {
/// Refresh indexes inside of an array that is indexable.
mutating func refreshIndexes() {
enumerated().forEach {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Shared/Extensions/Component+Mutation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public extension Component {
///
/// - parameter json: A JSON dictionary
/// - parameter animation: A Animation that is used when performing the mutation (only works for Listable objects)
public func reloadIfNeeded(_ json: [String : Any], withAnimation animation: Animation = .automatic) {
public func reloadIfNeeded(_ json: [String: Any], withAnimation animation: Animation = .automatic) {
manager.reloadIfNeeded(json: json, component: self, withAnimation: animation)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import Cache

do {
if let data = NSData(contentsOfFile: filePath),
let json = try JSONSerialization.jsonObject(with: data as Data, options: .mutableContainers) as? [String : Any] {
let json = try JSONSerialization.jsonObject(with: data as Data, options: .mutableContainers) as? [String: Any] {
strongSelf.source?.cancel()
strongSelf.source = nil

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ extension SpotsController {
/// - parameter compare: A closure that is used for comparing a ComponentModel collections
/// - parameter animated: An animation closure that can be used to perform custom animations when reloading
/// - parameter completion: A closure that will be run after reload has been performed on all components
public func reloadIfNeeded(_ json: [String : Any],
public func reloadIfNeeded(_ json: [String: Any],
compare: @escaping CompareClosure = { lhs, rhs in return lhs !== rhs },
animated: ((_ view: View) -> Void)? = nil,
completion: Completion = nil) {
Expand Down Expand Up @@ -69,7 +69,7 @@ extension SpotsController {
///- parameter json: A JSON dictionary that gets parsed into UI elements
///- parameter animated: An animation closure that can be used to perform custom animations when reloading
///- parameter completion: A closure that will be run after reload has been performed on all components
public func reload(_ json: [String : Any], animated: ((_ view: View) -> Void)? = nil, completion: Completion = nil) {
public func reload(_ json: [String: Any], animated: ((_ view: View) -> Void)? = nil, completion: Completion = nil) {
manager.reload(json: json,
controller: self,
animated: animated,
Expand Down
2 changes: 1 addition & 1 deletion Sources/Shared/Protocols/DictionaryConvertible.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
A protocol for returning a dictionary representation of self
*/
public protocol DictionaryConvertible {
var dictionary: [String : Any] { get }
var dictionary: [String: Any] { get }
}
2 changes: 1 addition & 1 deletion Sources/Shared/Protocols/UserInterface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public protocol UserInterface: class {
func processChanges(_ changes: Changes,
withAnimation animation: Animation,
updateDataSource: () -> Void,
completion: ((()) -> Void)?)
completion: (() -> Void)?)

/// A convenience method for performing inserts on a UserInterface.
///
Expand Down
4 changes: 2 additions & 2 deletions Sources/Shared/Structs/ComponentModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public struct ComponentModel: Codable, Equatable {
layout: Layout = Layout(),
interaction: Interaction = .init(),
items: [Item] = [],
meta: [String : Any] = [:]) {
meta: [String: Any] = [:]) {
self.identifier = identifier
self.kind = kind
self.layout = layout
Expand Down Expand Up @@ -98,7 +98,7 @@ public struct ComponentModel: Codable, Equatable {
interaction: Interaction = .init(),
model: T? = nil,
items: [Item] = [],
meta: [String : Any] = [:]) {
meta: [String: Any] = [:]) {
self.init(identifier: identifier,
header: header,
footer: footer,
Expand Down
8 changes: 4 additions & 4 deletions Sources/Shared/Structs/Item.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public struct Item: Codable, Indexable {
kind: StringConvertible = "",
action: String? = nil,
size: CGSize = CGSize(width: 0, height: 0),
meta: [String : Any] = [:],
relations: [String : [Item]] = [:]) {
meta: [String: Any] = [:],
relations: [String: [Item]] = [:]) {
self.identifier = identifier
self.title = title
self.subtitle = subtitle
Expand Down Expand Up @@ -103,8 +103,8 @@ public struct Item: Codable, Indexable {
kind: StringConvertible = "",
action: String? = nil,
size: CGSize = CGSize(width: 0, height: 0),
meta: [String : Any] = [:],
relations: [String : [Item]] = [:]) {
meta: [String: Any] = [:],
relations: [String: [Item]] = [:]) {
self.init(identifier: identifier,
title: title,
subtitle: subtitle,
Expand Down
4 changes: 2 additions & 2 deletions Sources/Shared/Structs/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public struct Parser {
///
/// - returns: A collection of components
@available(*, deprecated: 7.0, message: "Deprecated in favor for parseComponents with data")
public static func parseComponents(json: [String : Any],
public static func parseComponents(json: [String: Any],
key: String = "components",
configuration: Configuration = .shared) -> [Component] {
let components: [ComponentModel] = parseComponentModels(json: json, key: key)
Expand Down Expand Up @@ -58,7 +58,7 @@ public struct Parser {
///
/// - returns: A collection of `ComponentModel`s
@available(*, deprecated: 7.0, message: "Deprecated in favor for parseComponentModels with data")
public static func parseComponentModels(json: [String : Any],
public static func parseComponentModels(json: [String: Any],
key: String = "components") -> [ComponentModel] {
let jsonEncoder = JSONEncoder()

Expand Down
6 changes: 3 additions & 3 deletions Sources/iOS/Classes/SpotsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ open class SpotsController: UIViewController, SpotsProtocol, ComponentFocusDeleg

let notificationName = NSNotification.Name(rawValue: NotificationKeys.deviceDidRotateNotification.rawValue)
NotificationCenter.default.addObserver(self,
selector:#selector(self.deviceDidRotate(_:)),
selector: #selector(self.deviceDidRotate(_:)),
name: notificationName,
object: nil)
}
Expand All @@ -147,7 +147,7 @@ open class SpotsController: UIViewController, SpotsProtocol, ComponentFocusDeleg
///
/// - returns: An initialized controller with components. built from JSON.
@available(*, deprecated: 7.0, message: "Deprecated in favor for init with data")
public convenience init(_ json: [String : Any], configuration: Configuration = .shared) {
public convenience init(_ json: [String: Any], configuration: Configuration = .shared) {
self.init(components: Parser.parseComponents(json: json, configuration: configuration),
configuration: configuration)
}
Expand Down Expand Up @@ -216,7 +216,7 @@ open class SpotsController: UIViewController, SpotsProtocol, ComponentFocusDeleg
///
/// - parameter notification: A notification containing the new size.
@objc func deviceDidRotate(_ notification: Notification) {
if let userInfo = (notification as NSNotification).userInfo as? [String : Any],
if let userInfo = (notification as NSNotification).userInfo as? [String: Any],
let rotationSize = userInfo["size"] as? RotationSize, view.window == nil {
configure(withSize: rotationSize.size)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/macOS/Classes/SpotsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ open class SpotsController: NSViewController, SpotsProtocol {
- parameter json: A JSON dictionary that gets parsed into UI elements
*/
@available(*, deprecated: 7.0, message: "Deprecated in favor for init with data")
public convenience init(_ json: [String : Any], configuration: Configuration = .shared) {
public convenience init(_ json: [String: Any], configuration: Configuration = .shared) {
self.init(components: Parser.parseComponents(json: json, configuration: configuration))
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/macOS/Classes/SpotsScrollView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ open class SpotsScrollView: NSScrollView {
layoutViews(animated: false)
}

open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey: Any]?, context: UnsafeMutableRawPointer?) {
if keyPath == "contentLayoutRect" {
if #available(OSX 10.12, *) {
// Workaround to fix the contentInset when using tabs.
Expand Down
6 changes: 3 additions & 3 deletions Sources/macOS/Extensions/NSCollectionView+UserInterface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ extension NSCollectionView: UserInterface {
public func processChanges(_ changes: Changes,
withAnimation animation: Animation = .automatic,
updateDataSource: () -> Void,
completion: ((()) -> Void)? = nil) {
completion: (() -> Void)? = nil) {
let instance = animation != .none ? animator() : self
let deletionSets = Set<IndexPath>(changes.deletions
.map { IndexPath(item: $0, section: 0) })
Expand All @@ -173,7 +173,7 @@ extension NSCollectionView: UserInterface {
reloadSets.isEmpty &&
deletionSets.isEmpty &&
changes.moved.isEmpty {
completion?(())
completion?()
return
}

Expand All @@ -189,7 +189,7 @@ extension NSCollectionView: UserInterface {
to: IndexPath(item: move.value, section: 0))
}
}, completionHandler: nil)
completion?(())
completion?()
removeAnimation()
}

Expand Down
6 changes: 3 additions & 3 deletions Sources/macOS/Extensions/NSTableView+UserInterface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ extension NSTableView: UserInterface {
public func processChanges(_ changes: Changes,
withAnimation animation: Animation = .automatic,
updateDataSource: () -> Void,
completion: ((()) -> Void)? = nil) {
completion: (() -> Void)? = nil) {
guard let component = (dataSource as? DataSource)?.component else {
return
}
Expand All @@ -145,7 +145,7 @@ extension NSTableView: UserInterface {
!reloadSets.isEmpty &&
!deletionSets.isEmpty &&
changes.moved.isEmpty {
completion?(())
completion?()
return
}

Expand All @@ -170,7 +170,7 @@ extension NSTableView: UserInterface {
component.model.items[index] = item
}

completion?(())
completion?()
endUpdates()
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/macOS/Protocols/ComponentView.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Cocoa

public protocol ComponentView {}
extension NSView : ComponentView {}
extension NSCollectionViewItem : ComponentView {}
extension NSView: ComponentView {}
extension NSCollectionViewItem: ComponentView {}
2 changes: 1 addition & 1 deletion Sources/tvOS/Extensions/SpotsScrollView+tvOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extension SpotsScrollView {
var yOffsetOfCurrentSubview: CGFloat = 0.0
let lastView = subviewsInLayoutOrder.last
let multipleComponents = subviewsInLayoutOrder.count > 1
let scrollViews = subviewsInLayoutOrder.flatMap({ $0 as? ScrollView })
let scrollViews = subviewsInLayoutOrder.compactMap({ $0 as? ScrollView })

for (offset, scrollView) in scrollViews.enumerated() {
defer {
Expand Down
Loading