@@ -2,14 +2,36 @@ import SwiftUI
22
33struct SettingsSection < Content: View , Footer: View > : View {
44 let title : String
5+ let showWarning : Bool
56 @ViewBuilder let content : ( ) -> Content
67 @ViewBuilder let footer : ( ) -> Footer
78
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+
817 var body : some View {
918 VStack ( alignment: . leading, spacing: 10 ) {
1019 Text ( title)
1120 . bold ( )
1221 . 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+ }
1335 VStack ( alignment: . leading, spacing: 0 ) {
1436 content ( )
1537 }
@@ -22,8 +44,8 @@ struct SettingsSection<Content: View, Footer: View>: View {
2244}
2345
2446extension 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 ( ) } )
2749 }
2850}
2951
@@ -37,7 +59,7 @@ extension SettingsSection where Footer == EmptyView {
3759 Divider ( )
3860 SettingsLink ( url: " https://example.com " , title: " Example " )
3961 }
40- SettingsSection ( title: " Advanced " ) {
62+ SettingsSection ( title: " Advanced " , showWarning : true ) {
4163 SettingsLink ( url: " https://example.com " , title: " Example " )
4264 } footer: {
4365 Text ( " Footer " )
0 commit comments