Add segmented control implementation

This commit is contained in:
Samuel Attard 2017-03-10 17:40:39 +11:00
parent 85d66d2413
commit 1c027c526b
No known key found for this signature in database
GPG key ID: E89DDE5742D58C4E
2 changed files with 104 additions and 1 deletions

View file

@ -212,4 +212,23 @@ TouchBar.TouchBarSpacer = class TouchBarSpacer extends TouchBarItem {
}
}
TouchBar.TouchBarSegmentedControl = class TouchBarSegmentedControl extends TouchBarItem {
constructor (config) {
super()
if (config == null) config = {}
const {segmentStyle, segments, selectedIndex, change} = config
this.type = 'segmented_control'
this._addLiveProperty('segmentStyle', segmentStyle);
this._addLiveProperty('segments', segments || []);
this._addLiveProperty('selectedIndex', selectedIndex)
if (typeof change === 'function') {
this.onInteraction = (details) => {
this._selectedIndex = details.selectedIndex;
change(details.selectedIndex);
}
}
}
}
module.exports = TouchBar