AsteroidOS / asteroid-settings

Default settings app for AsteroidOS
GNU General Public License v3.0
9 stars 18 forks source link

Eliminate elementsNb() function in main.qml #53

Closed beroset closed 2 years ago

beroset commented 2 years ago

The current main.qml contains this code:

        Flickable {
            function elementsNb() {
                var nb = 13;
                if(DeviceInfo.hasSpeaker) nb ++
                return nb;
            }
            contentHeight: elementsNb()*Dims.h(16) + (DeviceInfo.hasRoundScreen ? Dims.h(20) : 0)

The intent is to add some padding at the top (and the bottom, not shown) if it's a round screen. However, it uses a function elementsNb which requires human programmers to count how many items are in the list, which is inherently fragile.

Better would be to use an approach which does not require accurate human counting, but lets the computer do that. This would make the code easier to maintain and probably easier to understand.