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
:
- Drag and drop an
UIView
component to Interface Builder canvas. - Switch class name from
UIView
toFUIProgressIndicatorControl
, and set module toSAPFiori
. - 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. - Control-drag from the progress indicator control in Interface Builder to your source file and create an action for the
FUIProgressIndicatorControl
. Make sure to selectTouchUpInside
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
-
An enum representing the different display states a
See moreFUIProgressIndicatorControl
can have.Declaration
Swift
public enum DisplayState
-
The current progress value (between 0.0 and 1.0) of the progress indicator.
Declaration
Swift
public var progress: Float { get }
-
The current display state of this progress indicator. The initial value is
DisplayState.started
. Changing this property will trigger a redraw of the view adjusting the view to the set state.Declaration
Swift
public private(set) var displayState: DisplayState { get }
-
Updates the progress value. Updating the progress value can be animated. Values for progress should be between 0.0 and 1.0.
Declaration
Swift
open func update(progress: Float, animated: Bool = false, completion: (() -> Void)? = nil)
Parameters
progress
The value the progress indicator should be set to.
animated
Indicates if the progress update should be animated or not.
completion
Completion block called once progress value was updated. This will be called regardless of whether
animated
is true or false. -
Changes the display state of this control. Use this to switch between different graphical representations of this control.
Declaration
Swift
public func changeDisplayState(to newState: DisplayState)
Parameters
newState
the new display state to switch to.