-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBlob.swift
55 lines (47 loc) · 1.56 KB
/
Blob.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
import SwiftUI
struct Blob {
struct Title: View {
let title: LocalizedStringKey
let action: () -> Void
var body: some View {
_Blob(content: Text(title)
.font(.footnote)
.bold(),
action: action)
}
}
struct Icon: View {
let icon: String
let action: () -> Void
var body: some View {
_Blob(content:
Image(systemName: icon)
.font(Font.headline.bold()), action: action)
}
}
}
private struct _Blob<Content>: View where Content : View {
let content: Content
let action: () -> Void
var body: some View {
Button(action: action) {
EmptyView()
}.buttonStyle(Style { pressed in
ZStack {
Circle()
.frame(width: 45, height: 45)
.shadow(color: .init(.systemBackground), radius: 2, x: pressed ? 0 : -2, y: pressed ? 0 : -2)
.shadow(color: .init(.systemBackground), radius: 3, x: pressed ? 0 : 3, y: pressed ? 0 : 3)
.foregroundColor(pressed ? .pink : .init(.secondarySystemBackground))
self.content
.foregroundColor(pressed ? .init(.systemBackground) : .pink)
}
})
}
}
private struct Style<Content>: ButtonStyle where Content : View {
var hover: (Bool) -> Content
func makeBody(configuration: Configuration) -> some View {
hover(configuration.isPressed)
}
}