This repository was archived by the owner on Jun 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 312
/
Copy pathStackTransformViewOptions+Layout.swift
106 lines (103 loc) · 3.27 KB
/
StackTransformViewOptions+Layout.swift
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
98
99
100
101
102
103
104
105
106
//
// StackTransformViewOptions+Layout.swift
// CollectionViewPagingLayout
//
// Created by Amir on 28/03/2021.
// Copyright © 2021 Amir Khorsandi. All rights reserved.
//
import UIKit
import Foundation
public extension StackTransformViewOptions {
enum Layout: String, CaseIterable {
case transparent
case perspective
case rotary
case vortex
case reverse
case blur
}
static func layout(_ layout: Layout) -> Self {
switch layout {
case .transparent:
return Self(
scaleFactor: 0.12,
minScale: 0.0,
maxStackSize: 4,
alphaFactor: 0.2,
bottomStackAlphaSpeedFactor: 10,
topStackAlphaSpeedFactor: 0.1,
popAngle: .pi / 10,
popOffsetRatio: .init(width: -1.45, height: 0.3)
)
case .perspective:
return Self(
scaleFactor: 0.1,
minScale: 0.2,
maxStackSize: 6,
spacingFactor: 0.08,
alphaFactor: 0.0,
perspectiveRatio: 0.3,
shadowRadius: 5,
popAngle: .pi / 10,
popOffsetRatio: .init(width: -1.45, height: 0.3),
stackPosition: CGPoint(x: 1, y: 0)
)
case .rotary:
return Self(
scaleFactor: -0.03,
minScale: 0.2,
maxStackSize: 3,
spacingFactor: 0.01,
alphaFactor: 0.1,
shadowRadius: 8,
stackRotateAngel: .pi / 16,
popAngle: .pi / 4,
popOffsetRatio: .init(width: -1.45, height: 0.4),
stackPosition: CGPoint(x: 0, y: 1)
)
case .vortex:
return Self(
scaleFactor: -0.15,
minScale: 0.2,
maxScale: nil,
maxStackSize: 4,
spacingFactor: 0,
alphaFactor: 0.4,
topStackAlphaSpeedFactor: 1,
perspectiveRatio: -0.3,
shadowEnabled: false,
popAngle: .pi,
popOffsetRatio: .zero,
stackPosition: CGPoint(x: 0, y: 1)
)
case .reverse:
return Self(
scaleFactor: 0.1,
maxScale: nil,
maxStackSize: 4,
spacingFactor: 0.08,
shadowRadius: 8,
popAngle: -.pi / 4,
popOffsetRatio: .init(width: 1.45, height: 0.4),
stackPosition: CGPoint(x: -1, y: -0.2),
reverse: true
)
case .blur:
return Self(
scaleFactor: 0.1,
maxScale: nil,
maxStackSize: 7,
spacingFactor: 0.06,
topStackAlphaSpeedFactor: 0.1,
perspectiveRatio: 0.04,
shadowRadius: 8,
popAngle: -.pi / 4,
popOffsetRatio: .init(width: 1.45, height: 0.4),
stackPosition: CGPoint(x: -1, y: 0),
reverse: true,
blurEffectEnabled: true,
maxBlurEffectRadius: 0.08
)
}
}
}