DetailsView.qml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. import QtQuick 2.0
  2. Item {
  3. id: root
  4. property bool isShown: false
  5. property string image
  6. property string name
  7. property string year
  8. property string director
  9. property string cast
  10. property string overview
  11. property alias rating: ratingsItem.rating
  12. anchors.fill: parent
  13. opacity: 0
  14. visible: opacity
  15. scale: 0.3
  16. function show() {
  17. mainView.scheduleUpdate();
  18. root.isShown = true;
  19. showAnimation.restart();
  20. }
  21. function hide() {
  22. hideAnimation.restart();
  23. }
  24. Binding {
  25. target: mainView
  26. property: "blurAmount"
  27. value: 40 * root.opacity
  28. when: root.isShown
  29. }
  30. ParallelAnimation {
  31. id: showAnimation
  32. NumberAnimation { target: root; property: "opacity"; to: 1.0; duration: 500; easing.type: Easing.InOutQuad }
  33. NumberAnimation { target: root; property: "scale"; to: 1.0; duration: 500; easing.type: Easing.InOutQuad }
  34. }
  35. SequentialAnimation {
  36. id: hideAnimation
  37. ParallelAnimation {
  38. NumberAnimation { target: root; property: "opacity"; to: 0; duration: 500; easing.type: Easing.InOutQuad }
  39. NumberAnimation { target: root; property: "scale"; to: 0.3; duration: 500; easing.type: Easing.InOutQuad }
  40. }
  41. PropertyAction { target: root; property: "isShown"; value: false }
  42. }
  43. MouseArea {
  44. anchors.fill: parent
  45. onClicked: {
  46. root.hide();
  47. }
  48. }
  49. Rectangle {
  50. id: backgroundItem
  51. anchors.centerIn: parent
  52. width: Math.min(620, parent.width - 32)
  53. height: Math.min(840, parent.height - 32)
  54. border.color: "#808080"
  55. border.width: 1
  56. opacity: 0.8
  57. gradient: Gradient {
  58. GradientStop { position: 0.0; color: "#101010" }
  59. GradientStop { position: 0.3; color: "#404040" }
  60. GradientStop { position: 1.0; color: "#090909" }
  61. }
  62. }
  63. Flickable {
  64. anchors.top: backgroundItem.top
  65. anchors.left: backgroundItem.left
  66. anchors.right: backgroundItem.right
  67. anchors.bottom: bottomSeparator.top
  68. anchors.margins: 1
  69. anchors.bottomMargin: 0
  70. contentWidth: backgroundItem.width
  71. contentHeight: ratingsItem.y + descriptionTextItem.height + 64
  72. flickableDirection: Flickable.VerticalFlick
  73. clip: true
  74. Image {
  75. id: movieImageItem
  76. x: 8
  77. y: 24
  78. width: 192
  79. height: 192
  80. source: root.image ? "images/" + root.image : ""
  81. fillMode: Image.PreserveAspectFit
  82. smooth: true
  83. }
  84. Column {
  85. id: topColumn
  86. y: 20
  87. anchors.left: movieImageItem.right
  88. anchors.leftMargin: 10
  89. anchors.right: parent.right
  90. anchors.rightMargin: 26
  91. spacing: 8
  92. Text {
  93. id: titleTextItem
  94. width: parent.width
  95. wrapMode: Text.WordWrap
  96. color: "#ffffff"
  97. font.pixelSize: text.length < 12 ? settings.fontL : settings.fontMM
  98. text: root.name
  99. }
  100. Text {
  101. id: yearTextItem
  102. width: parent.width
  103. wrapMode: Text.WordWrap
  104. color: "#ffffff"
  105. font.pixelSize: settings.fontS
  106. text: "<b>Published:</b> " + root.year
  107. }
  108. Text {
  109. id: directorsTextItem
  110. width: parent.width
  111. wrapMode: Text.WordWrap
  112. color: "#ffffff"
  113. font.pixelSize: settings.fontS
  114. text: "<b>Director:</b> " + root.director
  115. }
  116. Text {
  117. id: castTextItem
  118. width: parent.width
  119. wrapMode: Text.WordWrap
  120. color: "#ffffff"
  121. font.pixelSize: settings.fontS
  122. text: "<b>Cast:</b> " + root.cast
  123. }
  124. }
  125. RatingsItem {
  126. id: ratingsItem
  127. x: 10
  128. y: Math.max(topColumn.height, movieImageItem.height) + 40
  129. rating: root.rating
  130. }
  131. Text {
  132. id: descriptionTextItem
  133. anchors.top: ratingsItem.bottom
  134. anchors.topMargin: 16
  135. width: parent.width - 32
  136. anchors.horizontalCenter: parent.horizontalCenter
  137. wrapMode: Text.WordWrap
  138. color: "#ffffff"
  139. font.pixelSize: settings.fontM
  140. text: "<b>Description:</b> " + root.overview
  141. }
  142. }
  143. Rectangle {
  144. id: bottomSeparator
  145. anchors.horizontalCenter: parent.horizontalCenter
  146. anchors.bottom: backgroundItem.bottom
  147. anchors.bottomMargin: 80
  148. width: backgroundItem.width - 16
  149. height: 1
  150. color: "#808080"
  151. }
  152. Button {
  153. anchors.bottom: backgroundItem.bottom
  154. anchors.bottomMargin: 8
  155. anchors.left: backgroundItem.left
  156. anchors.leftMargin: 32
  157. text: "Back"
  158. effectsOn: false
  159. onClicked: {
  160. root.hide();
  161. }
  162. }
  163. Button {
  164. anchors.bottom: backgroundItem.bottom
  165. anchors.bottomMargin: 8
  166. anchors.right: backgroundItem.right
  167. anchors.rightMargin: 32
  168. effectsOn: root.visible
  169. text: "Order"
  170. onClicked: {
  171. console.debug("Order! TODO: implement");
  172. }
  173. }
  174. }