Skip to content

Commit

Permalink
Refactored tvOS example with proper assets.
Browse files Browse the repository at this point in the history
  • Loading branch information
onurersel committed Sep 29, 2017
1 parent 3691e90 commit 1f25069
Show file tree
Hide file tree
Showing 37 changed files with 151 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
4.0
2 changes: 1 addition & 1 deletion anim.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'anim'
s.version = '1.2.1'
s.version = '1.2.2'
s.license = { :type => "MIT", :file => "LICENSE" }
s.summary = 'Swift animation library for iOS, tvOS and macOS'
s.homepage = 'https://github.com/onurersel/anim'
Expand Down
35 changes: 6 additions & 29 deletions anim.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
BA0BAF381F7E35B1001CBC01 /* DistanceExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA0BAF371F7E35B1001CBC01 /* DistanceExtension.swift */; };
BA0BAF391F7E35B1001CBC01 /* DistanceExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA0BAF371F7E35B1001CBC01 /* DistanceExtension.swift */; };
BA150FA91E53B870009A14E3 /* animTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA150F961E53B838009A14E3 /* animTests.swift */; };
BA150FAA1E53D2EB009A14E3 /* anim.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BA3FCA091E4B262F0095BE41 /* anim.framework */; };
BA184E101E77EC16001CAE47 /* Foundation.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA184E0F1E77EC16001CAE47 /* Foundation.swift */; };
Expand Down Expand Up @@ -153,14 +155,10 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
BA0BAF371F7E35B1001CBC01 /* DistanceExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DistanceExtension.swift; sourceTree = "<group>"; };
BA150F961E53B838009A14E3 /* animTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = animTests.swift; sourceTree = "<group>"; };
BA150F971E53B838009A14E3 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
BA150F9E1E53B85C009A14E3 /* animTests-ios.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "animTests-ios.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
BA16C8791F79564100D1721B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
BA16C87B1F79564100D1721B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
BA16C87E1F79564100D1721B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
BA16C8801F79564100D1721B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
BA16C8811F79564100D1721B /* example_bonfire_macos.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = example_bonfire_macos.entitlements; sourceTree = "<group>"; };
BA184E0F1E77EC16001CAE47 /* Foundation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Foundation.swift; sourceTree = "<group>"; };
BA20430B1E5C571100E8FDCA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
BA20430C1E5C571100E8FDCA /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
Expand Down Expand Up @@ -282,18 +280,6 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
BA16C8781F79564100D1721B /* example-bonfire-macos */ = {
isa = PBXGroup;
children = (
BA16C8791F79564100D1721B /* AppDelegate.swift */,
BA16C87B1F79564100D1721B /* Assets.xcassets */,
BA16C87D1F79564100D1721B /* MainMenu.xib */,
BA16C8801F79564100D1721B /* Info.plist */,
BA16C8811F79564100D1721B /* example_bonfire_macos.entitlements */,
);
path = "example-bonfire-macos";
sourceTree = "<group>";
};
BA2043071E5C56E400E8FDCA /* examples */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -328,6 +314,7 @@
BA20432E1E5C81AD00E8FDCA /* ViewController.swift */,
BA2043371E5C840600E8FDCA /* Particle.swift */,
BA20433B1E5C86CF00E8FDCA /* Emitter.swift */,
BA0BAF371F7E35B1001CBC01 /* DistanceExtension.swift */,
);
path = bonfire;
sourceTree = "<group>";
Expand All @@ -348,7 +335,6 @@
BA3FCA0B1E4B262F0095BE41 /* anim */,
BA2043071E5C56E400E8FDCA /* examples */,
BA3F894F1E5341FD00FBAB7D /* test */,
BA16C8781F79564100D1721B /* example-bonfire-macos */,
BA3FCA0A1E4B262F0095BE41 /* Products */,
);
sourceTree = "<group>";
Expand Down Expand Up @@ -820,6 +806,7 @@
BA2043381E5C840600E8FDCA /* Particle.swift in Sources */,
BA4590731E6861F400CAB89B /* Dummy.swift in Sources */,
BA20432F1E5C81AD00E8FDCA /* AppDelegate.swift in Sources */,
BA0BAF381F7E35B1001CBC01 /* DistanceExtension.swift in Sources */,
BA20433C1E5C86CF00E8FDCA /* Emitter.swift in Sources */,
BA2043311E5C81C000E8FDCA /* Layout.swift in Sources */,
BABCF2E61E67021E00158464 /* Style.swift in Sources */,
Expand Down Expand Up @@ -851,6 +838,7 @@
BA5DE4211F7944BC001A1BAE /* Math.swift in Sources */,
BA5DE4221F7944BC001A1BAE /* Style.swift in Sources */,
BA5DE4231F7944BC001A1BAE /* Dummy.swift in Sources */,
BA0BAF391F7E35B1001CBC01 /* DistanceExtension.swift in Sources */,
BA5DE4241F7944BC001A1BAE /* Foundation.swift in Sources */,
BA5DE4251F7944BC001A1BAE /* ViewController.swift in Sources */,
BA5DE4261F7944BC001A1BAE /* Particle.swift in Sources */,
Expand Down Expand Up @@ -948,17 +936,6 @@
};
/* End PBXTargetDependency section */

/* Begin PBXVariantGroup section */
BA16C87D1F79564100D1721B /* MainMenu.xib */ = {
isa = PBXVariantGroup;
children = (
BA16C87E1F79564100D1721B /* Base */,
);
name = MainMenu.xib;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
BA150FA71E53B85C009A14E3 /* Debug */ = {
isa = XCBuildConfiguration;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
},
{
"idiom" : "tv",
"filename" : "circle_red-tv.png",
"scale" : "1x"
},
{
"idiom" : "tv",
"filename" : "[email protected]",
"scale" : "2x"
}
],
"info" : {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
},
{
"idiom" : "tv",
"filename" : "particle_red-tv.png",
"scale" : "1x"
},
{
"idiom" : "tv",
"filename" : "[email protected]",
"scale" : "2x"
}
],
"info" : {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
},
{
"idiom" : "tv",
"filename" : "particle_yellow-tv.png",
"scale" : "1x"
},
{
"idiom" : "tv",
"filename" : "[email protected]",
"scale" : "2x"
}
],
"info" : {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
},
{
"idiom" : "tv",
"filename" : "rect_orange-tv.png",
"scale" : "1x"
},
{
"idiom" : "tv",
"filename" : "[email protected]",
"scale" : "2x"
}
],
"info" : {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
},
{
"idiom" : "tv",
"filename" : "rect_red-tv.png",
"scale" : "1x"
},
{
"idiom" : "tv",
"filename" : "[email protected]",
"scale" : "2x"
}
],
"info" : {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
},
{
"idiom" : "tv",
"filename" : "rect_yellow-tv.png",
"scale" : "1x"
},
{
"idiom" : "tv",
"filename" : "[email protected]",
"scale" : "2x"
}
],
"info" : {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
},
{
"idiom" : "tv",
"filename" : "wood-tv.png",
"scale" : "1x"
},
{
"idiom" : "tv",
"filename" : "[email protected]",
"scale" : "2x"
}
],
"info" : {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions examples/bonfire/DistanceExtension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// DistanceExtension.swift
// anim
//
// Created by Onur Ersel on 2017-09-29.
// Copyright © 2017 Onur Ersel. All rights reserved.
//

import UIKit

enum PlatformScale: CGFloat {
case iOS = 1
case tvOS = 3

static var valueForPlatform: PlatformScale {
#if os(tvOS)
return self.tvOS
#else
return self.iOS
#endif
}
}

extension Double {
var platform: CGFloat {
return CGFloat(self) * PlatformScale.valueForPlatform.rawValue
}
}

extension Float {
var platform: CGFloat {
return CGFloat(self) * PlatformScale.valueForPlatform.rawValue
}
}

extension CGFloat {
var platform: CGFloat {
return self * PlatformScale.valueForPlatform.rawValue
}
}

extension Int {
var platform: CGFloat {
return CGFloat(self) * PlatformScale.valueForPlatform.rawValue
}
}

extension CGSize {
var platform: CGSize {
return CGSize(width: self.width.platform, height: self.height.platform)
}
}

extension DoubleRange {
var platform: DoubleRange {
return DoubleRange(min: Double(self.min.platform), max: Double(self.max.platform))
}
}
11 changes: 10 additions & 1 deletion examples/bonfire/Emitter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,18 @@ class Emitter: UIView {
var scale: CGFloat
var duration: TimeInterval
var initialAlpha: CGFloat

mutating func applyPlatformMultiplier() {
emitSize = emitSize.platform
ascend = ascend.platform
}
}

var settings: Settings!
var settings: Settings! {
didSet {
settings.applyPlatformMultiplier()
}
}
private var availableParticles = [Particle]()


Expand Down
8 changes: 5 additions & 3 deletions examples/bonfire/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ class ViewController: UIViewController {

anim.defaultSettings.delay = 0

/*
#if os(tvOS)
self.view.transform = CGAffineTransform.init(scaleX: 3, y: 3)
#endif
*/

// background
let backgroundView = UIView()
Expand All @@ -36,12 +38,12 @@ class ViewController: UIViewController {
// container
mainContainer = UIView()
self.view.addSubview(mainContainer)
mainContainer.center(to: self.view, verticalAdjustment: 20)
mainContainer.center(to: self.view, verticalAdjustment: 20.platform)

// wood
let woodView = UIImageView(image: #imageLiteral(resourceName: "wood"))
mainContainer.addSubview(woodView)
woodView.center(to: mainContainer, verticalAdjustment: 80)
woodView.center(to: mainContainer, verticalAdjustment: 80.platform)

// emitters
createEdgeFireEmitters(x: -16)
Expand Down Expand Up @@ -98,7 +100,7 @@ class ViewController: UIViewController {
private func createEmitter(x: CGFloat = 0, y: CGFloat = 0, withSettings settings: Emitter.Settings) {
let emitter = Emitter()
mainContainer.addSubview(emitter)
emitter.center(to: mainContainer, horizontalAdjustment: x, verticalAdjustment: y)
emitter.center(to: mainContainer, horizontalAdjustment: x.platform, verticalAdjustment: y.platform)
let settings = settings
emitter.start(settings)
}
Expand Down

0 comments on commit 1f25069

Please sign in to comment.