Ejemplo n.º 1
0
        public bool allCompetitions()
        {
            TaskRepos          rep   = new TaskRepos();
            List <Assets.Task> tasks = rep.getTasks();

            if (tasks.Count() > 0)
            {
                foreach (var item in tasks)
                {
                    Label.Text += item.TaskName + "\n";
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        public CompetitionDetails(Competition selectedComp)
        {
            User   creator        = MySQLManager.LoadUsers().Where(x => x.id == selectedComp.fk_CreatorId).FirstOrDefault();
            Button FavoriteButton = new Button
            {
                Text              = "☆",
                HeightRequest     = 50,
                WidthRequest      = 50,
                FontSize          = 25,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                TextColor         = Color.Yellow,
                BackgroundColor   = Color.LightGray
            };

            Button editButton  = new Button();
            Button EnterButton = new Button();


            TaskRepos   rep   = new TaskRepos();
            List <Task> tasks = rep.getTasks(selectedComp.Id);

            editButton.IsVisible  = false;
            EnterButton.IsVisible = false;

            if (creator.id == Session.Id)
            {
                editButton = new Button()
                {
                    IsVisible         = true,
                    Text              = "Edit",
                    BackgroundColor   = Color.White,
                    BorderColor       = Color.Black,
                    BorderWidth       = 3,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    VerticalOptions   = LayoutOptions.CenterAndExpand,
                };
            }
            else
            {
                EnterButton = new Button()
                {
                    IsVisible         = true,
                    Text              = "Enter",
                    BackgroundColor   = Color.White,
                    BorderColor       = Color.Black,
                    BorderWidth       = 3,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    VerticalOptions   = LayoutOptions.CenterAndExpand,
                };
            }

            Entry commentEntry = new Entry()
            {
                IsVisible         = false,
                BackgroundColor   = Color.White,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                WidthRequest      = 200,
                HeightRequest     = 200
            };

            Button PostCommentButton = new Button()
            {
                Text              = "Post",
                BackgroundColor   = Color.White,
                BorderColor       = Color.Black,
                BorderWidth       = 3,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
            };

            if (isFavorited(selectedComp))
            {
                FavoriteButton.BackgroundColor = Color.Orange;
            }

            FavoriteButton.Clicked    += async(sender, args) => FavoriteButtonOnClick(sender, args, FavoriteButton, selectedComp);
            PostCommentButton.Clicked += async(sender, args) => PostCommentOnClick(sender, args, commentEntry, selectedComp);
            EnterButton.Clicked       += async(sender, args) => await EnterButtonOnClick(sender, args, selectedComp);

            editButton.Clicked += async(sender, args) => await EditButtonClick(sender, args, editButton, selectedComp);

            List <User> users = MySQLManager.LoadUsers();
            User        usr   = users.Where(x => x.id == selectedComp.fk_CreatorId).FirstOrDefault();

            StackLayout C = new StackLayout();

            C.Children.Add(new Label {
                Text = selectedComp.Name, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand
            });
            C.Children.Add(new Label {
                Text = $"Created by: {usr.username}", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand
            });
            C.Children.Add(new Label {
                Text = $"{selectedComp.Description}", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand
            });
            C.Children.Add(new Label {
                Text = $"Total tasks: {tasks.Count}", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand
            });
            C.Children.Add(FavoriteButton);
            C.Children.Add(editButton);
            C.Children.Add(EnterButton);
            C.Children.Add(new Label {
                Text = $"Comments:", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand
            });
            C.Children.Add(commentEntry);
            C.Children.Add(PostCommentButton);

            List <Comment> comments = MySQLManager.LoadCommentByCompetition(selectedComp.Id);


            foreach (var item in comments)
            {
                try
                {
                    C.Children.Add(new Label
                    {
                        Text = $"{users.Where(x => x.id == item.fk_Usersid).FirstOrDefault().username}:{comments.Count}\n" +
                               $"{item.Commentaras}\n{item.Date}",
                        HorizontalOptions = LayoutOptions.CenterAndExpand,
                        VerticalOptions   = LayoutOptions.CenterAndExpand,
                        WidthRequest      = 200,
                        HeightRequest     = 150
                    });
                }
                catch
                {
                    continue;
                }
            }

            ScrollView scrollView = new ScrollView
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Content         = C
            };

            Content = scrollView;
        }
Ejemplo n.º 3
0
        public CompetitionTasksList(int ind, Competition competition)
        {
            Button editButton = new Button();

            editButton.IsVisible = false;
            editButton           = new Button()
            {
                IsVisible         = true,
                Text              = "Edit",
                BackgroundColor   = Color.White,
                BorderColor       = Color.Black,
                BorderWidth       = 3,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
            };
            Button butt = new Button
            {
                Text              = "Next page",
                BackgroundColor   = Color.White,
                BorderColor       = Color.Black,
                BorderWidth       = 3,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand
            };

            Label = new Label
            {
                IsVisible         = false,
                TextColor         = Color.Red,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand
            };

            TaskRepos          rep   = new TaskRepos();
            List <Assets.Task> tasks = rep.getTasks(competition.Id);


            Button task1 = new Button();
            Button task2 = new Button();
            Button task3 = new Button();
            Button task4 = new Button();
            Button task5 = new Button();

            task1.IsVisible = false;
            task2.IsVisible = false;
            task3.IsVisible = false;
            task4.IsVisible = false;
            task5.IsVisible = false;


            if (tasks.Count >= ind * 5 + 1)
            {
                task1 = new Button()
                {
                    IsVisible         = true,
                    Text              = $"{tasks[ind * 5].TaskName}",
                    BackgroundColor   = Color.White,
                    BorderColor       = Color.Black,
                    BorderWidth       = 3,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    VerticalOptions   = LayoutOptions.CenterAndExpand,
                    WidthRequest      = 250
                };
            }
            if (tasks.Count >= ind * 5 + 2)
            {
                task2 = new Button()
                {
                    IsVisible         = true,
                    Text              = $"{tasks[ind * 5 + 1].TaskName}",
                    BackgroundColor   = Color.White,
                    BorderColor       = Color.Black,
                    BorderWidth       = 3,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    VerticalOptions   = LayoutOptions.CenterAndExpand,
                    WidthRequest      = 250
                };
            }
            if (tasks.Count >= ind * 5 + 3)
            {
                task3 = new Button()
                {
                    IsVisible         = true,
                    Text              = $"{tasks[ind * 5 + 2].TaskName}",
                    BackgroundColor   = Color.White,
                    BorderColor       = Color.Black,
                    BorderWidth       = 3,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    VerticalOptions   = LayoutOptions.CenterAndExpand,
                    WidthRequest      = 250
                };
            }
            if (tasks.Count >= ind * 5 + 4)
            {
                task4 = new Button()
                {
                    IsVisible         = true,
                    Text              = $"{tasks[ind * 5 + 3].TaskName}",
                    BackgroundColor   = Color.White,
                    BorderColor       = Color.Black,
                    BorderWidth       = 3,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    VerticalOptions   = LayoutOptions.CenterAndExpand,
                    WidthRequest      = 250
                };
            }
            if (tasks.Count >= ind * 5 + 5)
            {
                task5 = new Button()
                {
                    IsVisible         = true,
                    Text              = $"{tasks[ind * 5 + 4].TaskName}",
                    BackgroundColor   = Color.White,
                    BorderColor       = Color.Black,
                    BorderWidth       = 3,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    VerticalOptions   = LayoutOptions.CenterAndExpand,
                    WidthRequest      = 250
                };
            }

            bool allow = task1.IsVisible && task2.IsVisible && task3.IsVisible && task4.IsVisible && task5.IsVisible;

            task1.Clicked += async(sender, args) => await GoToEditTask(sender, args, tasks[0 * ind], competition);

            task2.Clicked += async(sender, args) => await GoToEditTask(sender, args, tasks[1 * ind], competition);

            task3.Clicked += async(sender, args) => await GoToEditTask(sender, args, tasks[2 * ind], competition);

            task4.Clicked += async(sender, args) => await GoToEditTask(sender, args, tasks[3 * ind], competition);

            task5.Clicked += async(sender, args) => await GoToEditTask(sender, args, tasks[4 * ind], competition);

            ScrollView scrollView = new ScrollView
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Content         = new StackLayout
                {
                    Children =
                    {
                        new Label {
                            Text = "Tasks list", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand
                        },
                        Label,
                        task1,
                        task2,
                        task3,
                        task4,
                        task5,
                        butt
                    }
                }
            };

            Content = scrollView;
        }