SettingsButton

open class SettingsButton : FUIMapToolbarButton

FUIMapToolbarSettingsButton inherits from the FUIButton class and is presented within the FUIMapToolbar. It is up to the developer to manage the transition between the presented views (example: legend or the panel container). A sample has been provided to show the presentation and dismissal of the view controller.

Usage


let settingsButton = FUIMapToolbarSettingsButton()
settingsButton.didSelectHandler = { [weak self] button in
   DispatchQueue.main.async {
       let settings = DevMapSettingsViewController()
       settings.dismissButton = button

       let navController = UINavigationController(rootViewController: settings)
       if !(UIDevice.current.userInterfaceIdiom == .phone) {
           settings.modalPresentationStyle = .formSheet
           navController.modalPresentationStyle = .formSheet
           self.present(navController, animated: true, completion: nil)
       } else {
           navController.modalPresentationStyle = .overFullScreen
           let dismissClosure: (() -> Void)? = { [weak self] in
               self.dismiss(animated: true, completion: nil)
           }
           settings.dismissClosure = dismissClosure
           self.present(navController, animated: true, completion: nil)
       }
   }
}

var toolbar = FUIMapToolbar(mapView: mapView)
let data = [settingsButton]
toolbar.items = data

Supplementary Classes

class DevMapSettingsViewController: UITableViewController {

   var dismissButton: FUIButton?

   var dataSource: [String] = {
       let mapViewOptions = "Map View Options"
       let featureLayersOptions = "Feature Layers Options"
       let nearMeRadius = "Near Me Radius"
       let mapUnitOfMeasure = "Map Unit of Measure"
       return [mapViewOptions, featureLayersOptions, nearMeRadius, mapUnitOfMeasure]
   }()

    var dismissClosure: (() -> Void)? = nil

    var completionButton: FUIButton? = nil

    var completionClosure: ((FUIButton) -> Void)? = nil

   override func viewDidLoad() {
       navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Close", style: .plain, target: self, action: #selector(dismissVC))
       self.navigationController?.title = "Map Settings"
       tableView.dataSource = self
       tableView.delegate = self
   }

   override func numberOfSections(in tableView: UITableView) -> Int {
       return dataSource.count
   }

   override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
       let settingsCell = UITableViewCell()
       settingsCell.textLabel?.text = dataSource[indexPath.section]
       if dataSource[indexPath.section] == "Near Me Radius" {
           let switchView = UISwitch()
           settingsCell.accessoryView = switchView
       } else {
           settingsCell.accessoryType = UITableViewCellAccessoryType.disclosureIndicator
       }
       return settingsCell
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
       return 1
    }

    @objc func dismissVC() {
       DispatchQueue.main.async {
           self.dismissButton?.isSelected = false
       }

       guard (UIDevice.current.userInterfaceIdiom == .phone) else {
           self.dismiss(animated: true , completion: {
               guard let completionClosure = self.completionClosure, let completionButton = self.completionButton else {
                   return
               }
               completionClosure(completionButton)
           })
           return
        }

        guard let closure = self.dismissClosure else {
           return
        }
        closure()
   }

}

  • A convenience initializer of the FUIMapToolbarSettingsButton that sets the frame to zero.

    Declaration

    Swift

    public convenience init()