private static Grid GenerateTopGrid()
        {
            var leftStack = new MarginFrame(20)
            {
                Content = new StackLayout
                {
                    Children =
                    {
                        new Label
                        {
                            HorizontalTextAlignment = TextAlignment.Center,
                            Text = "LaunchPal Plus"
                        },
                        new Label
                        {
                            HorizontalTextAlignment = TextAlignment.Start,
                            Text =
                                $"With LaunchPal Plus you get even more out of the app and at a low, one time cost to enchance your experiance even more.{Environment.NewLine}{Environment.NewLine}" +
                                $"Some functions it enables is for example the all new weather forecasts, free search of any planed or launches mission and enable in app viewing of the launch and sattelite view of the launchpad.{Environment.NewLine}{Environment.NewLine}" +
                                $"So get it now, more awsome stuff is on its way!"
                        }
                    }
                }
            };

            var rightStack = new MarginFrame(20)
            {
                Content = new MarginFrame(0, Theme.FrameColor)
                {
                    Content = new StackLayout
                    {
                        VerticalOptions = LayoutOptions.Center,
                        HorizontalOptions = LayoutOptions.Center,
                        Children =
                        {
                            new Label
                            {
                                HorizontalTextAlignment = TextAlignment.Center,
                                Text = "Now only",
                                TextColor = Theme.HeaderColor,
                                FontSize = 22
                            },
                            new Label
                            {
                                HorizontalTextAlignment = TextAlignment.Center,
                                Text = "2 USD / 2 Euro",
                                TextColor = Theme.HeaderColor,
                                FontSize = 20
                            }
                        }
                    }
                }
            };

            var topGrid =  new Grid
            {
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition {Width = new GridLength(1, GridUnitType.Star)},
                    new ColumnDefinition {Width = new GridLength(1, GridUnitType.Star)},
                    new ColumnDefinition {Width = new GridLength(1, GridUnitType.Star)},
                    new ColumnDefinition {Width = new GridLength(1, GridUnitType.Star)}
                }
            };

            topGrid.Children.Add(leftStack, 0, 3, 0, 1);
            topGrid.Children.Add(rightStack, 3, 0);

            return topGrid;
        }
