Beispiel #1
0
        public CurrentRally(Rally rallyData, TextSender textSender)
        {
            InitializeComponent();
            NavigationPage.SetHasNavigationBar(this, false);

            currentRally = rallyData;
            timer        = new RallyTimer(currentRally.end);
            this.sender  = textSender;

            rallyDictionary = new SemanticsDictionary(currentRally.invitation);
            currentRally.refreshInviteeSummary();
            RenderCurrentRallyUI(currentRally);

            MessagingCenter.Subscribe <App, string>(this, "textReceived", (sender, arg) => {
                analyzeTextMessage(arg);
            });
        }
        async void InitializeRallyUI(string invitation)
        {
            DateTime rallyStartTime = DateTime.Now;

            Rally newRally = new Rally
            {
                start      = rallyStartTime,
                end        = rallyStartTime.AddMinutes(10),
                invitation = invitation,
                invitees   = selectedContacts
            };

            newRally.refreshInviteeSummary();

            List <Rally> rallyList = JsonConvert.DeserializeObject <List <Rally> >(Application.Current.Properties["RallyList"] as string);

            rallyList.Add(newRally);
            Application.Current.Properties["RallyList"] = JsonConvert.SerializeObject(rallyList);

            var newRallyPage = new CurrentRally(newRally, sender);
            await Navigation.PushAsync(newRallyPage);

            MessagingCenter.Send <RallySetupPage>(this, "RallyStarted");
        }
Beispiel #3
0
        void RenderCurrentRallyUI(Rally currentRally)
        {
            Grid upperLayout = new Grid
            {
                HorizontalOptions    = LayoutOptions.FillAndExpand,
                MinimumHeightRequest = 100
            };

            upperLayout.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            upperLayout.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            upperLayout.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(2, GridUnitType.Star)
            });
            upperLayout.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });

            Label timerLabel = new Label
            {
                TextColor         = Color.Black,
                FontSize          = 40,
                FontAttributes    = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.CenterAndExpand
            };

            timerLabel.BindingContext = timer;
            timerLabel.SetBinding(Label.TextProperty, "TimerString");
            upperLayout.Children.Add(timerLabel, 1, 0);

            Button messageInviteesButton = new Button
            {
                Text              = "\U00002709",
                FontSize          = 20,
                FontAttributes    = FontAttributes.Bold,
                TextColor         = Color.Black,
                HorizontalOptions = LayoutOptions.End
            };

            messageInviteesButton.Clicked += delegate
            {
                openNewMessagePage();
            };
            upperLayout.Children.Add(messageInviteesButton, 2, 0);

            parentLayout.Children.Add(upperLayout);

            Label invitation = new Label
            {
                Text              = currentRally.invitation,
                TextColor         = Color.Black,
                FontSize          = 20,
                FontAttributes    = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.Center
            };

            parentLayout.Children.Add(invitation);

            Label summary = new Label
            {
                TextColor         = Color.Black,
                FontSize          = 20,
                HorizontalOptions = LayoutOptions.CenterAndExpand
            };

            summary.BindingContext = currentRally;
            summary.SetBinding(Label.TextProperty, "inviteeSummary");
            parentLayout.Children.Add(summary);

            Picker sortPicker = new Picker
            {
                Title             = "Sort by",
                TextColor         = Color.Black,
                FontSize          = 20,
                HorizontalOptions = LayoutOptions.Fill,
                BackgroundColor   = Color.Transparent
            };

            sortPicker.Items.Add("Sort A-Z");
            sortPicker.Items.Add("Sort Z-A");
            sortPicker.Items.Add("Show Only Accepted");
            sortPicker.Items.Add("Show Only Declined");
            sortPicker.Items.Add("Show Only Undetermined");
            sortPicker.Items.Add("Show Only Unreplied");

            sortPicker.SelectedIndexChanged += delegate
            {
                switch (sortPicker.SelectedIndex)
                {
                case 0:
                    visibleInviteeList = currentRally.invitees.OrderBy(i => i.Name).ToList();
                    refreshVisibleInviteeList();
                    break;

                case 1:
                    visibleInviteeList = currentRally.invitees.OrderByDescending(i => i.Name).ToList();
                    refreshVisibleInviteeList();
                    break;

                case 2:
                    visibleInviteeList = currentRally.invitees.Where(i => (i.Status == 3)).ToList();
                    refreshVisibleInviteeList();
                    break;

                case 3:
                    visibleInviteeList = currentRally.invitees.Where(i => (i.Status == 2)).ToList();
                    refreshVisibleInviteeList();
                    break;

                case 4:
                    visibleInviteeList = currentRally.invitees.Where(i => (i.Status == 1)).ToList();
                    refreshVisibleInviteeList();
                    break;

                case 5:
                    visibleInviteeList = currentRally.invitees.Where(i => (i.Status == 0)).ToList();
                    refreshVisibleInviteeList();
                    break;
                }
            };
            sortPicker.SelectedIndex = 0;

            parentLayout.Children.Add(sortPicker);

            inviteeScrollView = new ScrollView {
                BackgroundColor = Color.Transparent
            };
            inviteeStack = new StackLayout {
                Orientation = StackOrientation.Vertical
            };

            foreach (RallyContact invitee in visibleInviteeList)
            {
                StackLayout inviteeStackTemplate = new StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    Margin      = new Thickness(10)
                };

                Button inviteeTemplate = new Button
                {
                    Text              = invitee.Name,
                    TextColor         = Color.Black,
                    FontSize          = 20,
                    HorizontalOptions = LayoutOptions.StartAndExpand,
                    BackgroundColor   = Color.Transparent
                };

                Button semanticDisplayButton = new Button
                {
                    HorizontalOptions = LayoutOptions.End,
                    BackgroundColor   = Color.Transparent,
                    TextColor         = Color.Black,
                    FontSize          = 20
                };
                semanticDisplayButton.Clicked += delegate
                {
                    invitee.incrementStatus();
                    currentRally.refreshInviteeSummary();
                };
                semanticDisplayButton.BindingContext = invitee;
                semanticDisplayButton.SetBinding(Button.TextProperty, "StatusString");

                /*ImageButton statusTemplate = new ImageButton
                 * {
                 *  Source = "checkMark.png"
                 * };*/

                //statusButtons.Add(semanticDisplayButton);

                inviteeStackTemplate.Children.Add(inviteeTemplate);
                inviteeStackTemplate.Children.Add(semanticDisplayButton);

                inviteeStack.Children.Add(inviteeStackTemplate);
            }
            inviteeScrollView.Content = inviteeStack;
            parentLayout.Children.Add(inviteeScrollView);

            Label errorLabel = new Label
            {
                IsVisible         = false,
                HorizontalOptions = LayoutOptions.Center
            };

            parentLayout.Children.Add(errorLabel);

            this.Content = parentLayout;
        }
Beispiel #4
0
 async public void startRally(Rally selectedRally)
 {
     await Navigation.PushAsync(new CurrentRally(selectedRally, sender));
 }