-
Notifications
You must be signed in to change notification settings - Fork 112
/
Snapshot.swift
48 lines (39 loc) · 1.6 KB
/
Snapshot.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
//
// Snapshot.swift
// InAppViewDebugger
//
// Created by Indragie Karunaratne on 3/31/19.
// Copyright © 2019 Indragie Karunaratne. All rights reserved.
//
import Foundation
import CoreGraphics
/// A snapshot of the UI element tree in its current state.
@objc(IAVDSnapshot) public final class Snapshot: NSObject {
/// Unique identifier for the snapshot.
@objc public let identifier = UUID().uuidString
/// Identifying information for the element, like its name and classification.
@objc public let label: ElementLabel
/// The frame of the element in its parent's coordinate space.
@objc public let frame: CGRect
/// Whether the element is hidden from view or not.
@objc public let isHidden: Bool
/// A snapshot image of the element in its current state.
@objc public let snapshotImage: CGImage?
/// The child snapshots of the snapshot (one per child element).
@objc public let children: [Snapshot]
/// The element used to create the snapshot.
@objc public let element: Element
/// Constructs a new `Snapshot`
///
/// - Parameter element: The element to construct the snapshot from. The
/// data stored in the snapshot will be the data provided by the element
/// at the time that this constructor is called.
@objc public init(element: Element) {
self.label = element.label
self.frame = element.frame
self.isHidden = element.isHidden
self.snapshotImage = element.snapshotImage
self.children = element.children.map { Snapshot(element: $0) }
self.element = element
}
}