-
Notifications
You must be signed in to change notification settings - Fork 0
/
IconSetPreview.swift
47 lines (42 loc) · 1.08 KB
/
IconSetPreview.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
import SwiftUI
struct IconSetPreview: View {
let iconSet: IconSet?
var body: some View {
Group {
if let iconSet = iconSet {
ScrollView(.vertical) {
VStack {
ForEach(iconSet.assets, id: \.properties.id) { properties, image in
VStack {
Image(nsImage: NSImage(cgImage: image, size: .zero))
.resizable()
.aspectRatio(contentMode: .fit)
.frame(maxWidth: properties.size.width, maxHeight: properties.size.height)
Text(verbatim: "\(properties.idiom.rawValue), \(properties.userFacingSize)")
}
}
}
.animation(.easeInOut)
.frame(maxWidth: .infinity)
.padding()
}
} else {
Text("Preview")
.opacity(0.5)
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
.background(Color(.textBackgroundColor))
.frame(idealWidth: 200)
}
}
private extension AssetProperties {
var userFacingSize: String {
"\(widthString)×\(heightString)\(scale.suffix)"
}
}
struct IconSetPreview_Previews: PreviewProvider {
static var previews: some View {
IconSetPreview(iconSet: nil)
}
}