-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path07-Decoration.swift
47 lines (42 loc) · 1.15 KB
/
07-Decoration.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
//
// 07-Decoration.swift
// Example
//
// Created by linhey on 1/3/25.
//
import SectionUI
import SwiftUI
import Combine
/**
装饰视图
*/
struct DecorationView: View {
@State
var section = ColorCell
.wrapperToSingleTypeSection()
.setSectionStyle { section in
section.sectionInset = .init(top: 10, left: 10, bottom: 10, right: 10)
}
.cellSafeSize(.fraction(0.25), transforms: .height(asRatioOfWidth: 1))
.set(decoration: TextReusableView.self, model: .init(text: "decoration", color: .red)) { decoration in
decoration.zIndex = 1
decoration.onAction(.willDisplay) { context in
context.view.backgroundColor = .red.withAlphaComponent(0.7)
context.view.titleLabel.font = .systemFont(ofSize: 60, weight: .bold)
}
}
var body: some View {
SKPreview.sections {
section
}
.task {
section.config(models: (0...50).map({ idx in
.init(text: idx.description, color: nil)
}))
}
.ignoresSafeArea()
}
}
#Preview {
DecorationView()
}