Skip to content

Commit 1051aca

Browse files
referencing section usage
1 parent 9cc2858 commit 1051aca

File tree

1 file changed

+160
-0
lines changed

1 file changed

+160
-0
lines changed
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
import SwiftUI
2+
import gitdiff
3+
4+
struct APIReferenceView: View {
5+
var body: some View {
6+
NavigationView {
7+
List {
8+
Section("Basic Usage") {
9+
CodeExample(
10+
title: "Simple Rendering",
11+
code: """
12+
DiffRenderer(diffText: gitDiffOutput)
13+
"""
14+
)
15+
}
16+
17+
Section("View Modifiers") {
18+
CodeExample(
19+
title: "Theme",
20+
code: """
21+
DiffRenderer(diffText: gitDiff)
22+
.diffTheme(.vsCodeDark)
23+
"""
24+
)
25+
26+
CodeExample(
27+
title: "Line Numbers",
28+
code: """
29+
DiffRenderer(diffText: gitDiff)
30+
.diffLineNumbers(false)
31+
"""
32+
)
33+
34+
CodeExample(
35+
title: "Font Configuration",
36+
code: """
37+
DiffRenderer(diffText: gitDiff)
38+
.diffFont(size: 14, weight: .medium, design: .monospaced)
39+
"""
40+
)
41+
42+
CodeExample(
43+
title: "Line Spacing",
44+
code: """
45+
DiffRenderer(diffText: gitDiff)
46+
.diffLineSpacing(.comfortable)
47+
"""
48+
)
49+
50+
CodeExample(
51+
title: "Combined Modifiers",
52+
code: """
53+
DiffRenderer(diffText: gitDiff)
54+
.diffTheme(.gitlab)
55+
.diffLineNumbers(false)
56+
.diffFont(size: 14)
57+
.diffLineSpacing(.comfortable)
58+
.diffWordWrap(true)
59+
"""
60+
)
61+
}
62+
63+
Section("Configuration Object") {
64+
CodeExample(
65+
title: "Using Configuration",
66+
code: """
67+
let config = DiffConfiguration(
68+
theme: .xcodeDark,
69+
showLineNumbers: true,
70+
fontSize: 14,
71+
lineSpacing: .comfortable
72+
)
73+
74+
DiffRenderer(diffText: gitDiff)
75+
.diffConfiguration(config)
76+
"""
77+
)
78+
79+
CodeExample(
80+
title: "Configuration Builder",
81+
code: """
82+
let config = DiffConfiguration.default
83+
.with(theme: .vsCodeLight)
84+
.withLineNumbers(false)
85+
.withFont(size: 16)
86+
87+
DiffRenderer(diffText: gitDiff)
88+
.diffConfiguration(config)
89+
"""
90+
)
91+
92+
CodeExample(
93+
title: "Preset Configurations",
94+
code: """
95+
// Code Review
96+
DiffRenderer(diffText: gitDiff)
97+
.diffConfiguration(.codeReview)
98+
99+
// Mobile
100+
DiffRenderer(diffText: gitDiff)
101+
.diffConfiguration(.mobile)
102+
103+
// Presentation
104+
DiffRenderer(diffText: gitDiff)
105+
.diffConfiguration(.presentation)
106+
"""
107+
)
108+
}
109+
110+
Section("Custom Theme") {
111+
CodeExample(
112+
title: "Creating Custom Theme",
113+
code: """
114+
let myTheme = DiffTheme(
115+
addedBackground: Color.green.opacity(0.2),
116+
addedText: Color.green,
117+
removedBackground: Color.red.opacity(0.2),
118+
removedText: Color.red,
119+
contextBackground: Color.gray.opacity(0.1),
120+
contextText: Color.primary,
121+
lineNumberBackground: Color.gray.opacity(0.1),
122+
lineNumberText: Color.secondary,
123+
headerBackground: Color.blue.opacity(0.1),
124+
headerText: Color.blue,
125+
fileHeaderBackground: Color.gray.opacity(0.1),
126+
fileHeaderText: Color.primary
127+
)
128+
129+
DiffRenderer(diffText: gitDiff)
130+
.diffTheme(myTheme)
131+
"""
132+
)
133+
}
134+
}
135+
.navigationTitle("API Reference")
136+
.navigationBarTitleDisplayMode(.inline)
137+
}
138+
}
139+
}
140+
141+
struct CodeExample: View {
142+
let title: String
143+
let code: String
144+
145+
var body: some View {
146+
VStack(alignment: .leading, spacing: 8) {
147+
Text(title)
148+
.font(.footnote.bold())
149+
150+
ScrollView(.horizontal, showsIndicators: false) {
151+
Text(code)
152+
.font(.system(.caption, design: .monospaced))
153+
.padding(8)
154+
.background(Color(UIColor.systemGray6))
155+
.cornerRadius(6)
156+
}
157+
}
158+
.padding(.vertical, 4)
159+
}
160+
}

0 commit comments

Comments
 (0)