FUISearchController

@MainActor
open class FUISearchController : UISearchController
extension FUISearchController: UISearchBarDelegate
extension FUISearchController: UIBarPositioningDelegate
extension FUISearchController: UISearchResultsUpdating
extension FUISearchController: SFSpeechRecognizerDelegate
extension FUISearchController: UIEditMenuInteractionDelegate
extension FUISearchController: FUIBarcodeScanViewControllerDelegate

Fiori style UISearchController. The only difference between FUISearchController and regular UISearchController is the searchBar. FUISearchController‘s searchBar is FUISearchBar.

Developer can add a FUIBarcodeScanner to this FUISearchBar by setting the isBarcodeScannerEnabled property of the FUISearchBar to true. A barcode scanner icon will be displayed at the bookmark icon location of the search bar.

A barcode scanner view will be displayed when the barcode scanner icon is tapped.

Developer can turn on speech recognition by setting the isSpeechRecognizerEnabled property of the FUISearchBar to true. A speech icon will be displayed near the bookmark icon in the search bar.

An interaction menu will be displayed when the speech icon is tapped.

For iOS 11, it is recommended to set the FUISearchController to navigationItem, instead of the table view header for iOS 10.

Here is a sample code snippet.

// Instantiate an FUISearchController and configure its properties
searchController = FUISearchController(searchResultsController: nil)
searchController.searchResultsUpdater = self
searchController.hidesNavigationBarDuringPresentation = true
searchController.searchBar.placeholderText = "Search The List"

// Adding barcode scanner to this search bar
searchController.searchBar.isBarcodeScannerEnabled = true
searchController.searchBar.barcodeScanner?.scanMode = .EAN_UPC
searchController.searchBar.barcodeScanner?.scanResultTransformer = { (scanString) -> String in
return scanString.uppercased()
}
// Adding speech recognizer to this search bar. The speech recognizer and the barcode scanner are mutually exclusive.
searchController.searchBar.isSpeechRecognizerEnabled = true

navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = false


Theming


fdlFUISearchController_searchBar {
bar-tint-color: @line;
background-color: @primary1_darkBackground;
background-tint-color: @tintColorDark;
}

  • Indicates the state of the current search. The default value is .initial.

    Declaration

    Swift

    @MainActor
    public var searchStatus: FUISearchStatus { get }
  • Invoked when the state of the search changes

    Declaration

    Swift

    @MainActor
    public var searchStatusChangedClosure: ((FUISearchStatus) -> Void)?
  • Displays an icon in the menu to indicate that the speech recognition is in progress on the menu.

    Declaration

    Swift

    @MainActor
    public var menuImage: UIImage?
  • Indicates whether the speech recognition is in progress. The default value is false.

    Declaration

    Swift

    @MainActor
    public var isSpeeching: Bool { get }
  • Search bar of the search controller. When instantiating the FUISearchController programmatically, a default FUISearchBar is initialized automatically and can be used directly. The developer should set a reference to an @IBOutlet, if adding a search bar to their view in Interface Builder.

    Declaration

    Swift

    @MainActor
    override open var searchBar: FUISearchBar { get }
  • This is the developer implementation of the handler when the scan button is tapped.

    If the value is set to nil, the default barcode scanner will be used.

    Declaration

    Swift

    @MainActor
    public var customScanHandler: ((UISearchBar) -> Void)?
  • Handler for BarcodeScanner and SpeechRecognition button (‘Bookmark button’) click

    Important

    Because the presentation of the view controller for barcode scanning is invoked internally when this method is called, this method will be invoked on the delegate only after the presentation of the view controller is completed.

    Declaration

    Swift

    @MainActor
    public func searchBarBookmarkButtonClicked(_ searchBar: UISearchBar)

    Parameters

    searchBar

    calling UISearchBar

  • Enable the built-in barcode scanner in Search Bar

    Declaration

    Swift

    @MainActor
    public func showDefaultBarcodeScanner()
  • Implement this method on your manual bar delegate when not managed by a UIKit controller. UINavigationBar and UISearchBar default to UIBarPositionTop, UIToolbar defaults to UIBarPositionBottom. This message will be sent when the bar moves to a window.

    Declaration

    Swift

    @MainActor
    public func position(for bar: UIBarPositioning) -> UIBarPosition