-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainPage.qml
156 lines (144 loc) · 4.32 KB
/
MainPage.qml
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import QtQuick 2.0
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
Page {
width: mainwindow.width
height: mainwindow.height
Rectangle {
width: parent.width
height: parent.height
color: "#f7fafc"
}
Rectangle {
id: searchbar
visible: stackView.searchMode
width: listviewbackground.width
height: 50
x: listviewbackground.x
y: toolbar.height + 20
color: "transparent"
RowLayout {
anchors.fill: parent
Rectangle {
Layout.fillWidth: true
height: 40
radius: 10
// color: "#FAFAFA"
border.width: 0.5
border.color: "#E0E0E0"
TextInput {
width: parent.width - 10
height: parent.height - 20
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 20
maximumLength: 90
}
}
MyButton {
// Layout.rightMargin: 70
Layout.preferredWidth: 120
Layout.preferredHeight: 50
texticon.text: "\ue804"
texticon.visible: true
contentText.text: "Search"
contentText.color: "#FAFAFA"
contentText.font.bold: Font.Medium
bgitem.color: "#f56565"
bgitem.border.width: 0
bgitem.border.color: "#f56565"
}
}
}
Rectangle {
id: listviewbackground
anchors.horizontalCenter: parent.horizontalCenter
y: toolbar.height + 50
width: parent.width / 1.2
height: parent.height / 1.4
radius: 10
border.width: 0.5
border.color: "#E0E0E0"
state: stackView.searchMode ? "search" : "normal"
states: [
State {
name: "search"
PropertyChanges {
target: listviewbackground
y: toolbar.height + 100
height: parent.height / 1.6
}
},
State {
name: "normal"
PropertyChanges {
target: listviewbackground
y: toolbar.height + 50
height: parent.height / 1.4
}
}
]
transitions: [
Transition {
NumberAnimation {
target: listviewbackground
property: "y"
duration: 100
}
}
]
ListView {
id: listview
width: parent.width - 10
height: parent.height - 10
anchors.centerIn: parent
model: stackView.mainModel.loaded ? stackView.mainModel : 7
clip: true
delegate: listview.model.loaded ? newsdelegate : loadingdelegate
add: Transition {
NumberAnimation {
property: "x"
from: -300
duration: 200
}
}
removeDisplaced: Transition {
NumberAnimation {
properties: "y"
duration: 300
}
}
addDisplaced: Transition {
NumberAnimation {
properties: "y"
duration: 300
}
}
remove: Transition {
NumberAnimation {
property: "x"
to: -parent.width
duration: 200
}
}
}
ClickableText {
visible: stackView.mainModel.loaded && stackView.mainModel != searchmodel
anchors.horizontalCenter: listview.horizontalCenter
anchors.top: listview.bottom
anchors.topMargin: 13
text: "Load More..."
color: "#f56565"
font.bold: Font.Medium
onClicked: newsmodel.getPostInfo()
}
}
Component {
id: newsdelegate
NewsDelegate { }
}
Component {
id: loadingdelegate
LoadingDelegate { }
}
}