-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTrezorExpandableSection.swift
More file actions
63 lines (55 loc) · 2.13 KB
/
TrezorExpandableSection.swift
File metadata and controls
63 lines (55 loc) · 2.13 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
52
53
54
55
56
57
58
59
60
61
62
63
import SwiftUI
/// Reusable expandable section for the Trezor dashboard.
/// Provides a tappable header with animated expand/collapse of content.
struct TrezorExpandableSection<Content: View>: View {
let title: String
let icon: String
let description: String
@Binding var isExpanded: Bool
@ViewBuilder let content: () -> Content
var body: some View {
VStack(spacing: 0) {
// Tappable header
Button(action: {
withAnimation(.easeInOut(duration: 0.25)) {
isExpanded.toggle()
}
}) {
HStack(spacing: 16) {
Image(systemName: icon)
.font(.system(size: 20))
.foregroundColor(.white)
.frame(width: 40, height: 40)
.background(Color.white.opacity(0.1))
.clipShape(Circle())
VStack(alignment: .leading, spacing: 2) {
Text(title)
.font(.system(size: 16, weight: .semibold))
.foregroundColor(.white)
Text(description)
.font(.system(size: 12))
.foregroundColor(.white.opacity(0.6))
}
Spacer()
Image(systemName: "chevron.down")
.font(.system(size: 14))
.foregroundColor(.white.opacity(0.4))
.rotationEffect(.degrees(isExpanded ? 0 : -90))
.animation(.easeInOut(duration: 0.25), value: isExpanded)
}
}
// Expandable content
if isExpanded {
Divider()
.background(Color.white.opacity(0.1))
.padding(.top, 12)
content()
.padding(.top, 12)
.transition(.opacity)
}
}
.padding(16)
.background(Color.white.opacity(0.05))
.clipShape(RoundedRectangle(cornerRadius: 12))
}
}