Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandrshoshiashvili committed Feb 27, 2017
1 parent b85e24f commit db4f733
Show file tree
Hide file tree
Showing 27 changed files with 251 additions and 223 deletions.
8 changes: 4 additions & 4 deletions AwesomeSpotlightView/Classes/AwesomeSpotlight.swift
Expand Up @@ -21,13 +21,13 @@ class AwesomeSpotlight: NSObject {
var rect = CGRect()
var shape : AwesomeSpotlightShape = .RoundRectangle
private var text : String = ""
private var attributedText : AttributedString? = nil
private var attributedText : NSAttributedString? = nil

var showedText: AttributedString {
var showedText: NSAttributedString {
if let attrText = attributedText {
return attrText
} else {
return AttributedString(string: text)
return NSAttributedString(string: text)
}
}

Expand All @@ -42,7 +42,7 @@ class AwesomeSpotlight: NSObject {
self.text = text
}

init(withRect rect: CGRect, shape: AwesomeSpotlightShape, attributedText: AttributedString) {
init(withRect rect: CGRect, shape: AwesomeSpotlightShape, attributedText: NSAttributedString) {
super.init()
self.rect = rect
self.shape = shape
Expand Down
17 changes: 9 additions & 8 deletions AwesomeSpotlightView/Classes/AwesomeSpotlightView.swift
Expand Up @@ -35,7 +35,6 @@ class AwesomeSpotlightView: UIView {
private static let kSkipButtonFont = UIFont.boldSystemFont(ofSize: 13.0)

private var spotlightMask = CAShapeLayer()
private var currentIndex = 0
private var continueLabel = UILabel()
private var skipSpotlightButton = UIButton()
private var arrowDownImageView = UIImageView()
Expand All @@ -58,6 +57,8 @@ class AwesomeSpotlightView: UIView {
var skipButtonFont = kSkipButtonFont
var showAllSpotlightsAtOnce = kShowAllSpotlightsAtOnce

var currentIndex = 0

// MARK: - Initializers

override init(frame: CGRect) {
Expand Down Expand Up @@ -98,8 +99,8 @@ class AwesomeSpotlightView: UIView {

private func setupTextLabel() {
textLabel = UILabel(frame: CGRect(x: 0, y: 0, width: maxLabelWidth, height: 0))
textLabel.backgroundColor = .clear()
textLabel.textColor = .white()
textLabel.backgroundColor = .clear
textLabel.textColor = .white
textLabel.font = textLabelFont
textLabel.lineBreakMode = .byWordWrapping
textLabel.numberOfLines = 0
Expand All @@ -109,8 +110,8 @@ class AwesomeSpotlightView: UIView {
}

private func setupArrowDown() {
if let bundlePath = Bundle.main().pathForResource("AweosmeSpotlightViewBundle", ofType: "bundle") {
if let _ = Bundle(path: bundlePath)?.pathForResource("arrowDownIcon", ofType: "png") {
if let bundlePath = Bundle.main.path(forResource: "AwesomeSpotlightViewBundle", ofType: "bundle") {
if let _ = Bundle(path: bundlePath)?.path(forResource: "arrowDownIcon", ofType: "png") {
let arrowDownImage = UIImage(named: "arrowDownIcon", in: Bundle(path: bundlePath), compatibleWith: nil)
arrowDownImageView = UIImageView(image: arrowDownImage)
arrowDownImageView.alpha = 0
Expand All @@ -127,7 +128,7 @@ class AwesomeSpotlightView: UIView {
continueLabel.textAlignment = .center
continueLabel.text = "Continue".localized
continueLabel.alpha = 0
continueLabel.backgroundColor = .white()
continueLabel.backgroundColor = .white
addSubview(continueLabel)
}

Expand All @@ -140,7 +141,7 @@ class AwesomeSpotlightView: UIView {
skipSpotlightButton.setTitle("Skip".localized, for: [])
skipSpotlightButton.titleLabel?.font = skipButtonFont
skipSpotlightButton.alpha = 0
skipSpotlightButton.tintColor = .white()
skipSpotlightButton.tintColor = .white
addSubview(skipSpotlightButton)
}

Expand Down Expand Up @@ -370,7 +371,7 @@ class AwesomeSpotlightView: UIView {
}

extension AwesomeSpotlightView : CAAnimationDelegate {
override func animationDidStop(_ anim: CAAnimation, finished flag: Bool) {
func animationDidStop(_ anim: CAAnimation, finished flag: Bool) {
delegate?.spotlightView?(spotlightView: self, didNavigateToIndex: currentIndex)
}
}
12 changes: 4 additions & 8 deletions AwesomeSpotlightView/Classes/Localizator.swift
Expand Up @@ -13,21 +13,17 @@ private class Localizator {

lazy var localizableDictionary: NSDictionary! = {

//NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"AquarianHarp" ofType:@"bundle"];
//NSString *imageName = [[NSBundle bundleWithPath:bundlePath] pathForResource:@"trebleclef2" ofType:@"png"];

//AweosmeSpotlightViewBundle

if let bundlePath = Bundle.main().pathForResource("AweosmeSpotlightViewBundle", ofType: "bundle") {
if let path = Bundle(path: bundlePath)?.pathForResource("Localizable", ofType: "plist") {
if let bundlePath = Bundle.main.path(forResource: "AwesomeSpotlightViewBundle", ofType: "bundle") {
if let path = Bundle(path: bundlePath)?.path(forResource: "Localizable", ofType: "plist") {
return NSDictionary(contentsOfFile: path)
}
}
fatalError("Localizable file NOT found")
}()

func localize(string: String) -> String {
guard let localizedString = localizableDictionary.value(forKey: "Buttons")?.value(forKey: string)?.value(forKey: "value") as? String else {

guard let localizedString = ((localizableDictionary.value(forKey: "Buttons") as AnyObject).value(forKey: string) as AnyObject).value(forKey: "value") as? String else {
assertionFailure("Missing translation for: \(string)")
return ""
}
Expand Down

0 comments on commit db4f733

Please sign in to comment.