// Qt
import QtQuick 2.15

//  Qml imports
import "qrc:/globals"
import "qrc:/components"

Item { id: _root
    property alias title        : _title.text
    property alias fileCount    : _fileCount.text
    property string freeValue   : ""
    property string totalValue  : ""
    property Item contentItem   : null
    property alias contentArea  : _contentArea

    height                      : 75
    width                       : parent.width

    Text { id: _title
        anchors {
            left        : parent.left
            top         : parent.top
        }

        color               : Colors.offWhite
        font.weight         : Font.DemiBold
        font.pixelSize      : Fonts.fontPixelTextRectExtra
    }

    Text { id: _fileCount
        anchors {
            left            : parent.left
            top             : _title.bottom
            topMargin       : 5
        }

        color               : Colors.offWhite
        font.pixelSize      : Fonts.fontUnit
    }

    Item { id   : _progressContainer
        anchors {
            right           : parent.right
            verticalCenter  : parent.verticalCenter
        }
        width               : Math.max(_freeText.contentWidth, _totalText.contentWidth)
        height              : parent.height

        Text { id: _freeText
            anchors.right               : parent.right
            anchors.verticalCenter      : parent.verticalCenter
            anchors.verticalCenterOffset: Variables.defaultMargin/2 * -1
            text                        : qsTr("Free: %1 %2").arg(_root.freeValue).arg(Variables.unitStorage)
            color                       : Colors.offWhite
            width                       : parent.width
            horizontalAlignment         : Text.AlignRight
        }

        Text { id: _totalText
            anchors.right               : parent.right
            anchors.top                 : _freeText.bottom
            text                        : qsTr("Total: %1 %2").arg(_root.totalValue).arg(Variables.unitStorage)
            color                       : Colors.offWhite
            width                       : parent.width
            horizontalAlignment         : Text.AlignRight
        }
    }

    ContentArea { id : _contentArea
        anchors {
            top         : _root.top
            right       : _progressContainer.left
            rightMargin : 10
            bottom      : _root.bottom
            bottomMargin: 10
        }
        width       : parent.height
        contentItem : _root.contentItem
    }
}
