# Library Customization ![SupportOptions Graphic](https://raw.githubusercontent.com/aheze/SupportDocs/main/Assets/CustomizableOptions.png) Almost everything in the SupportDocs library can be customized through the `SupportOptions` struct. To use, just make an instance of `SupportOptions` and configure what you want! You can find the declaration for the struct [here](https://github.com/aheze/SupportDocs/blob/main/Sources/SupportDocs/SupportOptions/SupportOptions.swift).
SwiftUI | UIKit |
```Swift import SwiftUI import SupportDocs struct ContentView: View { let dataSource = URL(string: "https://raw.githubusercontent.com/aheze/SupportDocs/DataSource/_data/supportdocs_datasource.json")! let options = SupportOptions( navigationBar: .init( title: "Support" /// Set navigation bar title to "Support" ), listStyle: .insetGroupedListStyle, /// Inset grouped list style (iOS 14+) other: .init( activityIndicatorStyle: UIActivityIndicatorView.Style.large, /// Large loading indicator error404: URL(string: "https://aheze.github.io/SupportDocs/404")! /// Custom 404 page (inside the DataSource branch) ) ) @State var supportDocsPresented: Bool = false var body: some View { Button("Present SupportDocs from SwiftUI!") { supportDocsPresented = true } .sheet(isPresented: $supportDocsPresented, content: { SupportDocsView(dataSource: dataSource, options: options, isPresented: $supportDocsPresented) }) } } ``` | ```Swift class ViewController: UIViewController { @IBOutlet weak var presentButton: UIButton! /// Connect these in the storyboard. @IBAction func presentButtonPressed(_ sender: Any) { let dataSource = URL(string: "https://raw.githubusercontent.com/aheze/SupportDocs/DataSource/_data/supportdocs_datasource.json")! // MARK: - UIKit way to make `SupportOptions` var options = SupportOptions() options.navigationBar.title = "Support" /// Set navigation bar title to "Support" options.listStyle = .insetGroupedListStyle /// Inset grouped list style (iOS 14+) options.other.activityIndicatorStyle = .large /// Large loading indicator options.other.error404 = URL(string: "https://aheze.github.io/SupportDocs/404")! /// Custom 404 page (inside the DataSource branch) let supportDocsViewController = SupportDocsViewController(dataSourceURL: dataSource, options: options) self.present(supportDocsViewController, animated: true, completion: nil) } } ``` |
SwiftUI | Result |
```swift let options = SupportOptions( categories: [ .init( tags: ["boba"], displayName: "Display name is boba", displayColor: UIColor.blue ) ] ) ``` | |
UIKit | |
```swift var options = SupportOptions() let bobaCategory = SupportOptions.Category( tags: ["boba"], displayName: "Display name is boba", displayColor: UIColor.blue ) options.categories = [bobaCategory] ``` |
SwiftUI |
```swift struct SwiftUIExampleView_WithCategories: View { let dataSource = URL(string: "https://raw.githubusercontent.com/aheze/SupportDocs/DataSource/_data/supportdocs_datasource.json")! let options = SupportOptions( categories: [ .init( tags: ["boba"], displayName: "Display name is boba", displayColor: UIColor.blue ) ] ) @State var supportDocsPresented = false var body: some View { Button("Present SupportDocs from SwiftUI!") { supportDocsPresented = true } .sheet(isPresented: $supportDocsPresented, content: { SupportDocsView(dataSource: dataSource, options: options) }) } } ``` |
UIKit |
```swift class UIKitExampleController_WithCategories: UIViewController { /** Connect this inside the storyboard. This is just for demo purposes, so it's not connected yet. */ @IBAction func presentButtonPressed(_ sender: Any) { let dataSource = URL(string: "https://raw.githubusercontent.com/aheze/SupportDocs/DataSource/_data/supportdocs_datasource.json")! var options = SupportOptions() let bobaCategory = SupportOptions.Category( tags: ["boba"], displayName: "Display name is boba", displayColor: UIColor.blue ) options.categories = [bobaCategory] let supportDocsViewController = SupportDocsViewController(dataSource: dataSource, options: options) self.present(supportDocsViewController, animated: true, completion: nil) } } ``` |
SwiftUI | Result |
```swift let options = SupportOptions( categories: [ .init( tags: ["boba"], displayName: "Display name is boba", displayColor: UIColor.blue ), .init( tags: ["fastFood"], displayName: "These aren't really healthy", displayColor: UIColor.red ) ] ) ``` | |
UIKit | |
```swift var options = SupportOptions() let bobaCategory = SupportOptions.Category( tags: ["boba"], displayName: "Display name is boba", displayColor: UIColor.blue ) let fastFoodCategory = SupportOptions.Category( tags: ["fastFood"], displayName: "These aren't really healthy", displayColor: UIColor.red ) options.categories = [bobaCategory, fastFoodCategory] ``` |
SwiftUI |
```swift struct SwiftUIExampleView_WithCategories: View { let dataSource = URL(string: "https://raw.githubusercontent.com/aheze/SupportDocs/DataSource/_data/supportdocs_datasource.json")! let options = SupportOptions( categories: [ .init( tags: ["boba"], displayName: "Display name is boba", displayColor: UIColor.blue ), .init( tags: ["fastFood"], displayName: "These aren't really healthy", displayColor: UIColor.red ) ] ) @State var supportDocsPresented = false var body: some View { Button("Present SupportDocs from SwiftUI!") { supportDocsPresented = true } .sheet(isPresented: $supportDocsPresented, content: { SupportDocsView(dataSource: dataSource, options: options) }) } } ``` |
UIKit |
```swift class UIKitExampleControllerWithCategories: UIViewController { /** Connect this inside the storyboard. This is just for demo purposes, so it's not connected yet. */ @IBAction func presentButtonPressed(_ sender: Any) { let dataSource = URL(string: "https://raw.githubusercontent.com/aheze/SupportDocs/DataSource/_data/supportdocs_datasource.json")! var options = SupportOptions() let bobaCategory = SupportOptions.Category( tags: ["boba"], displayName: "Display name is boba", displayColor: UIColor.blue ) let fastFoodCategory = SupportOptions.Category( tags: ["fastFood"], displayName: "These aren't really healthy", displayColor: UIColor.red ) options.categories = [bobaCategory, fastFoodCategory] let supportDocsViewController = SupportDocsViewController(dataSource: dataSource, options: options) self.present(supportDocsViewController, animated: true, completion: nil) } } ``` |
SwiftUI | Result |
```swift let options = SupportOptions( categories: [ .init( tags: ["boba", "fastFood"], displayName: "Food that tastes great", displayColor: UIColor.orange ) ] ) ``` | |
UIKit | |
```swift var options = SupportOptions() let bobaAndFastFoodCategory = SupportOptions.Category( tags: ["boba", "fastFood"], displayName: "Food that tastes great", displayColor: UIColor.orange ) options.categories = [bobaAndFastFoodCategory] ``` |
SwiftUI |
```swift struct SwiftUIExampleView_WithCategories: View { let dataSource = URL(string: "https://raw.githubusercontent.com/aheze/SupportDocs/DataSource/_data/supportdocs_datasource.json")! let options = SupportOptions( categories: [ .init( tags: ["boba", "fastFood"], displayName: "Food that tastes great", displayColor: UIColor.orange ) ] ) @State var supportDocsPresented = false var body: some View { Button("Present SupportDocs from SwiftUI!") { supportDocsPresented = true } .sheet(isPresented: $supportDocsPresented, content: { SupportDocsView(dataSource: dataSource, options: options) }) } } ``` |
UIKit |
```swift class UIKitExampleController_WithCategories: UIViewController { /** Connect this inside the storyboard. This is just for demo purposes, so it's not connected yet. */ @IBAction func presentButtonPressed(_ sender: Any) { let dataSource = URL(string: "https://raw.githubusercontent.com/aheze/SupportDocs/DataSource/_data/supportdocs_datasource.json")! var options = SupportOptions() let bobaAndFastFoodCategory = SupportOptions.Category( tags: ["boba", "fastFood"], displayName: "Food that tastes great", displayColor: UIColor.orange ) options.categories = [bobaAndFastFoodCategory] let supportDocsViewController = SupportDocsViewController(dataSource: dataSource, options: options) self.present(supportDocsViewController, animated: true, completion: nil) } } ``` |
SwiftUI | Result |
```swift let options = SupportOptions( navigationBar: .init( title: "Custom Nav Title" ) ) ``` | |
UIKit | |
```swift var options = SupportOptions() options.navigationBar.title = "Custom Nav Title" ``` |
SwiftUI | Result |
```swift let options = SupportOptions( navigationBar: .init( title: "Custom Nav Title", titleColor: UIColor.purple ) ) ``` | |
UIKit | |
```swift var options = SupportOptions() options.navigationBar.title = "Custom Nav Title" options.navigationBar.titleColor = UIColor.purple ``` |
`Image` | `Text` |
```Swift AnyView(Image(systemName: "xmark")) /// SF Symbols are best ``` | ```Swift AnyView(Text("I Am Finished")) /// `Text` works just as well ``` |
SwiftUI | Result |
```swift let options = SupportOptions( navigationBar: .init( dismissButtonView: AnyView(Text("I Am Finished")) /// or, AnyView(Image(systemName: "xmark")) ) ) ``` | |
UIKit | |
```swift var options = SupportOptions() options.navigationBar.dismissButtonView = AnyView(Text("I Am Finished")) /// or, AnyView(Image(systemName: "xmark")) ``` |
SwiftUI | Result |
```swift let options = SupportOptions( navigationBar: .init( dismissButtonTitle: "I Am Finished", buttonTintColor: UIColor.green ) ) ``` |
Dismiss button ↓ Back button (after selecting a document) ↓ |
UIKit | |
```swift var options = SupportOptions() options.navigationBar.dismissButtonTitle = "I Am Finished" options.navigationBar.buttonTintColor = UIColor.green ``` |
SwiftUI | Result |
```swift let options = SupportOptions( navigationBar: .init( backgroundColor: UIColor( red: 217 / 255, green: 247 / 255, blue: 255 / 255, alpha: 1 ) ) ) ``` |
Before scrolling ↓ After scrolling ↓ |
UIKit | |
```swift var options = SupportOptions() options.navigationBar.backgroundColor = UIColor( red: 217 / 255, green: 247 / 255, blue: 255 / 255, alpha: 1 ) ``` |
SwiftUI | Result |
```swift let options = SupportOptions( searchBar: .init( placeholder: "Type here to search!" ) ) ``` | |
UIKit | |
```swift var options = SupportOptions() options.searchBar.placeholder = "Type here to search!" ``` |
SwiftUI | Result |
```swift let options = SupportOptions( searchBar: .init( placeholder: "Type here to search!", placeholderColor: UIColor.blue.withAlphaComponent(0.75) ) ) ``` | |
UIKit | |
```swift var options = SupportOptions() options.searchBar.placeholder = "Type here to search!" options.searchBar.placeholderColor = UIColor.blue.withAlphaComponent(0.75) ``` |
SwiftUI | Result |
```swift let options = SupportOptions( searchBar: .init( textColor: UIColor.red ) ) ``` | |
UIKit | |
```swift var options = SupportOptions() options.searchBar.textColor = UIColor.red ``` |
SwiftUI | Result |
```swift let options = SupportOptions( searchBar: .init( tintColor: UIColor.orange ) ) ``` | |
UIKit | |
```swift var options = SupportOptions() options.searchBar.tintColor = UIColor.orange ``` |
SwiftUI | Result |
```swift let options = SupportOptions( searchBar: .init( backgroundColor: UIColor.gray ) ) ``` | |
UIKit | |
```swift var options = SupportOptions() options.searchBar.backgroundColor = UIColor.gray ``` |
SwiftUI | UIKit |
```swift let options = SupportOptions( searchBar: .init( clearButtonMode: .whileEditing ) ) ``` | ```swift var options = SupportOptions() options.searchBar.clearButtonMode = .whileEditing ``` |
SwiftUI | Result |
```swift let options = SupportOptions( progressBar: .init( foregroundColor: UIColor.red ) ) ``` | |
UIKit | |
```swift var options = SupportOptions() options.progressBar.foregroundColor = UIColor.red ``` |
SwiftUI | Result |
```swift let options = SupportOptions( progressBar: .init( foregroundColor: UIColor.red, backgroundColor: UIColor.blue ) ) ``` | |
UIKit | |
```swift var options = SupportOptions() options.progressBar.foregroundColor = UIColor.red options.progressBar.backgroundColor = UIColor.blue ``` |
List Style | Result |
.defaultListStyle |
|
SwiftUI | |
```swift let options = SupportOptions( listStyle: .defaultListStyle ) ``` | |
UIKit | |
```swift var options = SupportOptions() options.listStyle = .defaultListStyle ``` | |
.plainListStyle |
|
SwiftUI | |
```swift let options = SupportOptions( listStyle: .plainListStyle ) ``` | |
UIKit | |
```swift var options = SupportOptions() options.listStyle = .plainListStyle ``` | |
.groupedListStyle |
|
SwiftUI | |
```swift let options = SupportOptions( listStyle: .groupedListStyle ) ``` | |
UIKit | |
```swift var options = SupportOptions() options.listStyle = .groupedListStyle ``` | |
.insetGroupedListStyle |
|
SwiftUI | |
```swift let options = SupportOptions( listStyle: .insetGroupedListStyle ) ``` | |
UIKit | |
```swift var options = SupportOptions() options.listStyle = .insetGroupedListStyle ``` | |
.insetListStyle |
|
SwiftUI | |
```swift let options = SupportOptions( listStyle: .insetListStyle ) ``` | |
UIKit | |
```swift var options = SupportOptions() options.listStyle = .insetListStyle ``` | |
.sidebarListStyle |
|
SwiftUI | |
```swift let options = SupportOptions( listStyle: .sidebarListStyle ) ``` | |
UIKit | |
```swift var options = SupportOptions() options.listStyle = .sidebarListStyle ``` |
SwiftUI | UIKit |
```swift let options = SupportOptions( navigationViewStyle: .defaultNavigationViewStyle ) ``` | ```swift var options = SupportOptions() options.navigationViewStyle = .defaultNavigationViewStyle ``` |
SwiftUI | UIKit |
```swift let options = SupportOptions( other: .init( activityIndicatorStyle: .medium, welcomeView: AnyView(Text("Swipe right")), footer: AnyView(Text("Contact us if you didn't find what you were looking for!")), error404: URL(string: "https://aheze.github.io/SupportDocs/404")! ) ) ``` | ```swift var options = SupportOptions() options.other.activityIndicatorStyle = .medium options.other.welcomeView = AnyView(Text("Swipe right")) options.other.footer = AnyView(Text("Contact us if you didn't find what you were looking for!")) options.other.error404 = URL(string: "https://aheze.github.io/SupportDocs/404")! ``` |