blob: f6b35be43e0ed490de1129aa61c6f2d897deff67 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
import QtQuick
import QtQuick.Templates as T
import QtQuick.Controls.impl
import QtQuick.Controls.iOS.impl
T.Drawer {
id: control
parent: T.Overlay.overlay
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
implicitContentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
implicitContentHeight + topPadding + bottomPadding)
property real inset: control.dim ? 8 : 0
property bool vertical: control.edge === Qt.LeftEdge || control.edge === Qt.RightEdge
topPadding: SafeArea.margins.top
leftPadding: SafeArea.margins.left
rightPadding: SafeArea.margins.right
bottomPadding: SafeArea.margins.bottom
rightInset: background && control.edge === Qt.LeftEdge ? -inset : 0
leftInset: background && control.edge === Qt.RightEdge ? -inset : 0
bottomInset: background && control.edge === Qt.TopEdge ? -inset : 0
topInset: background && control.edge === Qt.BottomEdge ? -inset : 0
enter: Transition { SmoothedAnimation { velocity: 5 } }
exit: Transition { SmoothedAnimation { velocity: 5 } }
background: Item {
NinePatchImage {
source: IOS.url + "drawer-background"
NinePatchImageSelector on source {
states: [
{"light": Application.styleHints.colorScheme === Qt.Light},
{"dark": Application.styleHints.colorScheme === Qt.Dark},
{"modal": control.modal}
]
}
y: (parent.height - height) / 2
x: (parent.width - width) / 2
rotation: control.edge === Qt.TopEdge ? 90 : (control.edge === Qt.BottomEdge ? -90
: (control.edge === Qt.RightEdge ? 180 : 0))
width: vertical ? parent.width : parent.height
height: vertical ? parent.height : parent.width
}
Rectangle {
width: vertical ? 1 : parent.width
height: vertical ? parent.height : 1
color: control.palette.mid
x: control.edge === Qt.LeftEdge ? parent.width - 1 - inset : (control.edge === Qt.RightEdge ? inset : 0)
y: control.edge === Qt.BottomEdge ? inset : (control.edge === Qt.TopEdge ? parent.height - 1 - inset : 0)
z: 10
}
}
T.Overlay.modal: Rectangle {
color: Color.transparent(control.palette.mid, 0.5)
Behavior on opacity { NumberAnimation { duration: 150 } }
}
}
|