forked from IBAnimatable/IBAnimatable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BorderType.swift
executable file
·49 lines (42 loc) · 938 Bytes
/
BorderType.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
//
// BorderType.swift
// IBAnimatable
//
// Created by Tom Baranes on 13/01/2017.
// Copyright © 2017 IBAnimatable. All rights reserved.
//
import Foundation
public enum BorderType: IBEnum {
case solid
case dash(dashLength: Int, spaceLength: Int)
case none
}
extension BorderType {
public init(string: String?) {
guard let string = string else {
self = .none
return
}
let (name, params) = AnimationType.extractNameAndParams(from: string)
switch name {
case "solid":
self = .solid
case "dash":
self = .dash(dashLength: params[safe: 0]?.toInt() ?? 1, spaceLength: params[safe: 1]?.toInt() ?? 1)
default:
self = .none
}
}
}
extension BorderType: Equatable {
}
public func == (lhs: BorderType, rhs: BorderType) -> Bool {
switch (lhs, rhs) {
case (.solid, .solid):
return true
case (.dash, .dash):
return true
default:
return false
}
}