Skip to content

Commit

Permalink
Add showShadow param for start sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
dungPhamAlo committed May 17, 2022
1 parent e5653e3 commit 786f142
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion Sources/MaterialShowcase/MaterialShowcase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ extension MaterialShowcase {
}

/// Shows it over current screen after completing setup process
@objc public func show(animated: Bool = true,hasShadow: Bool = true, hasSkipButton: Bool = false, completion handler: (()-> Void)?) {
@objc public func show(animated: Bool = true, hasShadow: Bool = true, hasSkipButton: Bool = false, completion handler: (()-> Void)?) {
initViews()
alpha = 0.0
containerView.addSubview(self)
Expand Down
100 changes: 50 additions & 50 deletions Sources/MaterialShowcase/MaterialShowcaseSequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,59 +9,59 @@
import Foundation

public class MaterialShowcaseSequence {

var showcaseArray : [MaterialShowcase] = []
var currentCase : Int = 0
var key : String?

public init() { }

public func temp(_ showcase: MaterialShowcase) -> MaterialShowcaseSequence {
showcaseArray.append(showcase)
return self
}
public func start() {
guard !getUserState(key: self.key) else {
return
var showShadow: Bool = true
var showcaseArray : [MaterialShowcase] = []
var currentCase : Int = 0
var key : String?

public init() { }

public func temp(_ showcase: MaterialShowcase) -> MaterialShowcaseSequence {
showcaseArray.append(showcase)
return self
}
showcaseArray.first?.show(completion: increase)
}
func increase() -> Void {
self.currentCase += 1
}

/// Set user show retry
public func setKey(key : String? = nil) -> MaterialShowcaseSequence {
guard key != nil else {
return self
public func start() {
guard !getUserState(key: self.key) else {
return
}
showcaseArray.first?.show(hasShadow: showShadow, completion: increase)
}
self.key = key
return self
}

/// Remove user state
public func removeUserState(key : String = MaterialKey._default.rawValue) {
UserDefaults.standard.removeObject(forKey: key)
}
/// Remove user state
func getUserState(key : String?) -> Bool {
guard key != nil else {
return false
func increase() -> Void {
self.currentCase += 1
}
return UserDefaults.standard.bool(forKey: key!)
}

public func showCaseWillDismis() {
guard self.showcaseArray.count > currentCase else {
//last index
guard self.key != nil else {
return
}
UserDefaults.standard.set(true, forKey: key!)
return

/// Set user show retry
public func setKey(key : String? = nil) -> MaterialShowcaseSequence {
guard key != nil else {
return self
}
self.key = key
return self
}
showcaseArray[currentCase].show(completion: self.increase)
}


/// Remove user state
public func removeUserState(key : String = MaterialKey._default.rawValue) {
UserDefaults.standard.removeObject(forKey: key)
}
/// Remove user state
func getUserState(key : String?) -> Bool {
guard key != nil else {
return false
}
return UserDefaults.standard.bool(forKey: key!)
}

public func showCaseWillDismis() {
guard self.showcaseArray.count > currentCase else {
//last index
guard self.key != nil else {
return
}
UserDefaults.standard.set(true, forKey: key!)
return
}
showcaseArray[currentCase].show(hasShadow: showShadow, completion: self.increase)
}

}

0 comments on commit 786f142

Please sign in to comment.