-
Notifications
You must be signed in to change notification settings - Fork 112
/
Element.swift
66 lines (53 loc) · 2.1 KB
/
Element.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
//
// Element.swift
// LiveSnapshot
//
// Created by Indragie Karunaratne on 3/30/19.
// Copyright © 2019 Indragie Karunaratne. All rights reserved.
//
import Foundation
import CoreGraphics
/// Provides identifying information for an element that is displayed in the
/// view debugger.
@objc(IAVDElementLabel) public final class ElementLabel: NSObject {
/// Classification for an element that determines how it is represented
/// in the view debugger.
@objc(IAVDElementClassification) public enum Classification: Int {
/// An element of normal importance.
case normal
/// An element of higher importance that is highlighted
case important
}
/// A human readable name for the element.
@objc public let name: String?
/// Classification for an element that determines how it is represented
/// in the view debugger.
@objc public let classification: Classification
/// Constructs a new `Element`
///
/// - Parameters:
/// - name: A human readable name for the element
/// - classification: Classification for an element that determines how it
/// is represented in the view debugger.
@objc public init(name: String?, classification: Classification = .normal) {
self.name = name
self.classification = classification
}
}
/// A UI element that can be snapshotted.
@objc(IAVDElement) public protocol Element {
/// Identifying information for the element, like its name and classification.
var label: ElementLabel { get }
/// A shortened description of the element.
var shortDescription: String { get }
/// The full length description of the element.
var description: String { get }
/// The frame of the element in its parent's coordinate space.
var frame: CGRect { get }
/// Whether the element is hidden from view or not.
var isHidden: Bool { get }
/// A snapshot image of the element in its current state.
var snapshotImage: CGImage? { get }
/// The child elements of the element.
var children: [Element] { get }
}