Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tvOS support #287

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ branches:

script:
- set -o pipefail && xcodebuild test -project Macaw.xcodeproj -scheme 'Macaw iOS' -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO -destination 'platform=iOS Simulator,name=iPhone 6,OS=11.2' | xcpretty;
- set -o pipefail && xcodebuild build -project Macaw.xcodeproj -scheme 'MacawOSX' ONLY_ACTIVE_ARCH=NO | xcpretty;
- set -o pipefail && xcodebuild build -project Macaw.xcodeproj -scheme 'MacawOSX' ONLY_ACTIVE_ARCH=NO | xcpretty;
- set -o pipefail && xcodebuild build -project Macaw.xcodeproj -scheme 'MacawtvOS' ONLY_ACTIVE_ARCH=NO | xcpretty;
1 change: 1 addition & 0 deletions Macaw.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Pod::Spec.new do |s|

s.ios.deployment_target = "9.0"
s.osx.deployment_target = "10.12"
s.tvos.deployment_target = '9.0'
s.requires_arc = true
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.0' }

Expand Down
386 changes: 386 additions & 0 deletions Macaw.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion MacawTests/Animation/CombineAnimationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2017 Exyte. All rights reserved.
//

#if os(iOS)
#if os(iOS) || os(tvOS)

import XCTest
@testable import Macaw
Expand Down
2 changes: 1 addition & 1 deletion MacawTests/Animation/DelayedAnimationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2017 Exyte. All rights reserved.
//

#if os(iOS)
#if os(iOS) || os(tvOS)

import XCTest
@testable import Macaw
Expand Down
2 changes: 1 addition & 1 deletion MacawTests/Animation/SequenceAnimationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2017 Exyte. All rights reserved.
//

#if os(iOS)
#if os(iOS) || os(tvOS)

import XCTest
@testable import Macaw
Expand Down
2 changes: 1 addition & 1 deletion MacawTests/Bounds/ImageBoundsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2017 Exyte. All rights reserved.
//

#if os(iOS)
#if os(iOS) || os(tvOS)

import XCTest
@testable import Macaw
Expand Down
2 changes: 1 addition & 1 deletion MacawTests/Bounds/NodeBoundsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2017 Exyte. All rights reserved.
//

#if os(iOS)
#if os(iOS) || os(tvOS)

import XCTest
@testable import Macaw
Expand Down
2 changes: 1 addition & 1 deletion Source/animation/AnimationProducer.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#elseif os(OSX)
import AppKit
Expand Down
2 changes: 1 addition & 1 deletion Source/animation/layer_animation/CGExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#endif

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#elseif os(OSX)
import AppKit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#elseif os(OSX)
import AppKit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#elseif os(OSX)
import AppKit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#elseif os(OSX)
import AppKit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#elseif os(OSX)
import AppKit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#elseif os(OSX)
import AppKit
Expand Down
2 changes: 1 addition & 1 deletion Source/model/draw/RadialGradient.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#endif

Expand Down
4 changes: 2 additions & 2 deletions Source/model/scene/Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Foundation
import AppKit
#endif

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#endif

Expand Down Expand Up @@ -159,7 +159,7 @@ open class Image: Node {
}

// General case
#if os(iOS)
#if os(iOS) || os(tvOS)
return MImage(named: src)
#elseif os(OSX)
return MImage(named: NSImage.Name(rawValue: src))
Expand Down
2 changes: 1 addition & 1 deletion Source/model/scene/Text.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#elseif os(OSX)
import AppKit
Expand Down
14 changes: 12 additions & 2 deletions Source/platform/iOS/Common_iOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit

public typealias MRectCorner = UIRectCorner
Expand All @@ -23,8 +23,12 @@ import Foundation
public typealias MGestureRecognizerDelegate = UIGestureRecognizerDelegate
public typealias MTapGestureRecognizer = UITapGestureRecognizer
public typealias MPanGestureRecognizer = UIPanGestureRecognizer

#if os(iOS)
public typealias MPinchGestureRecognizer = UIPinchGestureRecognizer
public typealias MRotationGestureRecognizer = UIRotationGestureRecognizer
#endif

public typealias MScreen = UIScreen
public typealias MViewContentMode = UIViewContentMode

Expand All @@ -44,6 +48,7 @@ import Foundation
}
}

