Skip to content

Commit

Permalink
Merge pull request #1 from lekshmiraveendranath/feature/background
Browse files Browse the repository at this point in the history
Feature/background
  • Loading branch information
lekshmiraveendranath authored Feb 14, 2018
2 parents 7d041cf + 9a3342e commit ca61712
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Example/Example/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.1.0</string>
<string>1.2.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
Expand Down
3 changes: 3 additions & 0 deletions Example/Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class ViewController: UIViewController {

@IBAction func startTutorial() {

Spotlight.delay = 4.0
Spotlight.showInfoBackground = false

guard let rightBB1 = navigationItem.rightBarButtonItem, let leftBB1 = navigationItem.leftBarButtonItem else { return }

let n1 = SpotlightNode(text: "Show spotlight on a bar button item", target: .barButton(rightBB1))
Expand Down
2 changes: 1 addition & 1 deletion LRSpotlight.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "LRSpotlight"
s.version = "1.1.0"
s.version = "1.2.0"
s.swift_version = "4.0.0"
s.license = { :type => 'MIT', :file => "License.md" }
s.summary = "Introductory walkthrough framework for iOS Apps"
Expand Down
82 changes: 82 additions & 0 deletions Spotlight.xcodeproj/xcshareddata/xcschemes/Spotlight.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "413B98DB2029857F00EF3606"
BuildableName = "Spotlight.framework"
BlueprintName = "Spotlight"
ReferencedContainer = "container:Spotlight.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "413B98DB2029857F00EF3606"
BuildableName = "Spotlight.framework"
BlueprintName = "Spotlight"
ReferencedContainer = "container:Spotlight.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "413B98DB2029857F00EF3606"
BuildableName = "Spotlight.framework"
BlueprintName = "Spotlight"
ReferencedContainer = "container:Spotlight.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
2 changes: 1 addition & 1 deletion Spotlight/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.1.0</string>
<string>1.2.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
3 changes: 2 additions & 1 deletion Spotlight/Sources/Spotlight.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import UIKit

public struct Spotlight {

public static var moveDuration: TimeInterval = 4.0
public static var delay: TimeInterval = 3.0
public static var animationDuration: TimeInterval = 0.25
public static var showInfoBackground = true

public init() {}

Expand Down
21 changes: 15 additions & 6 deletions Spotlight/Sources/SpotlightViewController+UISetup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,22 @@ extension SpotlightViewController {
infoStackView.axis = .vertical
infoStackView.distribution = .fill
infoStackView.spacing = 8
infoStackView.layoutMargins = UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8)
infoStackView.isLayoutMarginsRelativeArrangement = true

if Spotlight.showInfoBackground {
let blurEffect = UIBlurEffect(style: .light)
let blurredEffectView = UIVisualEffectView(effect: blurEffect)
let vibrancyEffect = UIVibrancyEffect(blurEffect: blurEffect)
let vibrancyEffectView = UIVisualEffectView(effect: vibrancyEffect)
blurredEffectView.layer.cornerRadius = 10.0
vibrancyEffectView.layer.cornerRadius = 10.0
blurredEffectView.clipsToBounds = true
vibrancyEffectView.clipsToBounds = true
blurredEffectView.embedAndpin(to: infoStackView)
vibrancyEffectView.embedAndpin(to: infoStackView)
}

// let stackBackgroundView = UIView()
// stackBackgroundView.backgroundColor = .white
// stackBackgroundView.layer.cornerRadius = 5.0
// stackBackgroundView.alpha = 0.5
// stackBackgroundView.embedAndpin(to: infoStackView)

view.addSubview(infoStackView)

infoStackView.translatesAutoresizingMaskIntoConstraints = false
Expand Down
7 changes: 4 additions & 3 deletions Spotlight/Sources/SpotlightViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class SpotlightViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
nextSpotlight()
timer = Timer.scheduledTimer(timeInterval: Spotlight.moveDuration, target: self, selector: #selector(nextSpotlight), userInfo: nil, repeats: true)
timer = Timer.scheduledTimer(timeInterval: Spotlight.delay, target: self, selector: #selector(nextSpotlight), userInfo: nil, repeats: true)
}

override func viewWillDisappear(_ animated: Bool) {
Expand Down Expand Up @@ -102,11 +102,12 @@ extension SpotlightViewController {
targetRect = spotlightView.move(node)
}

// Animate the info label change
infoLabel.text = node.text.isEmpty ? " " : node.text

// Animate the info box around if intersects with spotlight
view.layoutIfNeeded()
UIView.animate(withDuration: Spotlight.animationDuration, animations: { [weak self] in
guard let `self` = self else { return }
self.infoLabel.text = node.text
if targetRect.intersects(self.infoStackView.frame) {
if self.infoStackTopConstraint.priority == .defaultLow {
self.infoStackTopConstraint.priority = .defaultHigh
Expand Down

0 comments on commit ca61712

Please sign in to comment.