C

Qt Quick Ultralite swipe_game Demo

// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial

import QtQuick 2.0
import StyleModule 1.0
import SwipeModule 1.0
/*
    This view displays the initial start button and provides multiple
    swipe areas for navigation.
*/

BaseView {
    id: root

    signal swipeDownTriggered()
    signal swipeUpTriggered()
    signal swipeLeftTriggered()
    signal swipeRightTriggered()
    signal startRequested()

    Button {
        id: startButton

        anchors.centerIn: parent
        font: Style.textFontDefault
        text: "Start"

        onClicked: {
            root.startRequested()
        }
    }

    // area which catches downward swipes which start at the top of the view
    DirectionalSwipeArea {
        id: downArea

        anchors.fill: parent

        direction: Swipe.Direction.Down

        onTriggered: {
            root.swipeDownTriggered()
        }
    }

    // area which catches upward swipes which start at the bottom of the view
    DirectionalSwipeArea {
        id: upArea

        anchors.fill: parent

        direction: Swipe.Direction.Up

        onTriggered: {
            root.swipeUpTriggered()
        }
    }

    // area which catches leftward swipes which start at the right of the view
    DirectionalSwipeArea {
        id: leftArea

        anchors.fill: parent

        direction: Swipe.Direction.Left

        onTriggered: {
            root.swipeLeftTriggered()
        }
    }

    // area which catches rightward swipes which start at the left of the view
    DirectionalSwipeArea {
        id: rightArea

        anchors.fill: parent

        direction: Swipe.Direction.Right

        onTriggered: {
            root.swipeRightTriggered()
        }
    }
}