예제 #1
0
        private void initDeleteMethodPanel(SavedMethodBtnController pMethodObj)
        {
            // show edit panel
            mContainer.SetActive(false);
            mReplacePanelMethod.SetActive(false);
            mDelPanelMethod.SetActive(true);

            // clone object to panel edit
            SavedMethodBtnController controller = Instantiate(pMethodObj);

            controller.setMethod(pMethodObj.getMethod());
            controller.setDeleteBtn(false);
            controller.setMethodBtn(false);

            RectTransform methodPanelrecttransform = controller.GetComponent <RectTransform>();

            // clear currency state
            for (int i = 0; i < mPanelForDelMethod.transform.childCount; i++)
            {
                Logger.Log("Destroy child on panel for edit saved payment method with ind - " + i);
                Destroy(mPanelForDelMethod.transform.GetChild(i).gameObject);
            }

            controller.transform.SetParent(mPanelForDelMethod.transform);
            methodPanelrecttransform.anchorMin = new Vector2(0, 0);
            methodPanelrecttransform.anchorMax = new Vector2(1, 1);
            methodPanelrecttransform.pivot     = new Vector2(0.5f, 0.5f);
            methodPanelrecttransform.offsetMin = new Vector2(0, 0);
            methodPanelrecttransform.offsetMax = new Vector2(0, 0);

            // set text
            mTitle.text         = mUtilsLink.GetTranslations().Get("delete_payment_account_page_title");
            mQuestionLabel.text = mUtilsLink.GetTranslations().Get("payment_account_delete_confirmation_question");

            mLinkCancel.GetComponent <Text>().text = mUtilsLink.GetTranslations().Get("cancel");
            mLinkCancel.GetComponent <Button>().onClick.RemoveAllListeners();
            mLinkCancel.GetComponent <Button>().onClick.AddListener(() => onClickCancelEditMethod());

            mLinkDelete.GetComponent <Text>().text = mUtilsLink.GetTranslations().Get("delete_payment_account_button");
            mLinkDelete.GetComponent <Button>().onClick.RemoveAllListeners();
            mLinkDelete.GetComponent <Button>().onClick.AddListener(() => onClickConfirmDeletePaymentMethod(controller.getMethod()));

            mBtnReplace.GetComponentInChildren <Text>().text = mUtilsLink.GetTranslations().Get("replace_payment_account_button");
            mBtnReplace.GetComponent <Button>().onClick.RemoveAllListeners();
            mBtnReplace.GetComponent <Button>().onClick.AddListener(() => onClickReplacePeymentMethod(controller.getMethod()));
        }
예제 #2
0
        private void onClickReplacePeymentMethod(XsollaSavedPaymentMethod pMethod)
        {
            Logger.Log("Click replace method");
            mListReplacedMethods = new ArrayList();

            // open form with replaced methods
            mInfoPanel.SetActive(false);
            mDelPanelMethod.SetActive(false);
            mContainer.SetActive(false);
            mReplacePanelMethod.SetActive(true);

            for (int i = 0; i < mPanelForReplacedMethods.transform.childCount; i++)
            {
                Logger.Log("Destroy child on panel for edit saved payment method with ind - " + i);
                Destroy(mPanelForReplacedMethods.transform.GetChild(i).gameObject);
            }

            // TODO
            // if we don't have account on replace we must click on another method

            // set all
            foreach (GameObject btnObj in mListBtnsObjs)
            {
                // check if this method not method those replaced
                SavedMethodBtnController controller = btnObj.GetComponent <SavedMethodBtnController>();
                if (controller.getMethod().GetKey() == pMethod.GetKey())
                {
                    continue;
                }

                // add this obj on panel
                SavedMethodBtnController controllerClone = Instantiate(controller);
                controllerClone.setMethod(controller.getMethod());
                controllerClone.setDeleteBtn(false);
                controllerClone.setMethodBtn(false);
                controllerClone.setToggleObj(true, onToggleChange);

                controllerClone.transform.SetParent(mPanelForReplacedMethods.transform);
                RectTransform methodPanelrecttransform = controllerClone.GetComponent <RectTransform>();
                methodPanelrecttransform.anchorMin = new Vector2(0, 0);
                methodPanelrecttransform.anchorMax = new Vector2(1, 1);
                methodPanelrecttransform.pivot     = new Vector2(0.5f, 0.5f);
                methodPanelrecttransform.offsetMin = new Vector2(0, 0);
                methodPanelrecttransform.offsetMax = new Vector2(0, 0);

                mListReplacedMethods.Add(controllerClone);
            }

            // set titles for replace screen
            mLinkGetAnotherMethods.GetComponent <Text>().text = mUtilsLink.GetTranslations().Get("savedmethod_other_change_account_label");
            Button linkAnotherMethod = mLinkGetAnotherMethods.GetComponent <Button>();

            linkAnotherMethod.onClick.RemoveAllListeners();
            linkAnotherMethod.onClick.AddListener(() => onClickConfirmReplacedAnotherMethod(pMethod));

            mLinkBack.GetComponent <Text>().text = mUtilsLink.GetTranslations().Get("back_to_paymentaccount");
            Button linkBack = mLinkBack.GetComponent <Button>();

            linkBack.onClick.RemoveAllListeners();
            linkBack.onClick.AddListener(() => onClickCancelEditMethod());

            mBtnContinue.GetComponentInChildren <Text>().text = mUtilsLink.GetTranslations().Get("form_continue");
            Button btnContinue = mBtnContinue.GetComponent <Button>();

            btnContinue.onClick.RemoveAllListeners();
            btnContinue.onClick.AddListener(() => onClickConfirmReplaced(pMethod));
        }