#if os(iOS)
extension MRotationGestureRecognizer {
final var mRotation: CGFloat {
get {
Expand Down Expand Up @@ -71,10 +76,15 @@ import Foundation
return super.location(ofTouch: touch, in: inView)
}
}
#endif

extension MFont {
class var mSystemFontSize: CGFloat {
return UIFont.systemFontSize
#if os(iOS)
return UIFont.systemFontSize
#elseif os(tvOS)
return 12.0
#endif
}
}

Expand Down
2 changes: 1 addition & 1 deletion Source/platform/iOS/Graphics_iOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit

func MGraphicsGetCurrentContext() -> CGContext? {
Expand Down
8 changes: 6 additions & 2 deletions Source/platform/iOS/MDisplayLink_iOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit

class MDisplayLink: MDisplayLinkProtocol {
Expand All @@ -23,7 +23,11 @@
self.onUpdate = onUpdate

displayLink = CADisplayLink(target: self, selector: #selector(updateHandler))
displayLink?.frameInterval = 1
#if os(iOS)
displayLink?.frameInterval = 1
#elseif os(tvOS)
displayLink?.preferredFramesPerSecond = 1
#endif
displayLink?.add(to: RunLoop.current, forMode: RunLoopMode.defaultRunLoopMode)
}

Expand Down
2 changes: 1 addition & 1 deletion Source/platform/iOS/MView_iOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit

open class MView: UIView, Touchable {
Expand Down
4 changes: 2 additions & 2 deletions Source/platform/macOS/Common_macOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ import Foundation
func MMainScreen() -> MScreen? {
return MScreen.main
}

extension MBezierPath {
func apply(_ transform: CGAffineTransform) {
let affineTransform = AffineTransform(
Expand All @@ -134,7 +134,7 @@ import Foundation
tX: transform.tx,
tY: transform.ty
)

self.transform(using: affineTransform)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/platform/macOS/MDisplayLink_macOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Foundation
return
}

CVDisplayLinkSetOutputCallback(displayLink!, { (_, _, _, _, _, userData) -> CVReturn in
CVDisplayLinkSetOutputCallback(displayLink!, { _, _, _, _, _, userData -> CVReturn in

let `self` = unsafeBitCast(userData, to: MDisplayLink.self)
`self`.onUpdate?()
Expand Down
2 changes: 1 addition & 1 deletion Source/render/GroupRenderer.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#endif

Expand Down
4 changes: 2 additions & 2 deletions Source/render/ImageRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Foundation
import AppKit
#endif

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#endif

Expand Down Expand Up @@ -64,7 +64,7 @@ class ImageRenderer: NodeRenderer {
return .none
}

#if os(iOS)
#if os(iOS) || os(tvOS)
let osImage = MImage(named: image.src)
#elseif os(OSX)
let osImage = MImage(named: NSImage.Name(rawValue: image.src))
Expand Down
2 changes: 1 addition & 1 deletion Source/render/NodeRenderer.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#endif

Expand Down
2 changes: 1 addition & 1 deletion Source/render/RenderContext.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#endif

Expand Down
4 changes: 2 additions & 2 deletions Source/render/RenderUtils.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#elseif os(OSX)
import AppKit
Expand Down Expand Up @@ -423,7 +423,7 @@ class RenderUtils {
let maxSize = CGFloat(max(w, h))
let path = MBezierPath(arcCenter: CGPoint.zero, radius: maxSize / 2, startAngle: extent, endAngle: end, clockwise: arcAngle >= 0)

#if os(iOS)
#if os(iOS) || os(tvOS)
var transform = CGAffineTransform(translationX: cx, y: cy)
transform = transform.rotated(by: CGFloat(rotation))
path.apply(transform.scaledBy(x: CGFloat(w) / maxSize, y: CGFloat(h) / maxSize))
Expand Down
2 changes: 1 addition & 1 deletion Source/render/ShapeRenderer.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#elseif os(OSX)
import AppKit
Expand Down
4 changes: 2 additions & 2 deletions Source/render/TextRenderer.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#elseif os(OSX)
import AppKit
Expand Down Expand Up @@ -160,7 +160,7 @@ class TextRenderer: NodeRenderer {
fileprivate func getTextColor(_ fill: Fill) -> MColor {
if let color = fill as? Color {

#if os(iOS)
#if os(iOS) || os(tvOS)
return MColor(cgColor: RenderUtils.mapColor(color))
#elseif os(OSX)
return MColor(cgColor: RenderUtils.mapColor(color)) ?? .black
Expand Down
2 changes: 1 addition & 1 deletion Source/svg/SVGView.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#elseif os(OSX)
import AppKit
Expand Down
2 changes: 1 addition & 1 deletion Source/thirdparty/CGFloat+Double.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#endif

Expand Down
2 changes: 1 addition & 1 deletion Source/utils/UIImage2Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#endif

Expand Down
Loading