Advertisement
Guest User

Untitled

a guest
May 17th, 2018
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 11.23 KB | None | 0 0
  1. import QtQuick 2.5
  2. import QtQuick.Layouts 1.2
  3.  
  4. import Gamblify.Gui 1.0
  5. import Gamblify.Betting 1.0
  6. import Gamblify.HelperFunctions 1.0
  7.  
  8. import "../entries_live"
  9. import "../entries_market"
  10.  
  11. Item {
  12.     id: root
  13.  
  14.     property int spacing: 15
  15.  
  16.     property var componentWidth: {
  17.         "startTime" : 0,
  18.                 "eventName": 0,
  19.                 "score": 0,
  20.                 "count": 0
  21.     }
  22.     property string title: "undefined"
  23.  
  24.     property bool marketEnabled: true
  25.     property bool producerDown: false
  26.     property var selectedBetEntries: []
  27.     property var startTime: 0
  28.     property var score: null
  29.     property bool overviewScreen: false
  30.     property string eventId: ""
  31.     property string eventStatus: ""
  32.  
  33.     // Kind of silly, but it's present in the JSON data, despite the API call is 'live'
  34.     property bool isLive: false
  35.     property string sportId: ""
  36.     property bool isFavorite: false
  37.     property bool disableLivescore: false
  38.  
  39.     //    property var marketList: []
  40.     property var betData: []
  41.     property string marketName: ""
  42.  
  43.     signal betOfferClicked(var outcomeData)
  44.     signal childClicked()
  45.     signal favoriteClicked()
  46.     signal favoriteRemoveClicked()
  47.  
  48.     function getMatchStatus(score) {
  49.         if (score.status === "Not Started") {
  50.             return "MATCH_ABOUT_TO_START";
  51.         }
  52.  
  53.         if (score.status === "ended") {
  54.             return "MATCH_ENDED";
  55.         }
  56.  
  57.         if (score.status === null) {
  58.             return "NO_DATA";
  59.         }
  60.  
  61.         return "MATCH_ON";
  62.     }
  63.  
  64.     function getTotalScore(score){
  65.         score = score.slice(1,-1);
  66.         var scoreArray = score.split(",");
  67.         var totalScore = 0;
  68.         for(var i = 0; i<scoreArray.length; i++){
  69.             totalScore = totalScore + parseInt(scoreArray[i]);
  70.         }
  71.         return totalScore;
  72.     }
  73.  
  74.     RowLayout {
  75.  
  76.         anchors {
  77.             fill: parent
  78.             rightMargin: root.spacing
  79.             leftMargin: root.spacing
  80.         }
  81.  
  82.         spacing: root.spacing
  83.  
  84.         //            GradientButton {
  85.         //                id: favoriteButton
  86.  
  87.         //                height: parent.height
  88.         //                width: parent.width * root.componentWidth["star"]
  89.  
  90.         //                FavoritesStar {
  91.         //                    anchors.fill: parent
  92.         //                    anchors.margins: 10
  93.  
  94.         //                    type: root.isFavorite === true ? "ACTIVE" : "DEFAULT"
  95.         //                }
  96.  
  97.         //                onClicked: root.isFavorite === true ? root.favoriteRemoveClicked() : root.favoriteClicked();
  98.         //            }
  99.  
  100.         GradientButton {
  101.             id: titleContainer
  102.  
  103.             Layout.fillHeight: true
  104.             Layout.preferredWidth: root.width * (root.componentWidth["startTime"] + root.componentWidth["eventName"])
  105.  
  106.             onClicked: {
  107.                 root.childClicked();
  108.             }
  109.  
  110.             RowLayout {
  111.                 id: rowLayout
  112.  
  113.                 anchors {
  114.                     fill: parent
  115.                     leftMargin: root.spacing
  116.                 }
  117.  
  118.                 RowLayout {
  119.                     Layout.fillHeight: true
  120.                     Layout.fillWidth: true
  121.                     spacing: root.spacing
  122.  
  123.                     Item {
  124.                         id: startTime
  125.  
  126.                         Layout.fillHeight: true
  127.                         Layout.preferredWidth: startTimeText.paintedWidth
  128.  
  129.                         Gilroy {
  130.                             id: startTimeText
  131.                             height: parent.height
  132.                             width: parent.width
  133.  
  134.                             horizontalAlignment: Text.AlignHCenter
  135.                             verticalAlignment: Text.AlignVCenter
  136.  
  137.                             font.pointSize: 10
  138.  
  139.                             color: "#8892B5"
  140.  
  141.                             text: {
  142.                                 return Util.getStartTimeOrDate(root.startTime);
  143.                             }
  144.                         }
  145.                     }
  146.  
  147.                     Item {
  148.                         id: liveE
  149.                         Layout.preferredWidth:liveEmblem.childrenRect.width
  150.                         Layout.preferredHeight: liveEmblem.childrenRect.height
  151.                         LiveEmblem {
  152.                             id: liveEmblem
  153.                             visible: root.isLive === true
  154.                         }
  155.                     }
  156.  
  157.                     Item {
  158.                         Layout.fillHeight: true
  159.                         Layout.fillWidth: true
  160.                         //                        width: root.width * 0.3
  161.                         Gilroy {
  162.                             id: titleText
  163.  
  164.                             //                        height: parent.height
  165.                             //                        width: parent.width
  166.                             anchors.fill: parent
  167.  
  168.                             font.pointSize: 12
  169.  
  170.                             //                        anchors.left: root.isLive === true ? liveEmblem.right : parent.left
  171.                             //                        anchors.leftMargin: 15
  172.  
  173.                             horizontalAlignment: Text.AlignLeft
  174.                             verticalAlignment: Text.AlignVCenter
  175.  
  176.                             color: "white"
  177.  
  178.                             text: root.title
  179.                             elide: Text.ElideRight
  180.                         }
  181.                     }
  182.                 }
  183.  
  184.  
  185.                 Item {
  186.                     id: arrowToRight
  187.                     Layout.preferredHeight: childrenRect.height
  188.                     Layout.preferredWidth: parent.width * 0.10
  189.  
  190.                     Arrow {
  191.                         visible: !overviewScreen
  192.  
  193.                         width: 15
  194.                         height: 15
  195.  
  196.                         rotation: 180
  197.                     }
  198.                 }
  199.             }
  200.  
  201.         }
  202.  
  203.         // TODO: ENABLE WHEN WE GET LIVE SCORES
  204.         //        Item {
  205.         //            id: score
  206.  
  207.         //            Layout.fillHeight: true
  208.         //            Layout.preferredWidth: root.isOutright ? 0 : parent.width * root.componentWidth["score"]
  209.  
  210.         //            Loader {
  211.         //                id: liveSportMessageLoader
  212.  
  213.         //                anchors.fill: parent
  214.  
  215.         //                    sourceComponent: {
  216.         //                        if(root.disableLivescore) return undefined;
  217.         //                sourceComponent: {
  218.         //                    if(root.isOutright) return undefined;
  219.  
  220.         //                    var matchStatus = getMatchStatus(root.score);
  221.         //                    // If the sport simply has no score information, abort everything
  222.         //                    if (matchStatus !== "MATCH_ON") {
  223.         //                        return liveMessageNoScoreData;
  224.         //                    }
  225.  
  226.  
  227.         //                    switch (MarketHelper.getSportNameBySportId(root.sportId)) {
  228.  
  229.         //                    case "SOCCER":
  230.         //                        return liveMessageSoccer;
  231.  
  232.         //                    case "ICE_HOCKEY":
  233.         //                        return liveMessageSoccer; // They have the same signature at the moment
  234.  
  235.         //                    default:
  236.         //                        return liveMessageGeneric;
  237.         //                    }
  238.         //                }
  239.         //            }
  240.         //        }
  241.  
  242.  
  243.         Item {
  244.             id: betButtons
  245.             Layout.fillHeight: true
  246.             Layout.fillWidth: true
  247.  
  248.             Loader {
  249.                 id: betButtonLoader
  250.  
  251.                 anchors.fill: parent
  252.  
  253.                 sourceComponent: {
  254.                     if (root.betData.length <= 0) {
  255.                         return noDataMessage;
  256.                     }
  257.                     return betButtonCollection;
  258.                 }
  259.             }
  260.  
  261.             Component {
  262.                 id: betButtonCollection
  263.  
  264.                 // This is modeled after LiveMessageGeneric.qml, so if you update that, update this too
  265.                 ColumnLayout {
  266.                     anchors.fill: parent
  267.                     spacing: 0
  268.  
  269.  
  270.                     //                    LiveMessageBackground {
  271.                     //                        Layout.preferredHeight: root.height * 0.25
  272.                     //                        Layout.fillWidth: true
  273.                     //                        visible: !root.isOutright
  274.  
  275.                     //                        Item {
  276.                     //                            anchors.fill: parent
  277.  
  278.                     //                            Gilroy {
  279.                     //                                anchors.fill: parent
  280.                     //                                anchors.leftMargin: 5
  281.  
  282.                     //                                verticalAlignment: Text.AlignVCenter
  283.  
  284.                     //                                font.capitalization: Font.AllUppercase
  285.                     //                                font.pointSize: 7
  286.  
  287.                     //                                color: "white"
  288.                     //                                text: root.marketName
  289.                     //                            }
  290.  
  291.                     //                        }
  292.                     //                    }
  293.                     BetButtonCollection {
  294.                         Layout.fillHeight: true
  295.                         Layout.fillWidth: true
  296.                         spacing: root.spacing
  297.  
  298.                         marketEnabled: root.marketEnabled
  299.                         producerDown: root.producerDown
  300.                         overviewScreen: root.overviewScreen
  301.                         eventId: root.eventId
  302.  
  303.                         selectedBetEntries: root.selectedBetEntries
  304.                         onBetOfferClicked: {
  305.                             root.betOfferClicked(outcomeData);
  306.                         }
  307.                         betData: root.betData
  308.                     }
  309.                 }
  310.  
  311.  
  312.             }
  313.         }
  314.  
  315.         Component {
  316.             id: noDataMessage
  317.  
  318.             LiveMessageBackground {
  319.                 anchors.fill: parent
  320.  
  321.                 Gilroy {
  322.                     anchors.centerIn: parent
  323.  
  324.                     font.capitalization: Font.AllUppercase
  325.                     font.pointSize: 10
  326.  
  327.                     color: "darkgrey"
  328.  
  329.                     text: qsTr("Waiting for data") + trM.e
  330.                 }
  331.             }
  332.         }
  333.     }
  334. }
  335.  
  336. //Component {
  337. //    id: liveMessageNoScoreData
  338.  
  339. //    LiveMessageNoScoreData {
  340. //        anchors.fill: parent
  341.  
  342. //        status: getMatchStatus(root.score);
  343. //        score: root.score
  344. //    }
  345. //}
  346.  
  347. //Component {
  348. //    id: liveMessageGeneric
  349.  
  350. //    LiveMessageGeneric {
  351. //        anchors.fill: parent
  352.  
  353. //        homeScore: root.getTotalScore(root.score.homeScores)
  354. //        awayScore: root.getTotalScore(root.score.awayScores)
  355. //        score: root.score
  356. //    }
  357. //}
  358.  
  359. //Component {
  360. //    id: liveMessageSoccer
  361.  
  362. //    LiveMessageSoccer {
  363. //        anchors.fill: parent
  364.  
  365. //        score: root.score
  366. //    }
  367. //}
  368. //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement