Skip to content

Commit 41d7180

Browse files
committed
Simplified example app
1 parent ae89966 commit 41d7180

File tree

1 file changed

+60
-55
lines changed
  • Example/CodeEditSourceEditorExample/CodeEditSourceEditorExample/Views

1 file changed

+60
-55
lines changed

Example/CodeEditSourceEditorExample/CodeEditSourceEditorExample/Views/ContentView.swift

Lines changed: 60 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -32,66 +32,71 @@ struct ContentView: View {
3232
}
3333

3434
var body: some View {
35-
VStack {
36-
CodeEditSourceEditor(
37-
$document.text,
38-
language: language,
39-
theme: theme,
40-
font: font,
41-
tabWidth: 4,
42-
lineHeight: 1.2,
43-
wrapLines: wrapLines,
44-
cursorPositions: $cursorPositions,
45-
useThemeBackground: true,
46-
highlightProviders: [treeSitterClient],
47-
useSystemCursor: useSystemCursor
48-
)
49-
.safeAreaInset(edge: .bottom, spacing: 0) {
50-
VStack(spacing: 0) {
51-
Divider()
52-
HStack {
53-
Toggle("Wrap Lines", isOn: $wrapLines)
54-
.toggleStyle(.button)
55-
.buttonStyle(.accessoryBar)
56-
if #available(macOS 14, *) {
57-
Toggle("Use System Cursor", isOn: $useSystemCursor)
58-
.toggleStyle(.button)
59-
.buttonStyle(.accessoryBar)
60-
} else {
61-
Toggle("Use System Cursor", isOn: $useSystemCursor)
62-
.disabled(true)
63-
.help("macOS 14 required")
64-
.toggleStyle(.button)
65-
.buttonStyle(.accessoryBar)
66-
}
35+
CodeEditSourceEditor(
36+
$document.text,
37+
language: language,
38+
theme: theme,
39+
font: font,
40+
tabWidth: 4,
41+
lineHeight: 1.2,
42+
wrapLines: wrapLines,
43+
cursorPositions: $cursorPositions,
44+
useThemeBackground: true,
45+
highlightProviders: [treeSitterClient],
46+
useSystemCursor: useSystemCursor
47+
)
48+
.safeAreaInset(edge: .bottom, spacing: 0) {
49+
HStack {
50+
Toggle("Wrap Lines", isOn: $wrapLines)
51+
.toggleStyle(.button)
52+
.buttonStyle(.accessoryBar)
53+
if #available(macOS 14, *) {
54+
Toggle("Use System Cursor", isOn: $useSystemCursor)
55+
.toggleStyle(.button)
56+
.buttonStyle(.accessoryBar)
57+
} else {
58+
Toggle("Use System Cursor", isOn: $useSystemCursor)
59+
.disabled(true)
60+
.help("macOS 14 required")
61+
.toggleStyle(.button)
62+
.buttonStyle(.accessoryBar)
63+
}
6764

68-
Spacer()
69-
Group {
70-
if isInLongParse {
71-
HStack(spacing: 5) {
72-
ProgressView()
73-
.controlSize(.small)
74-
Text("Parsing Document")
75-
}
76-
} else {
77-
Text(getLabel(cursorPositions))
78-
}
65+
Spacer()
66+
Group {
67+
if isInLongParse {
68+
HStack(spacing: 5) {
69+
ProgressView()
70+
.controlSize(.small)
71+
Text("Parsing Document")
7972
}
80-
.foregroundStyle(.secondary)
81-
Divider()
82-
.frame(height: 12)
83-
LanguagePicker(language: $language)
84-
.buttonStyle(.borderless)
73+
} else {
74+
Text(getLabel(cursorPositions))
8575
}
86-
.font(.subheadline)
87-
.fontWeight(.medium)
88-
.controlSize(.small)
89-
.padding(.horizontal, 8)
90-
.frame(height: 28)
9176
}
92-
.background(.bar)
93-
.zIndex(2)
77+
.foregroundStyle(.secondary)
78+
Divider()
79+
.frame(height: 12)
80+
LanguagePicker(language: $language)
81+
.buttonStyle(.borderless)
82+
}
83+
.font(.subheadline)
84+
.fontWeight(.medium)
85+
.controlSize(.small)
86+
.padding(.horizontal, 8)
87+
.frame(height: 28)
88+
.background(.bar)
89+
.overlay(alignment: .top) {
90+
VStack {
91+
Divider()
92+
.overlay {
93+
if colorScheme == .dark {
94+
Color.black
95+
}
96+
}
97+
}
9498
}
99+
.zIndex(2)
95100
.onAppear {
96101
self.language = detectLanguage(fileURL: fileURL) ?? .default
97102
self.theme = colorScheme == .dark ? .dark : .light

0 commit comments

Comments
 (0)