Beispiel #2
0
            internal static MarginFrame GenerateAstronautsInSpaceFrame()
            {
                var astronautsCount = new Label { HorizontalTextAlignment = TextAlignment.Center, FontAttributes = FontAttributes.Bold, TextColor = Theme.LinkColor, FontSize = 18 };
                astronautsCount.SetBinding(Label.TextProperty, new Binding("AstronautsInSpace"));
                var astronautsLabel = new Label { HorizontalTextAlignment = TextAlignment.Center, TextColor = Theme.TextColor, FontSize = 18, FontAttributes = FontAttributes.Bold };
                astronautsLabel.SetBinding(Label.TextProperty, new Binding("AstronoutsInSpaceLabel"));

                var astronautsInSpaceFrame = new MarginFrame(10, Theme.BackgroundColor)
                {
                    Content = new Frame()
                    {
                        GestureRecognizers = { OverviewPage.NavigateToPageWhenTaped(typeof(AstronautsPage)) },
                        BackgroundColor = Theme.FrameColor,
                        OutlineColor = Theme.FrameBorderColor,
                        Content = new StackLayout
                        {
                            Children =
                            {
                                astronautsLabel,
                                astronautsCount
                            }
                        }
                    }
                };

                return astronautsInSpaceFrame;
            }
        public NewsListTemplate(IReadOnlyList<NewsFeed> newsFeed)
        {
            ItemsSource = newsFeed;
            VerticalOptions = LayoutOptions.FillAndExpand;
            BackgroundColor = Theme.BackgroundColor;
            SeparatorColor = Theme.FrameColor;
            HasUnevenRows = true;

            var menuDataTemplate = new DataTemplate(() =>
            {
                var grid = new 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.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });

                grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) });
                grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) });
                grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) });

                var titleLabel = new Label
                {
                    VerticalOptions = LayoutOptions.Center,
                    TextColor = Theme.TextColor,
                    FontSize = Device.OnPlatform(16, 20, 16),
                    FontAttributes = FontAttributes.Bold,
                    HorizontalTextAlignment = TextAlignment.Start
                };
                var publishedLabel = new Label
                {
                    VerticalOptions = LayoutOptions.Center,
                    HorizontalTextAlignment = TextAlignment.End,
                    TextColor = Theme.TextColor,
                    FontSize = 12,
                    FontAttributes = FontAttributes.Italic
                };
                var leadLabel = new Label
                {
                    VerticalOptions = LayoutOptions.Center,
                    TextColor = Theme.TextColor,
                    FontSize = 14,
                };
                var authorLabel = new Label
                {
                    VerticalOptions = LayoutOptions.Center,
                    HorizontalTextAlignment = TextAlignment.Start,
                    TextColor = Theme.TextColor,
                    FontSize = 14,
                };
                var sourceLabel = new Label
                {
                    VerticalOptions = LayoutOptions.Center,
                    HorizontalTextAlignment = TextAlignment.End,
                    TextColor = Theme.TextColor,
                    FontSize = 16,
                    FontAttributes = FontAttributes.Bold
                };

                titleLabel.SetBinding(Label.TextProperty, "Title");
                leadLabel.SetBinding(Label.TextProperty, "Lead");
                authorLabel.SetBinding(Label.TextProperty, "Author");
                sourceLabel.SetBinding(Label.TextProperty, "Source");
                publishedLabel.SetBinding(Label.TextProperty, "PublishedString");

                grid.Children.Add(titleLabel, 0, 0);
                grid.Children.Add(publishedLabel, 3, 0);
                grid.Children.Add(leadLabel, 0, 1);
                grid.Children.Add(authorLabel, 0, 2);
                grid.Children.Add(sourceLabel, 2, 2);
                

                Grid.SetColumnSpan(titleLabel, 3);
                Grid.SetColumnSpan(publishedLabel, 1);
                Grid.SetColumnSpan(leadLabel, 4);
                Grid.SetColumnSpan(authorLabel, 2);
                Grid.SetColumnSpan(sourceLabel, 2);
                

                var contentFrame = new MarginFrame(5, Theme.BackgroundColor)
                {
                    Content = new Frame
                    {
                        OutlineColor = Theme.FrameColor,
                        BackgroundColor = Theme.BackgroundColor,
                        VerticalOptions = LayoutOptions.Center,
                        Padding = new Thickness(5),
                        Content = grid,
                        Margin = new Thickness(0, 0, 12, 0),
                    }
                };

                return new ViewCell { View = contentFrame };
            });

            var cell = new DataTemplate(typeof(ViewCell));
            cell.SetBinding(TextCell.TextProperty, "Title");
            cell.SetValue(TextCell.TextColorProperty, Color.FromHex("2f4f4f"));

            ItemTemplate = menuDataTemplate;
            SelectedItem = newsFeed.Count != 0 ? newsFeed[0] : null;
        }
