Skip to content

Progress Indicator

FUIProgressIndicatorControl

open class FUIProgressIndicatorControl: NibDesignableControl

FUIProgressIndicatorControl is an IBDesignable UI component. It can be used to display a (download) progress gauge as used in Apple's App Store and iTunes Store for downloading apps or music.

Different display states control the visual appearance of the control and the options the user has to interact with the control.

Initialization

Programmatically

let progressIndicatorControl = FUIProgressIndicatorControl(frame: CGRect())

Inside a Storyboard or Xib

  1. Drag and drop an UIView component to Interface Builder canvas.
  2. Switch class name from UIView to FUIProgressIndicatorControl, and set module to SAPFiori.
  3. Control-drag from the progress indicator control in Interface Builder to your source file to create an outlet of the FUIProgressIndicatorControl and to be able to access its properties.
  4. Control-drag from the progress indicator control in Interface Builder to your source file and create an action for the FUIProgressIndicatorControl. Make sure to select TouchUpInside as event type. Specify an action name and implement the generated callback method to react accordingly once the user tapped the control.

Usage

// If the action was not created in interface builder as described before, add it programmatically.
progressIndicatorControl.addTarget(self, action: #selector(myActionMethod), for: .touchUpInside)

// Initially, call the changeDisplayState(to:) method to change the views state. You can do that in viewDidLoad() or later.
// The state .inProgress indicates that progress has started. Usually you would show this state when you start connecting to
// a server for downloading data.
progressIndicatorControl.changeDisplayState(to: .inProgress)

// Once the connection has been established and the download has started, you can change the display state to .loadingPausable or
// .loadingStoppable:
progressIndicatorControl.changeDisplayState(to: .loadingPausable)

// If the user tapped the control, while it was in .loadingPausable state, you can change it to .loadingPaused
// For example:
@IBAction func myActionMethod(_ sender: FUIProgressIndicatorControl) {
   switch sender.displayState {
   case .inProgress:
       // do nothing if user tapped on control while it was .inProgress.
       break
   case .loadingPausable:
       sender.changeDisplayState(to: .paused)
       return
   case .loadingStoppable:
       // user cancelled the e.g. download, so we hide the control
       sender.isHidden = true
   }
}

// To set the progress value proceed as follows:
progressIndicatorControl.update(progress: 0.5, animated: false)
progressIndicatorControl.update(progress: 1, animated: true) {
   // Once the download is completed, you might want to hide the progress indicator
   // and show a link to the downloaded resource, etc..
   self.progressIndicatorControl.isHidden = true
   self.openDownloadedFileButton.isHidden = false
}

Theming

Supported style classes

fdlFUIProgressIndicatorControl

Last update: January 15, 2021