예제 #3
0
        public void initScreen(XsollaUtils pUtils, XsollaSavedPaymentMethods pMethods, Action pAddPaymentMethod, bool pAddState)
        {
            mUtilsLink        = pUtils;
            mActionAddPayment = pAddPaymentMethod;

            if (pMethods != null)
            {
                mListMethods = pMethods;
            }
            else
            {
                GetSavedMethod(pAddState, true);
                return;
            }

            if (mListBtnsObjs == null)
            {
                mListBtnsObjs = new ArrayList();
            }
            else
            {
                mListBtnsObjs.Clear();
            }

            mTitle.text            = pUtils.GetTranslations().Get("payment_account_page_title");
            mInformationTitle.text = pUtils.GetTranslations().Get("payment_account_add_title");
            mInformation.text      = pUtils.GetTranslations().Get("payment_account_add_info");
            mContinueLink.text     = pUtils.GetTranslations().Get("payment_account_back_button");
            mCanceltext.text       = pUtils.GetTranslations().Get("cancel");
            mCloseNotify.onClick.AddListener(CloseStatus);

            Button continueBtn = mContinueLink.GetComponent <Button>();

            continueBtn.onClick.RemoveAllListeners();
            continueBtn.onClick.AddListener(() =>
            {
                Destroy(this.gameObject);
                mOnClose();
            });
            Text textBtn = mBtnAddPaymentObj.GetComponentInChildren <Text>();

            textBtn.text = pUtils.GetTranslations().Get("payment_account_add_button");

            // clear btn Grid
            for (int i = 0; i < mBtnGrid.transform.childCount; i++)
            {
                Destroy(mBtnGrid.transform.GetChild(i).gameObject);
            }

            if (mListMethods.GetCount() == 0)
            {
                mContainer.SetActive(false);
                mDelPanelMethod.SetActive(false);
                mReplacePanelMethod.SetActive(false);
                mInfoPanel.SetActive(true);

                Button btnAddPayment = mBtnAddPaymentObj.GetComponent <Button>();
                btnAddPayment.onClick.RemoveAllListeners();
                btnAddPayment.onClick.AddListener(() => { CloseStatus(); mActionAddPayment(); });
            }
            else
            {
                mInfoPanel.SetActive(false);
                mDelPanelMethod.SetActive(false);
                mReplacePanelMethod.SetActive(false);
                mContainer.SetActive(true);
                foreach (XsollaSavedPaymentMethod item in mListMethods.GetItemList())
                {
                    // Create prefab on btn saved method, set parent and set controller on them
                    GameObject methodBtn = Instantiate(Resources.Load("Prefabs/SimpleView/_PaymentFormElements/SavedMethodBtnNew")) as GameObject;
                    methodBtn.transform.SetParent(mBtnGrid.transform);

                    // Add objects btn on list
                    mListBtnsObjs.Add(methodBtn);

                    SavedMethodBtnController controller = methodBtn.GetComponent <SavedMethodBtnController>();

                    // Activated btn delete
                    controller.setDeleteBtn(true);
                    controller.setMethodBtn(false);
                    controller.setDeleteBtnName(pUtils.GetTranslations().Get("delete_payment_account_button"));

                    // Set btn property
                    // Set method
                    controller.setMethod(item);
                    // Set name
                    controller.setNameMethod(item.GetName());
                    // Set Type
                    controller.setNameType(item.GetPsName());
                    // Set icon
                    mImgLoader.LoadImage(controller._iconMethod, item.GetImageUrl());
                    // Set BtnDelAction
                    controller.getBtnDelete().onClick.AddListener(() => { CloseStatus(); onClickDeletePaymentMethod(controller); });
                }

                // Add button "Add payment metnod"
                GameObject objAddMethodClone = Instantiate <GameObject>(mBtnAddPaymentObj);
                objAddMethodClone.transform.SetParent(mBtnGrid.transform);
                //set onclickListener
                Button btnAddMethod = objAddMethodClone.GetComponent <Button>();
                btnAddMethod.onClick.RemoveAllListeners();
                btnAddMethod.onClick.AddListener(() => { CloseStatus(); mActionAddPayment(); });
            }
        }