1
+ import FioriSwiftUICore
1
2
import Foundation
2
3
import SwiftUI
3
4
@@ -12,7 +13,98 @@ struct FioriButtonContentView: View {
12
13
NavigationLink ( " Button In List - Multiple Lines " , destination: LazyView ( FioriButtonInListMultipleLineExample ( ) ) )
13
14
NavigationLink ( " Custom Button " , destination: LazyView ( FioriButtonCustomButtonExample ( ) ) )
14
15
NavigationLink ( " In-Place Loading Button " , destination: LazyView ( InPlaceLoadingContentView ( ) ) )
16
+ NavigationLink ( " Misc Tests " , destination: LazyView ( MiscTestsView ( ) ) )
15
17
}
16
18
. navigationTitle ( " FioriButton " )
17
19
}
18
20
}
21
+
22
+ typealias Action = ( ) -> Void
23
+
24
+ struct ButtonView : View {
25
+ @Environment ( \. isInMenu) private var isInMenu
26
+
27
+ var title : String
28
+ var action : Action
29
+ init ( title: String , action: @escaping Action ) {
30
+ self . title = title
31
+ self . action = action
32
+ }
33
+
34
+ var body : some View {
35
+ FioriButton { _ in
36
+ print ( " ButtonView \" \( self . title) \" tappeded, isInMenu: \( self . isInMenu) " )
37
+ if self . isInMenu {
38
+ self . action ( )
39
+ }
40
+ } label: { _ in
41
+ Text ( self . title)
42
+ } . highPriorityGesture ( TapGesture ( ) . onEnded {
43
+ print ( " ButtonView \" \( self . title) \" tapped and triggered highPriorityGesture(TapGesture()), isInMenu: \( self . isInMenu) " )
44
+ if !self . isInMenu {
45
+ self . action ( )
46
+ }
47
+ } )
48
+ }
49
+ }
50
+
51
+ struct MiscTestsView : View {
52
+ var body : some View {
53
+ List {
54
+ ButtonView ( title: " Button " ) {
55
+ print ( " ButtonView action called " )
56
+ }
57
+
58
+ Menu {
59
+ ButtonView ( title: " Button in a Menu " ) {
60
+ print ( " ButtonView action called " )
61
+ } . environment ( \. isInMenu, true )
62
+ } label: {
63
+ Text ( " Menu Button Test " )
64
+ }
65
+
66
+ VStack ( alignment: . leading, spacing: 0 ) {
67
+ Card {
68
+ Text ( " Title " )
69
+ } subtitle: {
70
+ Text ( " Subtitle that goes to multiple lines before truncating just like that " )
71
+ } icons: {
72
+ Image ( systemName: " exclamationmark.triangle.fill " )
73
+ . font ( . fiori( forTextStyle: . subheadline) )
74
+ . foregroundColor ( . preferredColor( . negativeLabel) )
75
+ Image ( systemName: " paperclip " )
76
+ . font ( . fiori( forTextStyle: . subheadline) )
77
+ . foregroundColor ( . preferredColor( . quaternaryLabel) )
78
+ Text ( " 1 " )
79
+ . font ( . fiori( forTextStyle: . subheadline) )
80
+ . foregroundColor ( . preferredColor( . quaternaryLabel) )
81
+ } headerAction: {
82
+ ButtonView ( title: " Button in the card " ) {
83
+ print ( " ButtonView action called " )
84
+ }
85
+ } counter: {
86
+ Text ( " 1 of 3 " )
87
+ }
88
+
89
+ . onTapGesture {
90
+ print ( " Card tapped " )
91
+ }
92
+
93
+ CardFooter {
94
+ ButtonView ( title: " Primary " ) {
95
+ print ( " ButtonView action called " )
96
+ }
97
+ } secondaryAction: {
98
+ ButtonView ( title: " Secondary " ) {
99
+ print ( " ButtonView action called " )
100
+ }
101
+ } tertiaryAction: {
102
+ ButtonView ( title: " Tertiary " ) {
103
+ print ( " ButtonView action called " )
104
+ }
105
+ }
106
+ }
107
+ }
108
+ . listRowSpacing ( 16 )
109
+ }
110
+ }
0 commit comments