volume mixer: add icon for empty

This commit is contained in:
end-4
2024-03-26 12:57:15 +07:00
parent 5f4deb7408
commit c615b9987f
2 changed files with 33 additions and 6 deletions
@@ -159,9 +159,9 @@ export default (props) => {
'empty': notifEmptyContent, 'empty': notifEmptyContent,
'list': notifList, 'list': notifList,
}, },
setup: (self) => self setup: (self) => self.hook(Notifications, (self) => {
.hook(Notifications, (self) => self.shown = (Notifications.notifications.length > 0 ? 'list' : 'empty')) self.shown = (Notifications.notifications.length > 0 ? 'list' : 'empty')
, }),
}); });
return Box({ return Box({
...props, ...props,
@@ -8,7 +8,7 @@ import { MaterialIcon } from '../../.commonwidgets/materialicon.js';
import { setupCursorHover } from '../../.widgetutils/cursorhover.js'; import { setupCursorHover } from '../../.widgetutils/cursorhover.js';
import { AnimatedSlider } from '../../.commonwidgets/cairo_slider.js'; import { AnimatedSlider } from '../../.commonwidgets/cairo_slider.js';
const appVolume = (stream) => { const AppVolume = (stream) => {
// console.log(stream) // console.log(stream)
return Box({ return Box({
className: 'sidebar-volmixer-stream spacing-h-10', className: 'sidebar-volmixer-stream spacing-h-10',
@@ -71,13 +71,31 @@ const appVolume = (stream) => {
} }
export default (props) => { export default (props) => {
const emptyContent = Box({
homogeneous: true,
children: [Box({
vertical: true,
vpack: 'center',
className: 'txt spacing-v-10',
children: [
Box({
vertical: true,
className: 'spacing-v-5 txt-subtext',
children: [
MaterialIcon('brand_awareness', 'gigantic'),
Label({ label: 'No audio source', className: 'txt-small' }),
]
}),
]
})]
});
const appList = Scrollable({ const appList = Scrollable({
vexpand: true, vexpand: true,
child: Box({ child: Box({
attribute: { attribute: {
'updateStreams': (self) => { 'updateStreams': (self) => {
const streams = Audio.apps; const streams = Audio.apps;
self.children = streams.map(stream => appVolume(stream)); self.children = streams.map(stream => AppVolume(stream));
}, },
}, },
vertical: true, vertical: true,
@@ -108,12 +126,21 @@ export default (props) => {
}) })
] ]
}); });
const mainContent = Stack({
children: {
'empty': emptyContent,
'list': appList,
},
setup: (self) => self.hook(Audio, (self) => {
self.shown = (Audio.apps.length > 0 ? 'list' : 'empty')
}),
})
return Box({ return Box({
...props, ...props,
className: 'spacing-v-5', className: 'spacing-v-5',
vertical: true, vertical: true,
children: [ children: [
appList, mainContent,
status, status,
] ]
}); });