-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathHwDeviceIllustrations.swift
More file actions
51 lines (45 loc) · 2.14 KB
/
Copy pathHwDeviceIllustrations.swift
File metadata and controls
51 lines (45 loc) · 2.14 KB
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
import SwiftUI
/// Staggered hardware-device hero used by the hardware intro sheet: a Trezor on the left and a
/// blurred Ledger bleeding off the right. Ports bitkit-android's `HwDeviceIllustrations`.
struct HwDeviceIllustrations: View {
/// All measurements are expressed as fractions of the Figma design frame's width, so the hero
/// scales proportionally to whatever width it's given. Each device is rendered at its natural
/// (non-square) aspect ratio; the Trezor's left bleed is baked into the exported asset, while
/// the Ledger is offset to bleed off the right edge.
private enum Layout {
static let referenceWidth: CGFloat = 375
static let proportionalHeight: CGFloat = 256 / referenceWidth
static let trezorProportionalWidth: CGFloat = 172 / referenceWidth
static let ledgerProportionalWidth: CGFloat = 203 / referenceWidth
static let ledgerProportionalX: CGFloat = 172 / referenceWidth
static let proportionalStagger: CGFloat = 11.6 / referenceWidth
}
var body: some View {
GeometryReader { geo in
let width = geo.size.width
let imageHeight = width * Layout.proportionalHeight
let staggerY = width * Layout.proportionalStagger
ZStack {
Image("trezor-cropped")
.resizable()
.scaledToFit()
.frame(width: width * Layout.trezorProportionalWidth, height: imageHeight)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
.offset(y: staggerY)
Image("ledger")
.resizable()
.scaledToFit()
.frame(width: width * Layout.ledgerProportionalWidth, height: imageHeight)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
.offset(x: width * Layout.ledgerProportionalX, y: -staggerY)
}
}
.accessibilityHidden(true)
}
}
#Preview {
HwDeviceIllustrations()
.frame(height: 300)
.background(Color.black)
.preferredColorScheme(.dark)
}