Ejemplo n.º 1
0
        // Try to Load The Board
        private async Task LoadBoard()
        {
            List <TrelloBoard> aaa = await TrelloRepository.GetTrelloBoards();

            if (aaa == null)
            {
                // RnD: color patching =)
                //lvwBoards.BackgroundColor = Color.Green;

                // RnD :show settings ONLY ONCE (on First Init)
                if (App.FirstInit)
                {
                    Navigation.PushAsync(new NoConnectionPage());
                }
                else
                {
                    lvwBoards.BackgroundColor = Color.Gray;
                    lvwBoards.ItemsSource     = null;

                    // show (enable) Settings button
                    Settings.IsEnabled = true;
                    Settings.IsVisible = true;
                }
            }
            else
            {
                lvwBoards.BackgroundColor = Color.White;
                lvwBoards.ItemsSource     = aaa;
                //Debug.WriteLine("lvwBoards.ItemsSource: " + lvwBoards.ItemsSource);

                // All is OK - hide (disable) Settings button
                Settings.IsEnabled = true; //false;
                Settings.IsVisible = true; //false;
            }
        }//LoadBoard end
        private async void btnCloseCard_Clicked(object sender, EventArgs e)
        {
            TrelloCard card = (sender as Button).BindingContext as TrelloCard;

            card.IsClosed = true;
            await TrelloRepository.UpdateCardAsync(card);

            loadListAsync();
        }
        //fill the listview with favorite shoes from trello API
        private async Task getlists(Xamarin.Forms.ListView lvw)
        {
            lvw.ItemsSource = "";

            string            listId      = "5fd4e03623dc8d8494238fd9";
            List <TrelloCard> trelloCards = await TrelloRepository.GetTrelloCardAsync(listId);

            lvw.ItemsSource = await TrelloRepository.GetTrelloCardAsync(listId);
        }
        private async Task addcard(Results2 result)
        {
            await DisplayAlert("Alert", "You added this shoe as favorite", "OK");

            string     listId  = "5fd4e03623dc8d8494238fd9";
            TrelloCard newCard = new TrelloCard {
                name = result.Name, CardDesc = result.ImgUrl, IsClosed = false
            };
            await TrelloRepository.AddCardAsync(listId, newCard);
        }
        private async Task DeleteCard(TrelloCard e)
        {
            bool answer = await DisplayAlert("Are you sure?", "Would you like to delete this shoe as favorite ?", "Yes", "No");

            if (answer == true)
            {
                await TrelloRepository.DeleteCardAsync(e.CardId);

                getlists(lvwTrelloLists);
            }
        }
        private async void btnSave_Clicked(object sender, EventArgs e)
        {
            TrelloCard card = new TrelloCard()
            {
                Name = editName.Text
            };

            if (IsNewCard)
            {
                await TrelloRepository.AddCardAsync(this.Card.List.ListId, card);
            }
            else
            {
                Card.Name = card.Name;
                await TrelloRepository.UpdateCardAsync(Card);
            }
            Navigation.PopAsync();
        }
        private async Task loadMemberAsync()
        {
            TrelloMember tm = await TrelloRepository.GetMemberDataAsync(this.Card);

            lblFullName.Text = tm.FullName;


            //imgAvatar.Source = tm.AvatarImg;

            //HttpClient client = new HttpClient();
            //Stream stream = await client.GetStreamAsync(tm.AvatarImg);
            //imgAvatar.Source = ImageSource.FromStream(() => stream);

            imgAvatar.Source = new UriImageSource()
            {
                Uri            = new Uri(tm.gravatarHash),
                CachingEnabled = false
            };
            lblUsername.Text = tm.UserName;
        }
        private async Task TestModels()
        {
            List <TrelloBoard> list = new List <TrelloBoard>();

            list = await TrelloRepository.GetTrelloBoards();

            foreach (TrelloBoard item in list)
            {
                Debug.WriteLine(item.Name);
                List <TrelloList> l = new List <TrelloList>();
                l = await TrelloRepository.GetTrelloListsAsync(item.BoardId);

                foreach (TrelloList tl in l)
                {
                    TrelloCard card = new TrelloCard()
                    {
                        Name = "Testerdetesterdetest"
                    };
                    await TrelloRepository.AddCardAsync(tl.ListId, card);

                    Debug.WriteLine($"Listname: {tl.Name}");
                    List <TrelloCard> ltc = new List <TrelloCard>();
                    ltc = await TrelloRepository.GetTrelloCardsAsync(tl.ListId);

                    foreach (TrelloCard c in ltc)
                    {
                        Debug.WriteLine($"Cardname: {c.Name}");
                    }
                }
            }
            TrelloBoard b = list.Where(x => x.IsFavorite == true).ToList <TrelloBoard>().First();

            if (b != null)
            {
                Debug.WriteLine(b.Name);
            }
        }
        private async Task loadListAsync()
        {
            lvwCards.ItemsSource = await TrelloRepository.GetTrelloCardsAsync(List.ListId);

            lblListName.Text = List.Name;
        }
 private async Task LoadBord()
 {
     lvwBoards.ItemsSource = await TrelloRepository.GetTrelloBoards();
 }
        private async Task loadBordAsync()
        {
            lvwTrelloLists.ItemsSource = await TrelloRepository.GetTrelloListsAsync(Board.BoardId);

            //lvwBoards.ItemsSource = await TrelloRepository.GetTrelloBoards();
        }