FUIKPIView
open class FUIKPIView : NibDesignableControl, FUIStateTintable, FUIStateTintableImplementation, FUIKPIContainer, FUIContentCopyableView
extension FUIKPIView: FUIStateSelectable
The FUIKPIView
is an UIView
subclass, which enables a developer to present “KPI” information in a formatted manner consistent with the Fiori Design Language.
The FUIKPIView
takes 3 types of component items, and a caption string:
metric
: the value which is being displayed. For example, in:$256k
, the metric is “256”.unit
: the unit information for the metric displayed. For example, in$256k
, the units are “$” and “k”. Multiple unit components are permitted per metric. However, a maximum of two units should be used on each side of the metric.icon
: a32px x 32px
icon may be displayed. Icons should only be displayed to the left of a metric. Units may still be displayed to the right of the metric, when an icon is displayed.captionLabel
: optional label, displayed beneath the KPI components.
The KPI components are implemented as FUIKPIMetricItem
, FUIKPIUnitItem
, and FUIKPIIconItem
. All implement FUIKPIViewItem
protocol. The developer should create instances of each of these components, and pass them to the items: [FUIKPIViewItem]
property of the FUIKPIView
.
Note
This API of component items is conceptually similar to that ofUIToolbar
‘s items: [UIBarButtonItem]?
property.
Color configuration:
- Call
setTintColor(_:for:)
to configure tint color for disabled, normal, highlightedUIControlState
. SettingtintColor
is equivalent to callsetTintColor(color, for: UIControlState.normal)
. IftintColor
is not set by developer,colorScheme
will be applied. - Disabled: Color to be used when control is disabled.
- Normal: Color to be used when control is enabled.
- Highlighted: Color to be used when control is tapped on.
Initialization
Programmatically:
let kpiView = FUIKPIView(frame: CGRect())
Inside a Storyboard or xib
:
- Drag and drop a
UIView
component to Interface Builder’s canvas. - Switch custom class name from
UIView
toFUIKPIView
and set module toSAPFiori
. - Create an outlet of the
FUIKPIView
to be able to access its properties.
Usage
// Do any additional setup after loading the view.
let unit = FUIKPIUnitItem(string: "$")
let metric = FUIKPIMetricItem(string: "294")
let unit2 = FUIKPIUnitItem(string: "USD")
self.kpiView.items = [unit, metric, unit2]
self.kpiView.captionlabel.text = "Label example can wrap to two lines"
let icon = FUIKPIIconItem(icon: #imageLiteral(resourceName: "ProfilePic"))
let metric2 = FUIKPIMetricItem(string: "2")
self.kpiIconView.items = [icon, metric2, unit2]
self.kpiIconView.captionlabel.text = "Documents Example of Two Line Wrap"
Theming
Supported KPIView
class paths:
fdlFUIKPIView {}
fdlFUIKPIView_textView {}
fdlFUIKPIView_captionLabel {}
Supported KPIView
attributes:
tint-color (Color)
tint-color-disabled (Color)
tint-color-highlighted (Color)
-
Initialization method for a
FUIKPIView
takes a ‘CGRect"Declaration
Swift
public override init(frame: CGRect)
Parameters
frame
CGRect of the initial frame
-
alignment for the entire FUIKPIView; supports .leading, .center, or .trailing
Declaration
Swift
public var alignment: UIStackView.Alignment { get set }
-
Handler invoked when the FUIKPIView is selected. Only works when the isEnabled property of the FUIKPIView is set to true.
Declaration
Swift
open var didSelectHandler: (() -> Void)?
-
Undocumented
Declaration
Swift
open override var accessibilityLabel: String? { get set }
-
Color scheme for kpi view. Default value is
.device
Declaration
Swift
@available(*, deprecated, message: "Will be unavailble in newer SDK version.") public var colorScheme: FUIBackgroundColorScheme { get set }
-
Optional label, displayed beneath the KPI components. Wraps to 0 lines, with a preferred max width of 216 px.
Declaration
Swift
@IBOutlet public private(set) weak var captionlabel: FUILabel! { get }
-
Array of
FUIKPIViewItem
‘s, which are laid-out sequentially in theFUIKPIView
. Items will be baseline-aligned.Important
developer should set the complete array value to this property, not attempt to mutate the array after it has been set. Subsequent mutations will not be tracked.Declaration
Swift
public var items: [FUIKPIViewItem]? { get set }
-
refresh attributedStrings
Declaration
Swift
public func refreshAttributedStrings()
-
Changes the tint color for the control based on the given state
Declaration
Swift
public func applyTintColor(forState state: UIControlState)
Parameters
state
-
Formatting scenario, used by
FUIKPIAttributesProvider
- none: no previous item, no kerning
default
: regular (minimum) kerning case- repeatingFraction: kerning appended to a leading fraction item, when the current item is also a fraction
- repeatingUnit: kerning appended to a leading unit item, when the current item is also a unit
Declaration
Swift
public enum LeadingItemKerning
-
This property indicates if the content is copyable or not.
The default is
true
.Declaration
Swift
public var isContentCopyable: Bool { get set }