宽窄优行-由【嘉易行】项目成品而来
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//
//  EKAttributes+Presets.swift
//  SwiftEntryKit
//
//  Created by Daniel Huri on 4/23/18.
//
 
import Foundation
 
public extension EKAttributes {
    
    /** Default attributes - Can be mutated according to the hosting application theme */
    static var `default` = EKAttributes()
    
    /** Toast preset - The frame fills margins and safe area is filled with background view */
    static var toast: EKAttributes {
        var attributes = EKAttributes()
        attributes.positionConstraints = .fullWidth
        attributes.positionConstraints.safeArea = .empty(fillSafeArea: true)
        attributes.windowLevel = .statusBar
        attributes.scroll = .edgeCrossingDisabled(swipeable: true)
        attributes.popBehavior = .animated(animation: .translation)
        return attributes
    }
    
    /** Float preset - The frame is margined and the safe area is left cleared */
    static var float: EKAttributes {
        var attributes = EKAttributes()
        attributes.positionConstraints = .float
        attributes.roundCorners = .all(radius: 10)
        attributes.positionConstraints.safeArea = .empty(fillSafeArea: false)
        attributes.windowLevel = .statusBar
        return attributes
    }
    
    /** Preset for top float entry */
    static var topFloat: EKAttributes {
        var attributes = float
        attributes.position = .top
        return attributes
    }
    
    /** Preset for a bottom float entry */
    static var bottomFloat: EKAttributes {
        var attributes = float
        attributes.position = .bottom
        return attributes
    }
    
    /** Preset for a center float entry */
    static var centerFloat: EKAttributes {
        var attributes = float
        attributes.position = .center
        return attributes
    }
    
    /** Preset for a bottom toast entry */
    static var bottomToast: EKAttributes {
        var attributes = toast
        attributes.position = .bottom
        return attributes
    }
    
    /** Preset for a top toast entry */
    static var topToast: EKAttributes {
        var attributes = toast
        attributes.position = .top
        return attributes
    }
    
    /** Preset for a top note entry */
    static var topNote: EKAttributes {
        var attributes = topToast
        attributes.scroll = .disabled
        attributes.windowLevel = .normal
        attributes.entryInteraction = .absorbTouches
        return attributes
    }
    
    /** Preset for a bottom note entry */
    static var bottomNote: EKAttributes {
        var attributes = bottomToast
        attributes.scroll = .disabled
        attributes.windowLevel = .normal
        attributes.entryInteraction = .absorbTouches
        return attributes
    }
    
    /** Preset for a status bar entry - appears on top of the status bar */
    static var statusBar: EKAttributes {
        var attributes = topToast
        attributes.windowLevel = .statusBar
        attributes.entryInteraction = .absorbTouches
        attributes.positionConstraints.safeArea = .overridden
        return attributes
    }
}