-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day14-UIBlurView.swift
115 lines (99 loc) · 3.12 KB
/
Day14-UIBlurView.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// credit to Jordan Singer
// link: https://gist.github.com/jordansinger/87497bb3ed7e663ddacdbc9c9829be69
import SwiftUI
import PlaygroundSupport
struct AppleTV: View {
var body: some View {
ZStack {
Color.gray
ControlCenter()
}
}
}
struct ControlCenter: View {
var body: some View {
VStack(spacing: 16) {
HStack {
Spacer()
VStack(alignment: .trailing) {
Text("10:03")
.font(.system(size: 48, weight: .medium))
Text("Saturday, August 21")
}
}
HStack {
VStack {
Image(systemName: "person.crop.circle.fill")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 64, height: 64)
.foregroundColor(.secondary)
Text("Gengis Khan")
}
Spacer()
}.padding(.horizontal)
Module(icon: "circle.bottomthird.split", title: "Sleep", subtitle: "All connected devices")
Module(icon: "music.note.list", title: "Not Playing")
HStack {
Icon(icon: "house")
Spacer()
Icon(icon: "airplayaudio")
Spacer()
Icon(icon: "magnifyingglass")
}
}
.padding()
.frame(width: 375)
.background(Blur(style: .systemMaterial))
.cornerRadius(32)
}
}
struct Icon: View {
var icon: String
var body: some View {
ZStack {
RoundedRectangle(cornerRadius: 24)
.foregroundColor(Color(UIColor.secondarySystemBackground))
Image(systemName: icon)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 36, height: 36)
}.frame(width: 96, height: 96)
}
}
struct Module: View {
var icon: String
var title: String
var subtitle: String?
var body: some View {
HStack(spacing: 16) {
Image(systemName: icon)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 40, height: 48)
.padding(8)
VStack(alignment: .leading, spacing: 2) {
Text(title)
.font(.system(size: 24, weight: .medium))
if subtitle != nil {
Text(subtitle ?? "")
.foregroundColor(.secondary)
}
}
Spacer()
}
.padding()
.background(Color(UIColor.secondarySystemBackground))
.cornerRadius(24)
}
}
struct Blur: UIViewRepresentable {
var style: UIBlurEffect.Style
func makeUIView(context: Context) -> UIVisualEffectView {
return UIVisualEffectView(effect: UIBlurEffect(style: style))
}
func updateUIView(_ uiView: UIVisualEffectView, context: Context) {
uiView.effect = UIBlurEffect(style: style)
}
}
PlaygroundPage.current.setLiveView(AppleTV())