@@ -37,19 +37,6 @@ public struct SupportDocsView: View {
3737 This is only for SwiftUI -- You don't need to do this in UIKit. As long as you set `options.navigationBar.dismissButtonTitle = "Dismiss"`, SupportDocs will dismiss itself.
3838 */
3939 public init ( dataSourceURL: URL , options: SupportOptions = SupportOptions ( ) , isPresented: Binding < Bool > ? = nil ) {
40-
41- /**
42- The custom `NavigationConfigurator` modifier only works for iOS 14 and above, so for lower versions set `UINavigationBar.appearance()` instead.
43- */
44- if #available( iOS 14 . 0 , * ) { } else {
45- let navBarAppearance = UINavigationBarAppearance ( )
46- navBarAppearance. titleTextAttributes = [ . foregroundColor: options. navigationBar. titleColor]
47- navBarAppearance. largeTitleTextAttributes = [ . foregroundColor: options. navigationBar. titleColor]
48- navBarAppearance. backgroundColor = options. navigationBar. backgroundColor
49- UINavigationBar . appearance ( ) . scrollEdgeAppearance = navBarAppearance
50- UINavigationBar . appearance ( ) . standardAppearance = navBarAppearance
51- UINavigationBar . appearance ( ) . tintColor = options. navigationBar. buttonTintColor
52- }
5340 self . dataSourceURL = dataSourceURL
5441 self . options = options
5542 self . isPresented = isPresented
@@ -111,43 +98,66 @@ public struct SupportDocsView: View {
11198 */
11299 @State internal var sections : [ SupportSection ] = [ SupportSection] ( )
113100
101+ /**
102+ Reference of the search bar and its delegate.
103+ */
104+ @ObservedObject var searchBarConfigurator = SearchBarConfigurator ( )
105+
114106 public var body : some View {
115107 NavigationView {
116- Group {
108+ ZStack {
117109 if isDownloadingJSON {
118110
119111 /// Show the loading spinner if JSON is downloading.
120112 ActivityIndicator ( isAnimating: $isDownloadingJSON, style: options. other. activityIndicatorStyle)
121113 } else {
114+
122115 List {
123116
124117 /// First, display the titles of your documents.
125- ForEach ( sections) { section in
118+ ForEach (
119+
120+ /// Filter the sections. Display only those that contain documents where their titles contain the search bar's text.
121+ sections. filter { section in
122+ return searchBarConfigurator. searchText. isEmpty || section. supportItems. contains ( where: {
123+ $0. title. localizedStandardContains ( searchBarConfigurator. searchText)
124+ } )
125+ }
126+ ) { section in
126127 Section ( header: Text ( section. name) ) {
127- ForEach ( section. supportItems) { item in
128+ ForEach (
129+
130+ /// Filter the documents in each section.
131+ section. supportItems. filter { item in
132+ return searchBarConfigurator. searchText. isEmpty || item. title. localizedStandardContains ( searchBarConfigurator. searchText)
133+ }
134+ ) { item in
128135 SupportItemRow (
129136 title: item. title,
130137 titleColor: section. color,
131138 url: URL ( string: item. url) ?? options. other. error404,
132139 progressBarOptions: options. progressBar
133140 )
141+ . animation ( nil )
134142 }
135143 }
136144 . displayTextAsConfigured ( ) /// Prevent default all-caps behavior if possible (iOS 14 and above).
137145 }
138146
139147 /// Then, display the footer. Customize this inside `options.other.footer`.
140148 options. other. footer
141- . listRowInsets ( EdgeInsets ( ) )
142- . frame ( maxWidth: . infinity, minHeight: 60 )
143- . background ( Color ( UIColor . systemGroupedBackground) )
149+ . listRowInsets ( EdgeInsets ( ) )
150+ . frame ( maxWidth: . infinity, minHeight: 60 )
151+ . background ( Color ( UIColor . systemGroupedBackground) )
152+
144153 }
145154 . listStyle ( for: options. listStyle) /// Set the `listStyle` of your selection.
155+ . transition ( . opacity) /// Fade the List in once the JSON loads.
156+
146157 }
147158 }
148- . transition ( . opacity) /// Fade it in once the JSON loads.
149159 . navigationBarTitle ( Text ( options. navigationBar. title) , displayMode: . large) /// Set your title.
150- . configureNavigationBarIfAvailable ( navigationOptions : options. navigationBar )
160+ . configureBar ( for : options, searchBarConfigurator : searchBarConfigurator )
151161
152162 /**
153163 If you have a dismiss button, display it.
0 commit comments