Beispiel #4
0
            internal static MarginFrame SetLaunchesThisMonth()
            {
                var launchThisMonthLabel = new Label { HorizontalTextAlignment = TextAlignment.Center, TextColor = Theme.TextColor, FontSize = 18, FontAttributes = FontAttributes.Bold };
                launchThisMonthLabel.SetBinding(Label.TextProperty, new Binding("CurrentMonth"));
                var launchesThisMonthLabel = new Label { HorizontalTextAlignment = TextAlignment.Center, FontAttributes = FontAttributes.Bold, TextColor = Theme.LinkColor, FontSize = 18 };
                launchesThisMonthLabel.SetBinding(Label.TextProperty, new Binding("LaunchesThisMonthLabel"));

                var launchesThisMonthFrame = new MarginFrame(10, Theme.BackgroundColor)
                {
                    Content = new Frame()
                    {
                        GestureRecognizers = { OverviewPage.NavigateToPageWhenTaped(typeof(SearchPage), OverviewPage.Context.LaunchesThisMonth, OrderBy.Net) },
                        BackgroundColor = Theme.FrameColor,
                        OutlineColor = Theme.FrameBorderColor,
                        Content = new StackLayout
                        {
                            Children =
                            {
                                launchThisMonthLabel,
                                launchesThisMonthLabel
                            }
                        }
                    }
                };

                return launchesThisMonthFrame;
            }
        public SearchListTemplate(IReadOnlyList<LaunchData> launchList, OrderBy order)
        {
            IEnumerable<SimpleLaunchData> simpleLaunchList = null;

            switch (order)
            {
                case OrderBy.Net:
                    simpleLaunchList = launchList.Select(launchPair => new SimpleLaunchData
                    {
                        LaunchId = launchPair.Launch.Id,
                        Name = launchPair.Launch.Name,
                        Net = launchPair.Launch.Status == 2
                    ? DateTime.Now.AddMonths(1).AddDays(-1)
                    : TimeConverter.DetermineTimeSettings(launchPair.Launch.Net, App.Settings.UseLocalTime),
                        LaunchNet = launchPair.Launch.Status == 2 || launchPair.Launch.Status == 0 && launchPair.Launch.Net.TimeOfDay.Ticks == 0
                        ? "TBD"
                        : TimeConverter.SetStringTimeFormat(launchPair.Launch.Net, App.Settings.UseLocalTime)
                    }).OrderBy(x => x.Net).ToList();

                    break;
                case OrderBy.Status:
                    var statusGoList = launchList.Where(x => LaunchStatusEnum.GetLaunchStatusById(x.Launch.Status) == LaunchStatus.Go).Select(launchPair => new SimpleLaunchData
                    {
                        LaunchId = launchPair.Launch.Id,
                        Name = launchPair.Launch.Name,
                        Net = launchPair.Launch.Status == 2
                    ? DateTime.Now.AddMonths(1).AddDays(-1)
                    : TimeConverter.DetermineTimeSettings(launchPair.Launch.Net, App.Settings.UseLocalTime),
                        LaunchNet = launchPair.Launch.Status == 2 || launchPair.Launch.Status == 0 && launchPair.Launch.Net.TimeOfDay.Ticks == 0
                        ? "TBD"
                        : TimeConverter.SetStringTimeFormat(launchPair.Launch.Net, App.Settings.UseLocalTime)
                    }).OrderBy(x => x.Net).ToList();

                    var statusHoldList = launchList.Where(x => LaunchStatusEnum.GetLaunchStatusById(x.Launch.Status) != LaunchStatus.Go).Select(launchPair => new SimpleLaunchData
                    {
                        LaunchId = launchPair.Launch.Id,
                        Name = launchPair.Launch.Name,
                        Net = launchPair.Launch.Status == 2
                            ? DateTime.Now.AddMonths(1).AddDays(-1)
                            : TimeConverter.DetermineTimeSettings(launchPair.Launch.Net, App.Settings.UseLocalTime),
                        LaunchNet = launchPair.Launch.Status == 2 || launchPair.Launch.Status == 0 && launchPair.Launch.Net.TimeOfDay.Ticks == 0
                        ? "TBD"
                        : TimeConverter.SetStringTimeFormat(launchPair.Launch.Net, App.Settings.UseLocalTime)
                    }).OrderBy(x => x.Net).ToList();

                    simpleLaunchList = statusGoList.Concat(statusHoldList);

                    break;
                default:
                    throw new ArgumentOutOfRangeException(nameof(order), order, null);
            }

            ItemsSource = simpleLaunchList;
            VerticalOptions = LayoutOptions.FillAndExpand;
            BackgroundColor = Theme.BackgroundColor;
            SeparatorColor = Theme.FrameColor;
            HasUnevenRows = true;

            var menuDataTemplate = new DataTemplate(() =>
            {
                var nameLabel = new Label
                {
                    VerticalOptions = LayoutOptions.Center,
                    TextColor = Theme.TextColor,
                    FontSize = Device.OnPlatform(16, 20, 16),
                    FontAttributes = FontAttributes.Bold
                };
                var netLabel = new Label
                {
                    VerticalOptions = LayoutOptions.Center,
                    TextColor = Theme.TextColor,
                    FontSize = 14,
                };

                nameLabel.SetBinding(Label.TextProperty, "Name");
                netLabel.SetBinding(Label.TextProperty, "LaunchNet");

                var layout = new StackLayout
                {
                    Orientation = StackOrientation.Vertical,
                    VerticalOptions = LayoutOptions.Center,
                    Children =
                    {
                        nameLabel,
                        netLabel
                    }
                };

                var searchFrame = new MarginFrame(5, Theme.BackgroundColor)
                {
                    Content = new Frame
                    {
                        OutlineColor = Theme.FrameColor,
                        BackgroundColor = Theme.BackgroundColor,
                        VerticalOptions = LayoutOptions.Center,
                        Padding = new Thickness(5),
                        Content = layout,
                        Margin = new Thickness(0, 0, 12, 0),
                    }
                };

                return new ViewCell { View = searchFrame };
            });

            var cell = new DataTemplate(typeof(ViewCell));
            cell.SetBinding(TextCell.TextProperty, "Name");
            cell.SetValue(TextCell.TextColorProperty, Color.FromHex("2f4f4f"));

            ItemTemplate = menuDataTemplate;
            SelectedItem = launchList.Count != 0 ? launchList[0] : null;
            Margin = new Thickness(0, 0, 0, 30);
        }