Add segmented control implementation
This commit is contained in:
parent
85d66d2413
commit
1c027c526b
2 changed files with 104 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue