Пример #1
0
        StackLayout buildContent()
        {
            StackLayout content = new StackLayout();

            List <View> gridViews = new List <View>();
            var         grid      = new Grid {
                HeightRequest = 750,
                WidthRequest  = 500
            };

            //Setup a 2xA grid
            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });

            Color textCol;

            if (c.getLightMode())
            {
                textCol = Color.Black;
            }
            else
            {
                textCol = Color.White;
            }

            Switch darkMode = new Switch()
            {
                IsToggled = (!c.getLightMode()), HorizontalOptions = LayoutOptions.Center
            };

            endTime = new Entry {
                Keyboard = Keyboard.Numeric, Margin = 5, TextColor = textCol, FontSize = 18, MinimumHeightRequest = 20, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand
            };
            alertTypePicker = new Picker {
                ItemsSource = alertTypes, Margin = 5, SelectedIndex = 0, TextColor = textCol, FontSize = 18, MinimumHeightRequest = 20, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand
            };
            proximityEntry = new Entry {
                Keyboard = Keyboard.Numeric, Margin = 5, TextColor = textCol, FontSize = 18, MinimumHeightRequest = 20, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand
            };

            gridViews.Add(new Label()
            {
                Text = "Toggle dark mode", Margin = 5, TextColor = textCol, FontSize = 18, MinimumHeightRequest = 20, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand
            });
            gridViews.Add(darkMode);
            gridViews.Add(new Label()
            {
                Text = "\nDefault alert settings", Margin = 5, TextColor = textCol, FontSize = 18, MinimumHeightRequest = 20, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand
            });
            gridViews.Add(new Label {
                Text = "Alert type", Margin = 5, TextColor = textCol, FontSize = 18, MinimumHeightRequest = 20, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand
            });
            gridViews.Add(alertTypePicker);
            gridViews.Add(new Label {
                Text = "Proximity (m)", Margin = 5, TextColor = textCol, FontSize = 18, MinimumHeightRequest = 20, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand
            });
            gridViews.Add(proximityEntry);
            gridViews.Add(new Label {
                Text = "Duration (mins)", Margin = 5, TextColor = textCol, FontSize = 18, MinimumHeightRequest = 20, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand
            });
            gridViews.Add(endTime);

            //Add views to grid
            grid.Children.Add(gridViews[0], 0, 0);
            grid.Children.Add(gridViews[1], 2, 0);
            grid.Children.Add(gridViews[2], 0, 1);
            grid.Children.Add(gridViews[3], 0, 2);
            grid.Children.Add(gridViews[4], 1, 2);
            grid.Children.Add(gridViews[5], 0, 3);
            grid.Children.Add(gridViews[6], 1, 3);
            grid.Children.Add(gridViews[7], 0, 4);
            grid.Children.Add(gridViews[8], 1, 4);

            //Set Spans
            Grid.SetColumnSpan(gridViews[0], 2);
            Grid.SetColumnSpan(gridViews[2], 3);
            Grid.SetColumnSpan(gridViews[4], 2);
            Grid.SetColumnSpan(gridViews[6], 2);
            Grid.SetColumnSpan(gridViews[8], 2);


            //Add the grid
            content.Children.Add(grid);

            Button saveSettingsButton = new Button()
            {
                Text = "Save settings"
            };

            if (c.getLightMode())
            {
                saveSettingsButton.BackgroundColor = Color.FromHex(c.getLightModeButtonColor());
                saveSettingsButton.TextColor       = Color.Black;
            }
            else
            {
                saveSettingsButton.BackgroundColor = Color.FromHex(c.getDarkModeButtonColor());
                saveSettingsButton.TextColor       = Color.White;
            }
            saveSettingsButton.Clicked += SaveSettingsButton_Clicked;
            content.Children.Add(saveSettingsButton);

            return(content);
        }
Пример #2
0
        StackLayout BuildContent()
        {
            //Create content
            StackLayout content = new StackLayout();

            //Add the "Defaults button"
            var defaults = new Button();

            defaults.Text = "Use Defaults";
            if (c.getLightMode())
            {
                defaults.BackgroundColor = Color.FromHex(c.getLightModeButtonColor());
                defaults.TextColor       = Color.Black;
            }
            else
            {
                defaults.BackgroundColor = Color.FromHex(c.getDarkModeButtonColor());
                defaults.TextColor       = Color.White;
            }
            defaults.Clicked += async(sender, args) => DefaultsButtonClicked();
            content.Children.Add(defaults);

            //Create a list of views and a grid for the views
            gridViews = new List <View>();
            var grid = new Grid {
                HeightRequest = 750,
                WidthRequest  = 500
            };

            //Setup a 2xA grid
            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });

            Color textCol;

            if (c.getLightMode())
            {
                textCol = Color.Black;
            }
            else
            {
                textCol = Color.White;
            }

            //Add variable views
            TimeSpan ts = DateTime.Now.TimeOfDay;

            ts.Add(TimeSpan.FromHours(1));
            endTime = new TimePicker {
                Time = (ts), Margin = 5, TextColor = textCol, FontSize = 18, MinimumHeightRequest = 20, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand
            };
            alertTypePicker = new Picker {
                Margin = 5, SelectedIndex = 0, TextColor = textCol, FontSize = 18, MinimumHeightRequest = 20, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand
            };
            var items = new List <string>();

            foreach (string s in c.getAlertTypeDescriptions())
            {
                items.Add(s);
            }
            alertTypePicker.ItemsSource = items;

            //Add views
            gridViews.Add(new Label {
                Text = "Latitude", Margin = 5, TextColor = textCol, FontSize = 18, MinimumHeightRequest = 20, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand
            });
            gridViews.Add(new Label {
                Text = getLat(), Margin = 5, TextColor = textCol, FontSize = 18, MinimumHeightRequest = 20, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand
            });
            gridViews.Add(new Label {
                Text = "Longitude", Margin = 5, TextColor = textCol, FontSize = 18, MinimumHeightRequest = 20, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand
            });
            gridViews.Add(new Label {
                Text = getLon(), Margin = 5, TextColor = textCol, FontSize = 18, MinimumHeightRequest = 20, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand
            });
            gridViews.Add(new Label {
                Text = "Alert type", Margin = 5, TextColor = textCol, FontSize = 18, MinimumHeightRequest = 20, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand
            });
            gridViews.Add(alertTypePicker);
            gridViews.Add(new Label {
                Text = "End time", Margin = 5, TextColor = textCol, FontSize = 18, MinimumHeightRequest = 20, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand
            });
            gridViews.Add(endTime);

            //Add views to grid
            grid.Children.Add(gridViews[0], 0, 0);
            grid.Children.Add(gridViews[1], 1, 0);
            grid.Children.Add(gridViews[2], 0, 1);
            grid.Children.Add(gridViews[3], 1, 1);
            grid.Children.Add(gridViews[4], 0, 2);
            grid.Children.Add(gridViews[5], 1, 2);
            grid.Children.Add(gridViews[6], 0, 3);
            grid.Children.Add(gridViews[7], 1, 3);

            //Set Spans
            Grid.SetColumnSpan(gridViews[1], 2);
            Grid.SetColumnSpan(gridViews[3], 2);
            Grid.SetColumnSpan(gridViews[5], 2);
            Grid.SetColumnSpan(gridViews[7], 2);

            //Add the grid
            content.Children.Add(grid);

            //1st spacing label

            /*
             * Label l1 = new Label() {
             *  Text="",
             *  HeightRequest=25
             * };
             */

            //Add alert button
            var addAlertButton = new Button();

            addAlertButton.Text = "Add alert";
            if (c.getLightMode())
            {
                addAlertButton.BackgroundColor = Color.FromHex(c.getLightModeButtonColor());
                addAlertButton.TextColor       = Color.Black;
            }
            else
            {
                addAlertButton.BackgroundColor = Color.FromHex(c.getDarkModeButtonColor());
                addAlertButton.TextColor       = Color.White;
            }
            addAlertButton.Clicked += async(sender, args) => CreateAlertButtonClicked();
            content.Children.Add(addAlertButton);

            return(content);
        }