public Dictionary <string, TransactionSummaryGameObjectList> ExpandCollapseBasePanel(bool shouldExpandPanel, TransactionSummaryData tsData,
                                                                                         Dictionary <string, TransactionSummaryGameObjectList> transactionGameObjectDict)
    {
        TransactionSummaryGameObjectList transactionGameObjects = transactionGameObjectDict[tsData.GetPrimaryKey()];

        transactionGameObjects.GetTransactionSummaryGameObjects().Clear();
        GameObject parentGameObject           = transactionGameObjects.GetParentGameObject();
        GameObject expandCollapseButtonObject = parentGameObject.transform.GetComponentsInChildren <Button>()[1].gameObject;

        if (!shouldExpandPanel)
        {
            expandCollapseButtonObject.GetComponentInChildren <Text>().text = ">";
            transactionGameObjects.SetExpandedFlag(false);
        }
        else
        {
            expandCollapseButtonObject.GetComponentInChildren <Text>().text = "v";
            transactionGameObjects.SetExpandedFlag(true);

            foreach (TransactionSummaryFirstSubData tsFirstSubData in tsData.GetTransactionSummaryFirstSubDataList())
            {
                GameObject  tempFirstSubPanel = (GameObject)Instantiate(firstSubPanel, transform.position, transform.rotation);
                Transform[] ts = tempFirstSubPanel.transform.GetComponentsInChildren <Transform>();
                tempFirstSubPanel.name = "FirstSubPanel_" + tsData.GetPrimaryKey() + "_" + tsFirstSubData.GetPrimaryKey();

                foreach (Transform t in ts)
                {
                    switch (t.gameObject.name)
                    {
                    case "FirstSubPanelMainText":
                        t.gameObject.GetComponent <Text>().text = tsFirstSubData.GetPrimaryKey();
                        break;

                    case "FirstSubPanelSubText":
                        t.gameObject.GetComponent <Text>().text = "";
                        break;

                    case "FirstSubPanelPrice":
                        t.gameObject.GetComponent <Text>().text = "$" + tsFirstSubData.GetTotalPrice();
                        break;
                    }
                }

                tempFirstSubPanel.SetActive(true);
                tempFirstSubPanel.transform.SetParent(parentGameObject.transform, false);
                transactionGameObjects.AddTransactionSummaryGameObject(tempFirstSubPanel);
            }
        }
        return(transactionGameObjectDict);
    }
