private IEnumerator RemoveRoutine() { ConfirmDialog dialog = FindObjectOfType <ConfirmDialog>(); dialog.ApplyColours(); dialog.Show(); dialog.SetInfoMessage("Remove '<b>" + nameText.text + "</b>'?"); dialog.SetNone(); while (dialog.IsNone()) { yield return(null); } if (dialog.IsNo() || dialog.IsCancel()) { dialog.Hide(); yield break; } if (dialog.IsYes()) { dialog.Hide(); string url = string.Format("{0}/{1}/close", Endpoints.instance.TODOIST_TASKS(), taskId); UnityWebRequest request = Postman.CreatePostRequest(url, new JSONObject()); request.SetRequestHeader("Authorization", "Bearer " + apiKey); yield return(request.SendWebRequest()); Destroy(this.gameObject); } }
private IEnumerator AddToShoppingListRoutine() { ConfirmDialog dialog = FindObjectOfType <ConfirmDialog>(); dialog.ApplyColours(); dialog.Show(); dialog.SetNone(); dialog.SetInfoMessage("Add all ingredients from each recipe to the shopping list?"); while (dialog.IsNone()) { yield return(null); } if (dialog.IsNo()) { dialog.Hide(); dialog.SetNone(); yield break; } if (dialog.IsYes()) { TMP_Text addButtonText = addButton.GetComponentInChildren <TMP_Text>(); addButtonText.text = "Please wait..."; addButton.interactable = false; dialog.Hide(); OnlineList shoppingList = FindObjectsOfType <OnlineList>().Where(x => x.GetListType().Equals(TodoistList.shoppingList)).First(); UnityWebRequest request = Postman.CreateGetRequest(Endpoints.instance.SHOPPING_LIST()); yield return(request.SendWebRequest()); JSONArray json = JSON.Parse(request.downloadHandler.text).AsArray; foreach (KeyValuePair <string, JSONNode> obj in json) { string item = obj.Value.Value; yield return(StartCoroutine(shoppingList.AddItemRoutine(item))); } shoppingList.Refresh(); dialog.SetNone(); addButton.interactable = true; addButtonText.text = "Add To Shopping List"; yield break; } }
private async void ClearButton_Click(object sender, RoutedEventArgs e) { if (!biliVM.CheckAccoutStatus()) { return; } if (ViewLaterCollection.Count == 0) { return; } var dialog = new ConfirmDialog("您确认清空稍后观看记录吗?"); dialog.PrimaryButtonClick += async(_s, _e) => { _e.Cancel = true; dialog.IsPrimaryButtonEnabled = false; dialog.PrimaryButtonText = "清空中..."; bool reuslt = await _account.ClearViewLaterAsync(); if (reuslt) { new TipPopup("清空成功").ShowMessage(); ViewLaterCollection.Clear(); HolderText.Visibility = Visibility.Visible; dialog.Hide(); } else { new TipPopup("清空失败").ShowError(); } dialog.PrimaryButtonText = "确认"; dialog.IsPrimaryButtonEnabled = true; }; await dialog.ShowAsync(); }