|
9 | 9 | import Foundation |
10 | 10 |
|
11 | 11 | public class MaterialShowcaseSequence { |
12 | | - |
13 | | - var showcaseArray : [MaterialShowcase] = [] |
14 | | - var currentCase : Int = 0 |
15 | | - var key : String? |
16 | | - |
17 | | - public init() { } |
18 | | - |
19 | | - public func temp(_ showcase: MaterialShowcase) -> MaterialShowcaseSequence { |
20 | | - showcaseArray.append(showcase) |
21 | | - return self |
22 | | - } |
23 | | - public func start() { |
24 | | - guard !getUserState(key: self.key) else { |
25 | | - return |
| 12 | + var showShadow: Bool = false |
| 13 | + var showcaseArray : [MaterialShowcase] = [] |
| 14 | + var currentCase : Int = 0 |
| 15 | + var key : String? |
| 16 | + |
| 17 | + public init() { } |
| 18 | + |
| 19 | + public func temp(_ showcase: MaterialShowcase) -> MaterialShowcaseSequence { |
| 20 | + showcaseArray.append(showcase) |
| 21 | + return self |
26 | 22 | } |
27 | | - showcaseArray.first?.show(completion: increase) |
28 | | - } |
29 | | - func increase() -> Void { |
30 | | - self.currentCase += 1 |
31 | | - } |
32 | | - |
33 | | - /// Set user show retry |
34 | | - public func setKey(key : String? = nil) -> MaterialShowcaseSequence { |
35 | | - guard key != nil else { |
36 | | - return self |
| 23 | + public func start() { |
| 24 | + guard !getUserState(key: self.key) else { |
| 25 | + return |
| 26 | + } |
| 27 | + showcaseArray.first?.show(hasShadow: showShadow, completion: increase) |
37 | 28 | } |
38 | | - self.key = key |
39 | | - return self |
40 | | - } |
41 | | - |
42 | | - /// Remove user state |
43 | | - public func removeUserState(key : String = MaterialKey._default.rawValue) { |
44 | | - UserDefaults.standard.removeObject(forKey: key) |
45 | | - } |
46 | | - /// Remove user state |
47 | | - func getUserState(key : String?) -> Bool { |
48 | | - guard key != nil else { |
49 | | - return false |
| 29 | + func increase() -> Void { |
| 30 | + self.currentCase += 1 |
50 | 31 | } |
51 | | - return UserDefaults.standard.bool(forKey: key!) |
52 | | - } |
53 | | - |
54 | | - public func showCaseWillDismis() { |
55 | | - guard self.showcaseArray.count > currentCase else { |
56 | | - //last index |
57 | | - guard self.key != nil else { |
58 | | - return |
59 | | - } |
60 | | - UserDefaults.standard.set(true, forKey: key!) |
61 | | - return |
| 32 | + |
| 33 | + /// Set user show retry |
| 34 | + public func setKey(key : String? = nil) -> MaterialShowcaseSequence { |
| 35 | + guard key != nil else { |
| 36 | + return self |
| 37 | + } |
| 38 | + self.key = key |
| 39 | + return self |
62 | 40 | } |
63 | | - showcaseArray[currentCase].show(completion: self.increase) |
64 | | - } |
65 | | - |
| 41 | + |
| 42 | + /// Remove user state |
| 43 | + public func removeUserState(key : String = MaterialKey._default.rawValue) { |
| 44 | + UserDefaults.standard.removeObject(forKey: key) |
| 45 | + } |
| 46 | + /// Remove user state |
| 47 | + func getUserState(key : String?) -> Bool { |
| 48 | + guard key != nil else { |
| 49 | + return false |
| 50 | + } |
| 51 | + return UserDefaults.standard.bool(forKey: key!) |
| 52 | + } |
| 53 | + |
| 54 | + public func showCaseWillDismis() { |
| 55 | + guard self.showcaseArray.count > currentCase else { |
| 56 | + //last index |
| 57 | + guard self.key != nil else { |
| 58 | + return |
| 59 | + } |
| 60 | + UserDefaults.standard.set(true, forKey: key!) |
| 61 | + return |
| 62 | + } |
| 63 | + showcaseArray[currentCase].show(hasShadow: showShadow, completion: self.increase) |
| 64 | + } |
| 65 | + |
66 | 66 | } |
67 | 67 |
|
0 commit comments