示例#2
0
    public void displayTransactionDetails(bool isAlreadyExpanded, string selectedPanelKey)
    {
        transactionDetailsList.RemoveAllRows();
        TransactionDetailsRow            row = transactionDetailsList.AddRow();
        TransactionSummaryGameObjectList transactionGameObjects = null;

        row.InitiateTransactionDetailsRow(selectedMainPanelKey);
        transactionGameObjectDict = row.expandCollapseTransactionDetailsRows(selectedMainPanelSubDetailsData, selectedMainPanelKey,
                                                                             true, transactionGameObjectDict);
        transactionGameObjects = transactionGameObjectDict[selectedMainPanelKey];
        GameObject transactionDetailsParentPanel = transactionGameObjects.GetParentGameObject();

        foreach (TransactionSummaryDetailsData tsDetailsData in selectedMainPanelSubDetailsData.getTransactionSummaryDetailsData())
        {
            string currentTransactionDetailsPanelkey = selectedMainPanelKey + "_" + tsDetailsData.GetPrimaryKey();
            bool   curTransactionPanelExpandedFlag   = false;

            if ((currentTransactionDetailsPanelkey).Equals(selectedPanelKey))
            {
                curTransactionPanelExpandedFlag = !isAlreadyExpanded;
            }
            else
            {
                if (transactionGameObjectDict.ContainsKey(currentTransactionDetailsPanelkey))
                {
                    transactionGameObjects          = transactionGameObjectDict[currentTransactionDetailsPanelkey];
                    curTransactionPanelExpandedFlag = transactionGameObjects.IsExpanded();

                    if (curTransactionPanelExpandedFlag)
                    {
                        //transactionGameObjectDict = row.ExpandCollapseThirdPanel(curFinalPanelExpandedFlag, tsSubDetailsData, currentSecondSubPanelkey, transactionGameObjectDict);
                    }
                }
            }

            GameObject transactionDetailsPanel = transactionDetailsParentPanel.transform.Find("TransactionsPanel_" + currentTransactionDetailsPanelkey).gameObject;
            //transactionDetailsPanel.GetComponentsInChildren<Button>()[0].onClick.AddListener(() => displayTransactionDetails(curTransactionPanelExpandedFlag, currentTransactionDetailsPanelkey));
            transactionDetailsPanel.GetComponentsInChildren <Button>()[0].onClick.AddListener(() => openTransactionReceipt(tsDetailsData));
        }
    }
    public void onClickRow(bool isAlreadyExpanded, string selectedPanel)
    {
        transactionByDateList.RemoveAllRows();

        if (transactionSummaryDataList != null && transactionSummaryDataList.Count > 0)
        {
            TransactionByDateRow row = transactionByDateList.AddRow();
            row.InitiateTransactionRows(transactionSummaryDataList, dateToggle.isOn, transactionGameObjectDict);

            foreach (TransactionSummaryData tsData in transactionSummaryDataList)
            {
                string currentMainPanelkey = tsData.GetPrimaryKey();
                TransactionSummaryGameObjectList transactionGameObjects = null;
                bool tempBaseRowExpandedFlag = false;

                if (selectedPanel.Equals(currentMainPanelkey))
                {
                    tempBaseRowExpandedFlag   = !isAlreadyExpanded;
                    transactionGameObjectDict = row.ExpandCollapseBasePanel(tempBaseRowExpandedFlag, tsData, transactionGameObjectDict);
                    transactionGameObjects    = transactionGameObjectDict[currentMainPanelkey];
                }
                else
                {
                    if (transactionGameObjectDict.ContainsKey(currentMainPanelkey))
                    {
                        transactionGameObjects  = transactionGameObjectDict[currentMainPanelkey];
                        tempBaseRowExpandedFlag = transactionGameObjects.IsExpanded();
                    }

                    if (tempBaseRowExpandedFlag)
                    {
                        transactionGameObjectDict = row.ExpandCollapseBasePanel(tempBaseRowExpandedFlag, tsData, transactionGameObjectDict);
                    }
                }

                GameObject tempCurrentRow = transactionGameObjects.GetParentGameObject();
                tempCurrentRow.transform.GetComponentsInChildren <Button>()[1].onClick.AddListener(() => onClickRow(tempBaseRowExpandedFlag, tsData.GetPrimaryKey()));

                row.expandCollapseButton.onClick.AddListener(() => onClickRow(tempBaseRowExpandedFlag, currentMainPanelkey));

                if (tempBaseRowExpandedFlag)
                {
                    foreach (TransactionSummaryFirstSubData tsFirstSubData in tsData.GetTransactionSummaryFirstSubDataList())
                    {
                        string currentFirstSubPanelkey  = currentMainPanelkey + "_" + tsFirstSubData.GetPrimaryKey();
                        bool   tempFirstRowExpandedFlag = false;

                        if ((currentFirstSubPanelkey).Equals(selectedPanel))
                        {
                            tempFirstRowExpandedFlag  = !isAlreadyExpanded;
                            transactionGameObjectDict = row.ExpandCollapseFirstPanel(tempFirstRowExpandedFlag, tsFirstSubData, currentMainPanelkey, transactionGameObjectDict);
                        }
                        else
                        {
                            if (transactionGameObjectDict.ContainsKey(currentFirstSubPanelkey))
                            {
                                transactionGameObjects   = transactionGameObjectDict[currentFirstSubPanelkey];
                                tempFirstRowExpandedFlag = transactionGameObjects.IsExpanded();

                                if (tempFirstRowExpandedFlag)
                                {
                                    transactionGameObjectDict = row.ExpandCollapseFirstPanel(tempFirstRowExpandedFlag, tsFirstSubData, currentMainPanelkey, transactionGameObjectDict);
                                }
                            }
                        }

                        transactionGameObjects = transactionGameObjectDict[currentMainPanelkey];
                        GameObject currentFirstPanel = transactionGameObjects.GetParentGameObject().transform.Find("FirstSubPanel_" + currentFirstSubPanelkey).gameObject;
                        currentFirstPanel.GetComponentsInChildren <Button>()[0].onClick.AddListener(() => onClickRow(tempFirstRowExpandedFlag, currentFirstSubPanelkey));

                        if (tempFirstRowExpandedFlag)
                        {
                            foreach (TransactionSummarySecondSubData tsSecondSubData in tsFirstSubData.GetTransactionSummarySecondSubDataList())
                            {
                                string currentSecondSubPanelkey   = currentFirstSubPanelkey + "_" + tsSecondSubData.GetPrimaryKey();
                                bool   curSecondPanelExpandedFlag = false;

                                if ((currentSecondSubPanelkey).Equals(selectedPanel))
                                {
                                    curSecondPanelExpandedFlag = !isAlreadyExpanded;
                                    transactionGameObjectDict  = row.ExpandCollapseSecondPanel(curSecondPanelExpandedFlag, tsSecondSubData, currentFirstSubPanelkey, transactionGameObjectDict);
                                }
                                else
                                {
                                    if (transactionGameObjectDict.ContainsKey(currentSecondSubPanelkey))
                                    {
                                        transactionGameObjects     = transactionGameObjectDict[currentSecondSubPanelkey];
                                        curSecondPanelExpandedFlag = transactionGameObjects.IsExpanded();

                                        if (curSecondPanelExpandedFlag)
                                        {
                                            transactionGameObjectDict = row.ExpandCollapseSecondPanel(curSecondPanelExpandedFlag, tsSecondSubData, currentFirstSubPanelkey, transactionGameObjectDict);
                                        }
                                    }
                                }

                                transactionGameObjects = transactionGameObjectDict[currentFirstSubPanelkey];
                                GameObject currentSecondPanel = transactionGameObjects.GetParentGameObject().transform.Find("SecondSubPanel_" + currentSecondSubPanelkey).gameObject;
                                currentSecondPanel.GetComponentsInChildren <Button>()[1].onClick.AddListener(() => onClickRow(curSecondPanelExpandedFlag, currentSecondSubPanelkey));

                                if (curSecondPanelExpandedFlag)
                                {
                                    foreach (TransactionSummarySubDetailsData tsSubDetailsData in tsSecondSubData.GetTransactionSummarySubDetailsData())
                                    {
                                        string currentFinalSubPanelkey   = currentSecondSubPanelkey + "_" + tsSubDetailsData.GetPrimaryKey();
                                        bool   curFinalPanelExpandedFlag = false;

                                        if ((currentFinalSubPanelkey).Equals(selectedPanel))
                                        {
                                            curFinalPanelExpandedFlag = !isAlreadyExpanded;
                                            transactionGameObjectDict = row.ExpandCollapseThirdPanel(curFinalPanelExpandedFlag, tsSubDetailsData, currentSecondSubPanelkey, transactionGameObjectDict);
                                        }
                                        else
                                        {
                                            if (transactionGameObjectDict.ContainsKey(currentFinalSubPanelkey))
                                            {
                                                transactionGameObjects    = transactionGameObjectDict[currentFinalSubPanelkey];
                                                curFinalPanelExpandedFlag = transactionGameObjects.IsExpanded();

                                                if (curFinalPanelExpandedFlag)
                                                {
                                                    transactionGameObjectDict = row.ExpandCollapseThirdPanel(curFinalPanelExpandedFlag, tsSubDetailsData, currentSecondSubPanelkey, transactionGameObjectDict);
                                                }
                                            }
                                        }

                                        transactionGameObjects = transactionGameObjectDict[currentSecondSubPanelkey];
                                        GameObject currentThirdPanel = transactionGameObjects.GetParentGameObject().transform.Find("ThirdSubPanel_" + currentFinalSubPanelkey).gameObject;
                                        currentThirdPanel.GetComponentsInChildren <Button>()[1].onClick.AddListener(() => openTransactionDetailsView(currentFinalSubPanelkey, tsSubDetailsData));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }