Skip to content
Merged
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
1 change: 1 addition & 0 deletions Podyfied/SnowGlobe/.swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0
6 changes: 1 addition & 5 deletions SnowGlobe.podspec → Podyfied/SnowGlobe/SnowGlobe.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = "SnowGlobe"
s.version = "2.0.8"
s.version = "2.1.3"
s.summary = "Delightful / cheesy Christmas easter egg to. Shake iPhone to snow"

# This description is used to generate tags and improve search results.
Expand All @@ -34,9 +34,5 @@ DESC
s.resource_bundles = {
'SnowGlobe' => ['Podyfied/SnowGlobe/Pod/Assets/*.*', 'Pod/Assets/*.*']
}

# s.public_header_files = 'Pod/Classes/**/*.h'
# s.frameworks = 'UIKit', 'MapKit'
# s.dependency 'AFNetworking', '~> 2.3'
end

10 changes: 8 additions & 2 deletions SnowGlobe/SnowGlobe.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
9FDC70E11A2FBFDC0033F371 /* Numbers+Extentios.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FDC70DB1A2FBFDC0033F371 /* Numbers+Extentios.swift */; };
9FDC70E21A2FBFDC0033F371 /* SleighBells.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 9FDC70DC1A2FBFDC0033F371 /* SleighBells.mp3 */; };
9FDC70E31A2FBFDC0033F371 /* SnowGlobeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FDC70DD1A2FBFDC0033F371 /* SnowGlobeView.swift */; };
A774FBD61FB32DD000D08796 /* SnowGlobeSensitivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = A774FBD51FB32DD000D08796 /* SnowGlobeSensitivity.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -41,6 +42,7 @@
9FDC70DB1A2FBFDC0033F371 /* Numbers+Extentios.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Numbers+Extentios.swift"; sourceTree = "<group>"; };
9FDC70DC1A2FBFDC0033F371 /* SleighBells.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = SleighBells.mp3; sourceTree = "<group>"; };
9FDC70DD1A2FBFDC0033F371 /* SnowGlobeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SnowGlobeView.swift; sourceTree = "<group>"; };
A774FBD51FB32DD000D08796 /* SnowGlobeSensitivity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SnowGlobeSensitivity.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -85,6 +87,7 @@
children = (
9FDC70C11A2FBFAB0033F371 /* SnowGlobe.h */,
9FDC70DD1A2FBFDC0033F371 /* SnowGlobeView.swift */,
A774FBD51FB32DD000D08796 /* SnowGlobeSensitivity.swift */,
9FDC70D81A2FBFDC0033F371 /* CMMotionManager+shared.swift */,
9FDC70DB1A2FBFDC0033F371 /* Numbers+Extentios.swift */,
9FDC70E41A2FBFE70033F371 /* Resources */,
Expand Down Expand Up @@ -242,6 +245,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A774FBD61FB32DD000D08796 /* SnowGlobeSensitivity.swift in Sources */,
9FDC70E11A2FBFDC0033F371 /* Numbers+Extentios.swift in Sources */,
9FDC70DE1A2FBFDC0033F371 /* CMMotionManager+shared.swift in Sources */,
9FDC70E31A2FBFDC0033F371 /* SnowGlobeView.swift in Sources */,
Expand Down Expand Up @@ -311,6 +315,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -353,6 +358,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -376,7 +382,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "uk.co.stringCode.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -395,7 +401,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "uk.co.stringCode.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
36 changes: 36 additions & 0 deletions SnowGlobe/SnowGlobe/SnowGlobeSensitivity.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// SnowGlobeSensitivity.swift
// SnowGlobe
//
// Created by Jan Dammshäuser on 08.11.17.
// Copyright © 2017 stringCode. All rights reserved.
//

import Foundation

/// The SnowGlobeSensitivity defines how hard you have to shake the device in order to make it snow.
///
/// - ultraLow: 1.7
/// - low: 2
/// - medium: 3 (default)
/// - high: 4
/// - custom: enter your own sensitivity value. Has to be positive.
public enum SnowGlobeSensitivity {
case ultraLow, low, medium, high
case custom(Double)

fileprivate var value: Double {
switch self {
case .ultraLow: return 1.7
case .low: return 2
case .medium: return 3
case .high: return 4
case let .custom(sensitivity) where sensitivity > 0: return sensitivity
case .custom: return 0
}
}
}

func >=(lhs: Double, rhs: SnowGlobeSensitivity) -> Bool {
return lhs >= rhs.value
}
14 changes: 8 additions & 6 deletions SnowGlobe/SnowGlobe/SnowGlobeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ open class SnowGlobeView: UIView {

open var soundEffectsEnabled: Bool = true

open var sensitivity: SnowGlobeSensitivity = .medium

/// default ligth snow flake image
open class func lightSnowFlakeImage() -> (UIImage?) {
if let image = UIImage(named: "flake") {
Expand Down Expand Up @@ -154,11 +156,11 @@ open class SnowGlobeView: UIView {

fileprivate func initialSetup() {
backgroundColor = UIColor.clear
autoresizingMask = [UIViewAutoresizing.flexibleWidth, UIViewAutoresizing.flexibleHeight]
autoresizingMask = [UIView.AutoresizingMask.flexibleWidth, UIView.AutoresizingMask.flexibleHeight]
isUserInteractionEnabled = false
emitter.emitterCells = [emitterCell]
emitter.emitterShape = kCAEmitterLayerLine
emitter.renderMode = kCAEmitterLayerOldestLast
emitter.emitterShape = .line
emitter.renderMode = .oldestLast
emitter.lifetime = 0
}

Expand All @@ -170,9 +172,9 @@ open class SnowGlobeView: UIView {
}
motionManager.startAccelerometerUpdates(to: queue) { [weak self] accelerometerData, error in
let data = accelerometerData!.acceleration
var magnitude = sqrt( sq(data.x) + sq(data.y) + sq(data.z) )
magnitude = (magnitude < 3.0) ? 0.0 : magnitude
if (magnitude == 0.0 && self?.isAnimating == false) {
let sensitivity = self?.sensitivity ?? .medium
let magnitude = sqrt( sq(data.x) + sq(data.y) + sq(data.z) )
if (magnitude >= sensitivity && self?.isAnimating == false) {
return
}
if let welf = self {
Expand Down
2 changes: 1 addition & 1 deletion SnowGlobe/SnowGlobeTests/SnowGlobeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SnowGlobeTests: XCTestCase {

func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock() {
self.measure() {
// Put the code you want to measure the time of here.
}
}
Expand Down
8 changes: 4 additions & 4 deletions SwiftSample/SwiftSample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "uk.co.stringCode.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -474,7 +474,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "uk.co.stringCode.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -491,7 +491,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "uk.co.stringCode.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftSample.app/SwiftSample";
};
name = Debug;
Expand All @@ -505,7 +505,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "uk.co.stringCode.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftSample.app/SwiftSample";
};
name = Release;
Expand Down