File tree Expand file tree Collapse file tree 1 file changed +24
-13
lines changed
Source/Yasba/Views/Sieve Script Builder Expand file tree Collapse file tree 1 file changed +24
-13
lines changed Original file line number Diff line number Diff line change @@ -19,14 +19,7 @@ struct SieveScriptBuilderView: View {
1919 Color . primary. colorInvert ( )
2020 . ignoresSafeArea ( )
2121
22- Toolbar (
23- onRender: {
24- renderedScriptText = model. render ( )
25- shouldPresentSheet = true
26- } , onNew: {
27- shouldShowClearConfirmation = true
28- } )
29- . ignoresSafeArea ( )
22+ toolbar
3023
3124 SieveScriptView ( viewModel: model)
3225 . padding ( [ . leading, . top] , 24 )
@@ -62,17 +55,35 @@ struct SieveScriptBuilderView: View {
6255 Text ( " This will remove all commands from the script. This action cannot be undone. " )
6356 }
6457 }
58+
59+ @ViewBuilder
60+ private var toolbar : some View {
61+ Toolbar {
62+ if !model. rowTokens. isEmpty {
63+ ToolbarButton ( icon: " trash " ) {
64+ shouldShowClearConfirmation = true
65+ }
66+ }
67+ ToolbarButton ( icon: " note.text " ) {
68+ renderedScriptText = model. render ( )
69+ shouldPresentSheet = true
70+ }
71+ }
72+ . ignoresSafeArea ( )
73+ }
6574}
6675
67- private struct Toolbar : View {
68- var onRender : ( ) -> Void
69- var onNew : ( ) -> Void
76+ private struct Toolbar < Content: View > : View {
77+ var content : Content
78+
79+ init ( @ViewBuilder content: ( ) -> Content ) {
80+ self . content = content ( )
81+ }
7082
7183 var body : some View {
7284 HStack ( spacing: 32 ) {
7385 Spacer ( )
74- ToolbarButton ( icon: " document.badge.plus " ) { onNew ( ) }
75- ToolbarButton ( icon: " note.text " ) { onRender ( ) }
86+ content
7687 }
7788 . padding ( . trailing, 24 )
7889 . frame ( height: 50 )
You can’t perform that action at this time.
0 commit comments