import Quickshell
import Quickshell.Io
import QtQuick
import QtQuick.Layouts
import Quickshell.Widgets
import Quickshell.Services.Pipewire
import "common" as Common

Item {
    id: root
    property PwNode speakerNode: Pipewire.defaultAudioSink
    property PwNode microphoneNode: Pipewire.defaultAudioSource
    PwObjectTracker {
        objects: [root.microphoneNode, root.speakerNode]
    }

    width: row.width
    height: row.height

    // console.log("a");

    RowLayout {
        id: row
        Item {
            implicitWidth: 28
            implicitHeight: 28
            Rectangle {
                width: parent.width
                height: parent.height
                radius: 7
                color: "black"
            }
            Text {
                anchors.centerIn: parent
                font.pixelSize: 28
                color: root.speakerNode.audio.muted ? "#B1B2B5" : "white"
                font.family: "CaskaydiaCove Nerd Font Mono"
                text: root.speakerNode.audio.muted ? Common.Icons.audioIcons.speakerMuted : Common.Icons.audioIcons.speaker
            }
        }
        Item {
            implicitWidth: 28
            implicitHeight: 28
            Rectangle {
                width: parent.width
                height: parent.height
                radius: 7
                color: "black"
            }
            Text {
                anchors.centerIn: parent
                font.pixelSize: 34
                color: root.microphoneNode.audio.muted ? "#B1B2B5" : "white"
                font.family: "CaskaydiaCove Nerd Font Mono"
                text: root.microphoneNode.audio.muted ? Common.Icons.audioIcons.microphoneMuted : Common.Icons.audioIcons.microphone
            }
        }
    }
}
