Skip to content

Commit aaed614

Browse files
committed
Add a toolbar playground covering each placement
1 parent 2cf1f5c commit aaed614

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#if canImport(AndroidSwiftUI)
2+
import AndroidSwiftUI
3+
#else
4+
import SwiftUI
5+
#endif
6+
7+
struct ToolbarPlayground: View {
8+
9+
@State private var score = 0
10+
@State private var principalTitle = false
11+
12+
var body: some View {
13+
ScrollView {
14+
VStack(alignment: .leading, spacing: 12) {
15+
Text("Score: \(score)")
16+
Text("Save adds 1, Flag adds 10, the bottom action adds 100.")
17+
Button(principalTitle ? "Use the plain title" : "Use a principal title") {
18+
principalTitle.toggle()
19+
}
20+
}
21+
.padding()
22+
}
23+
.navigationTitle("Toolbar")
24+
.toolbar {
25+
ToolbarItem(placement: .navigationBarLeading) {
26+
Button("Flag") { score += 10 }
27+
}
28+
ToolbarItem(placement: .navigationBarTrailing) {
29+
Button("Save") { score += 1 }
30+
}
31+
if principalTitle {
32+
ToolbarItem(placement: .principal) {
33+
Text("Principal")
34+
}
35+
}
36+
ToolbarItem(placement: .bottomBar) {
37+
Button("Bottom action") { score += 100 }
38+
}
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)