-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathenums.swift
85 lines (73 loc) · 1.72 KB
/
enums.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
enum CompassPoint {
case north
case south
case east
case west
}
private enum Planet: Equatable {
case mercury, venus, earth
case mars, jupiter, saturn, uranus, neptune
}
enum Barcode {
case upc(Int, Int, Int, Int)
case qrCode(named: String)
case empty
}
// Usage
switch enumValue {
case .resetPasswordSendEmail:
return (category: "ResetPassword", name: "sendEmail", label: nil)
case .paymentSelectorOpen(_, let tenant, _, let option):
return (category: "PaymentSelector", name: "open", label: "\(tenant.name) - \(option.duration)min")
}
switch exception {
case .qrCode(_):
if let message = serverMessage {
trackError(name: name, message: message)
} else {
trackError(name: name, message: R.string.localizable.network_error())
}
default:
trackError(name: "generic", message: R.string.localizable.generic_error())
}
public enum SDKException: Error {
case notFound
case unauthorized
case network(HttpResponse, Error?)
}
public enum PaymentMethodType: String, Equatable {
case direct = "DIRECT", creditCard = "CREDIT_CARD"
}
enum AnimationLength {
case shot
case long
var duration: Double {
switch self {
case .shot:
return 2
case .long:
return 5.0
}
}
func getDuration() -> Double {
return self.duration
}
}
enum AnimationLengthAdvanced {
case shot
case long
case custom(Double)
var duration: Double {
switch self {
case .shot:
return 2
case .long:
return 5.0
case .custom(let duration):
return duration
}
}
func getDuration() -> Double {
return self.duration
}
}