/*!
 *
 * Copyright (c) 2021-2025 Diality Inc. - All Rights Reserved.
 * \copyright
 * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN
 * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER.
 *
 * \file    BaseSwitch.qml
 * \author  (last)      Nico Ramirez
 * \date    (last)      27-Oct-2025
 * \author  (original)  Nico Ramirez
 * \date    (original)  27-Oct-2025
 *
 */

import QtQuick 2.12
import QtQuick.Controls         2.12 // Switch

//  Qml imports
import "qrc:/globals"

Switch { id: _root
    property bool active    : true
    property real diameter  : Variables.sliderCircleDiameter
    property int  margin    : 4

    indicator: Rectangle {
        implicitWidth   : Variables.sliderCircleDiameter * 2.5
        implicitHeight  : Variables.sliderCircleDiameter + ( _root.margin * 2 )
        radius          : implicitHeight
        anchors.centerIn: parent
        color           : _root.checked && _root.active ? Colors.backgroundButtonSelect  : Colors.createTreatmentInactive
        border.color    : _root.checked && _root.active ? Colors.borderButton            : Colors.createTreatmentInactive

        Rectangle {
            x: _root.checked ? parent.width - width - _root.margin : _root.margin
            anchors.verticalCenter: parent.verticalCenter
            width   : _root.diameter
            height  : _root.diameter
            radius  : _root.diameter
            color   : _root.active ? Colors.textMain : Colors.borderDisableButton
            Behavior on x { NumberAnimation { duration: 150; easing.type: Easing.InOutQuad } }
        }
    }
}
