宽窄优行-由【嘉易行】项目成品而来
younger_times
2023-04-06 a1ae6802080a22e6e6ce6d0935e95facb1daca5c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
//  EKAttributes+PopBehavior.swift
//  SwiftEntryKit
//
//  Created by Daniel Huri on 4/26/18.
//
 
import Foundation
 
public extension EKAttributes {
    
    /** Describes the entry behavior when a new entry shows (with equal or higher display-priority) */
    enum PopBehavior {
                
        /** The entry disappears promptly (Does not animates out) when a new one shows */
        case overridden
        
        /** Animate the entry out - The entry rolls out when a new one shows */
        case animated(animation: Animation)
        
        public var isOverriden: Bool {
            switch self {
            case .overridden:
                return true
            case .animated:
                return false
            }
        }
        
        var animation: Animation? {
            switch self {
            case .animated(animation: let animation):
                return animation
            case .overridden:
                return nil
            }
        }
        
        func validate() {
            #if DEBUG
            guard let animation = animation else { return }
            guard animation == .none else { return }
            print("""
            SwiftEntryKit warning: cannot associate value `EKAttributes.Animation()`
            with `EKAttributes.PopBehavior.animated`. This may result in undefined behavior.
            Please use `PopBehavior.overridden` instead.
            """)
            #endif
        }
    }
}