@@ -2,14 +2,36 @@ import SwiftUI
2
2
3
3
struct SettingsSection < Content: View , Footer: View > : View {
4
4
let title : String
5
+ let showWarning : Bool
5
6
@ViewBuilder let content : ( ) -> Content
6
7
@ViewBuilder let footer : ( ) -> Footer
7
8
9
+
10
+ init ( title: String , showWarning: Bool = false , @ViewBuilder content: @escaping ( ) -> Content , @ViewBuilder footer: @escaping ( ) -> Footer ) {
11
+ self . title = title
12
+ self . showWarning = showWarning
13
+ self . content = content
14
+ self . footer = footer
15
+ }
16
+
8
17
var body : some View {
9
18
VStack ( alignment: . leading, spacing: 10 ) {
10
19
Text ( title)
11
20
. bold ( )
12
21
. padding ( . horizontal, 10 )
22
+ if showWarning {
23
+ HStack {
24
+ Text ( " GitHub Copilot features are disabled. Please check your subscription to access them. " )
25
+ . foregroundColor ( Color ( " WarningForegroundColor " ) )
26
+ . padding ( 4 )
27
+ Spacer ( )
28
+ }
29
+ . background ( Color ( " WarningBackgroundColor " ) )
30
+ . overlay (
31
+ RoundedRectangle ( cornerRadius: 3 )
32
+ . stroke ( Color ( " WarningStrokeColor " ) , lineWidth: 1 )
33
+ )
34
+ }
13
35
VStack ( alignment: . leading, spacing: 0 ) {
14
36
content ( )
15
37
}
@@ -22,8 +44,8 @@ struct SettingsSection<Content: View, Footer: View>: View {
22
44
}
23
45
24
46
extension SettingsSection where Footer == EmptyView {
25
- init ( title: String , @ViewBuilder content: @escaping ( ) -> Content ) {
26
- self . init ( title: title, content: content, footer: { EmptyView ( ) } )
47
+ init ( title: String , showWarning : Bool = false , @ViewBuilder content: @escaping ( ) -> Content ) {
48
+ self . init ( title: title, showWarning : showWarning , content: content, footer: { EmptyView ( ) } )
27
49
}
28
50
}
29
51
@@ -37,7 +59,7 @@ extension SettingsSection where Footer == EmptyView {
37
59
Divider ( )
38
60
SettingsLink ( url: " https://example.com " , title: " Example " )
39
61
}
40
- SettingsSection ( title: " Advanced " ) {
62
+ SettingsSection ( title: " Advanced " , showWarning : true ) {
41
63
SettingsLink ( url: " https://example.com " , title: " Example " )
42
64
} footer: {
43
65
Text ( " Footer " )
0 commit comments