protected override void SetupUserInterface()
        {
            Title = "Rx - Async to Observable";

            button1 = new Button {
                Text = "Call Service"
            };
            button1.SetDynamicResource(VisualElement.StyleProperty, Values.Styles.ReactiveButton);

            loading = new ActivityIndicator {
            };
            loading.SetDynamicResource(VisualElement.StyleProperty, Values.Styles.ReactiveActivityIndicator);

            Content = new StackLayout {
                Padding  = new Thickness(8d),
                Spacing  = 16d,
                Children =
                {
                    button1,
                    (outputLabel = new Label {
                        HorizontalTextAlignment = TextAlignment.Center,Text                                             = ""
                    }),
                    loading
                }
            };
        }
Beispiel #2
0
        public ReactiveUiLogin()
        {
            ViewModel = new EightBot.ReactiveExtensionExamples.ViewModels.Login();

            Title = "RxUI - Login";

            Content = new StackLayout {
                Padding  = new Thickness(40d),
                Children =
                {
                    (emailEntry           = new Entry             {
                        Placeholder       = "Email"
                    }),
                    (passwordEntry        = new Entry             {
                        Placeholder       = "Password", IsPassword = true
                    }),
                    (login                = new Button            {
                        Text              = "Login"
                    }),
                    (loading              = new ActivityIndicator {
                        HorizontalOptions = LayoutOptions.Center
                    }),
                }
            };

            emailEntry.SetDynamicResource(VisualElement.StyleProperty, Values.Styles.ReactiveEntry);
            passwordEntry.SetDynamicResource(VisualElement.StyleProperty, Values.Styles.ReactiveEntry);
            login.SetDynamicResource(VisualElement.StyleProperty, Values.Styles.ReactiveButton);
            loading.SetDynamicResource(VisualElement.StyleProperty, Values.Styles.ReactiveActivityIndicator);
        }
Beispiel #3
0
        public TrendsPage(TrendsViewModel trendsViewModel, TrendsChartSettingsService trendsChartSettingsService, Repository repository) : base(repository.Name, trendsViewModel)
        {
            _repository = repository;

            var referringSitesToolbarItem = new ToolbarItem {
                Text = "Referring Sites"
            };

            referringSitesToolbarItem.Clicked += HandleReferringSitesToolbarItemClicked;
            ToolbarItems.Add(referringSitesToolbarItem);

            TrendsChart.TotalViewsSeries.IsVisible        = trendsChartSettingsService.ShouldShowViewsByDefault;
            TrendsChart.TotalUniqueViewsSeries.IsVisible  = trendsChartSettingsService.ShouldShowUniqueViewsByDefault;
            TrendsChart.TotalClonesSeries.IsVisible       = trendsChartSettingsService.ShouldShowClonesByDefault;
            TrendsChart.TotalUniqueClonesSeries.IsVisible = trendsChartSettingsService.ShouldShowUniqueClonesByDefault;

            var activityIndicator = new ActivityIndicator();

            activityIndicator.SetDynamicResource(ActivityIndicator.ColorProperty, nameof(BaseTheme.RefreshControlColor));
            activityIndicator.SetBinding(IsVisibleProperty, nameof(TrendsViewModel.IsFetchingData));
            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(TrendsViewModel.IsFetchingData));

            var absoluteLayout = new AbsoluteLayout();

            absoluteLayout.Children.Add(activityIndicator, new Rectangle(.5, .5, -1, -1), AbsoluteLayoutFlags.PositionProportional);
            absoluteLayout.Children.Add(TrendsChart, new Rectangle(0, 0, 1, 1), AbsoluteLayoutFlags.All);

            Content = absoluteLayout;

            Padding = GetPadding();

            ViewModel.FetchDataCommand.Execute((_repository.OwnerLogin, _repository.Name));
        }
Beispiel #4
0
        public TrendsPage(TrendsViewModel trendsViewModel, TrendsChartSettingsService trendsChartSettingsService, Repository repository) : base(repository.Name, trendsViewModel)
        {
            _owner      = repository.OwnerLogin;
            _repository = repository.Name;

            TrendsChart.TotalViewsSeries.IsVisible        = trendsChartSettingsService.ShouldShowViewsByDefault;
            TrendsChart.TotalUniqueViewsSeries.IsVisible  = trendsChartSettingsService.ShouldShowUniqueViewsByDefault;
            TrendsChart.TotalClonesSeries.IsVisible       = trendsChartSettingsService.ShouldShowClonesByDefault;
            TrendsChart.TotalUniqueClonesSeries.IsVisible = trendsChartSettingsService.ShouldShowUniqueClonesByDefault;

            var activityIndicator = new ActivityIndicator();

            activityIndicator.SetDynamicResource(ActivityIndicator.ColorProperty, nameof(BaseTheme.RefreshControlColor));
            activityIndicator.SetBinding(IsVisibleProperty, nameof(TrendsViewModel.IsFetchingData));
            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(TrendsViewModel.IsFetchingData));

            var absoluteLayout = new AbsoluteLayout();

            absoluteLayout.Children.Add(activityIndicator, new Rectangle(.5, .5, -1, -1), AbsoluteLayoutFlags.PositionProportional);
            absoluteLayout.Children.Add(TrendsChart, new Rectangle(0, 0, 1, 1), AbsoluteLayoutFlags.All);

            Content = absoluteLayout;
        }
Beispiel #5
0
        public ReferringSitesPage(ReferringSitesViewModel referringSitesViewModel,
                                  Repository repository,
                                  AnalyticsService analyticsService) : base(PageTitles.ReferringSitesPage, referringSitesViewModel, analyticsService)
        {
            const int titleRowHeight = 50;
            const int titleTopMargin = 15;

            var collectionView = new CollectionView
            {
                AutomationId  = ReferringSitesPageAutomationIds.CollectionView,
                ItemTemplate  = new ReferringSitesDataTemplateSelector(),
                SelectionMode = SelectionMode.Single
            };

            collectionView.SelectionChanged += HandleCollectionViewSelectionChanged;
            collectionView.SetBinding(CollectionView.ItemsSourceProperty, nameof(ReferringSitesViewModel.ReferringSitesCollection));

            _refreshView = new RefreshView
            {
                AutomationId     = ReferringSitesPageAutomationIds.RefreshView,
                CommandParameter = (repository.OwnerLogin, repository.Name),
                Content          = collectionView
            };
            _refreshView.SetDynamicResource(RefreshView.RefreshColorProperty, nameof(BaseTheme.RefreshControlColor));
            _refreshView.SetBinding(RefreshView.CommandProperty, nameof(ReferringSitesViewModel.RefreshCommand));
            _refreshView.SetBinding(RefreshView.IsRefreshingProperty, nameof(ReferringSitesViewModel.IsRefreshing));

            //Add Title and Back Button to UIModalPresentationStyle.FormSheet
            if (Device.RuntimePlatform is Device.iOS)
            {
                var closeButton = new Button
                {
                    AutomationId      = ReferringSitesPageAutomationIds.CloseButton,
                    Text              = "Close",
                    HorizontalOptions = LayoutOptions.End,
                    VerticalOptions   = LayoutOptions.Center,
                    HeightRequest     = titleRowHeight * 3 / 5,
                    Padding           = new Thickness(5, 0)
                };
                closeButton.Clicked += HandleCloseButtonClicked;
                closeButton.SetDynamicResource(Button.TextColorProperty, nameof(BaseTheme.NavigationBarTextColor));
                closeButton.SetDynamicResource(Button.BorderColorProperty, nameof(BaseTheme.TrendsChartSettingsBorderColor));
                closeButton.SetDynamicResource(Button.BackgroundColorProperty, nameof(BaseTheme.NavigationBarBackgroundColor));


                var titleRowBlurView = new BoxView {
                    Opacity = 0.5
                };
                titleRowBlurView.SetDynamicResource(BackgroundColorProperty, nameof(BaseTheme.PageBackgroundColor));

                collectionView.Header = new BoxView {
                    HeightRequest = titleRowHeight + titleTopMargin
                };

                var titleLabel = new Label
                {
                    FontAttributes = FontAttributes.Bold,
                    Text           = PageTitles.ReferringSitesPage,
                    FontSize       = 30
                };
                titleLabel.SetDynamicResource(Label.TextColorProperty, nameof(BaseTheme.TextColor));

                closeButton.Margin = titleLabel.Margin = new Thickness(0, titleTopMargin, 0, 0);

                var activityIndicator = new ActivityIndicator
                {
                    AutomationId = ReferringSitesPageAutomationIds.ActivityIndicator,
                };
                activityIndicator.SetDynamicResource(ActivityIndicator.ColorProperty, nameof(BaseTheme.RefreshControlColor));
                activityIndicator.SetBinding(IsVisibleProperty, nameof(ReferringSitesViewModel.IsActivityIndicatorVisible));
                activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(ReferringSitesViewModel.IsActivityIndicatorVisible));

                var relativeLayout = new RelativeLayout();

                relativeLayout.Children.Add(_refreshView,
                                            Constraint.Constant(0),
                                            Constraint.Constant(0),
                                            Constraint.RelativeToParent(parent => parent.Width),
                                            Constraint.RelativeToParent(parent => parent.Height));

                relativeLayout.Children.Add(titleRowBlurView,
                                            Constraint.Constant(0),
                                            Constraint.Constant(0),
                                            Constraint.RelativeToParent(parent => parent.Width),
                                            Constraint.Constant(titleRowHeight));

                relativeLayout.Children.Add(titleLabel,
                                            Constraint.Constant(10),
                                            Constraint.Constant(0));

                relativeLayout.Children.Add(closeButton,
                                            Constraint.RelativeToParent(parent => parent.Width - GetWidth(parent, closeButton) - 10),
                                            Constraint.Constant(0),
                                            Constraint.RelativeToParent(parent => GetWidth(parent, closeButton)));

                relativeLayout.Children.Add(activityIndicator,
                                            Constraint.RelativeToParent(parent => parent.Width / 2 - GetWidth(parent, activityIndicator) / 2),
                                            Constraint.RelativeToParent(parent => parent.Height / 2 - GetHeight(parent, activityIndicator) / 2));

                Content = relativeLayout;
            }
            else
            {
                Content = _refreshView;
            }
        }
Beispiel #6
0
        public GitHubSettingsView()
        {
            const int _imageHeight        = 200;
            const int _demoButtonFontSize = 8;

            var gitHubAvatarImage = new CircleImage
            {
                AutomationId      = SettingsPageAutomationIds.GitHubAvatarImage,
                HeightRequest     = _imageHeight,
                WidthRequest      = _imageHeight,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Aspect            = Aspect.AspectFit
            };

            gitHubAvatarImage.SetBinding(CircleImage.SourceProperty, nameof(SettingsViewModel.GitHubAvatarImageSource));

            var gitHubAliasLabel = new Label
            {
                HorizontalTextAlignment = TextAlignment.Center,
                AutomationId            = SettingsPageAutomationIds.GitHubAliasLabel,
            };

            gitHubAliasLabel.SetBinding(Label.TextProperty, nameof(SettingsViewModel.GitHubAliasLabelText));

            var gitHubLoginButton = new FontAwesomeButton
            {
                AutomationId      = SettingsPageAutomationIds.GitHubLoginButton,
                TextColor         = Color.White,
                FontSize          = 24,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Padding           = new Thickness(10),
                Margin            = new Thickness(0, 25, 0, 5)
            };

            gitHubLoginButton.SetDynamicResource(BackgroundColorProperty, nameof(BaseTheme.ButtonBackgroundColor));
            gitHubLoginButton.SetDynamicResource(Button.TextColorProperty, nameof(BaseTheme.ButtonTextColor));
            gitHubLoginButton.SetBinding(Button.TextProperty, nameof(SettingsViewModel.LoginButtonText));
            gitHubLoginButton.SetBinding(Button.CommandProperty, nameof(SettingsViewModel.LoginButtonCommand));

            var demoButton = new Button
            {
                AutomationId      = SettingsPageAutomationIds.DemoModeButton,
                Padding           = new Thickness(2),
                BackgroundColor   = Color.Transparent,
                FontSize          = _demoButtonFontSize,
                Text              = "Enter Demo Mode",
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
            };

            demoButton.SetDynamicResource(Button.TextColorProperty, nameof(BaseTheme.TextColor));
            demoButton.SetBinding(IsVisibleProperty, nameof(SettingsViewModel.IsDemoButtonVisible));
            demoButton.SetBinding(Button.CommandProperty, nameof(SettingsViewModel.DemoButtonCommand));

            var activityIndicator = new ActivityIndicator
            {
                AutomationId    = SettingsPageAutomationIds.GitHubSettingsViewActivityIndicator,
                VerticalOptions = LayoutOptions.Start
            };

            activityIndicator.SetDynamicResource(ActivityIndicator.ColorProperty, nameof(BaseTheme.RefreshControlColor));
            activityIndicator.SetBinding(IsVisibleProperty, nameof(SettingsViewModel.IsAuthenticating));
            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(SettingsViewModel.IsAuthenticating));

            var relativeLayout = new RelativeLayout();

            relativeLayout.Children.Add(gitHubAvatarImage,
                                        //Center the image horizontally within the RelativeLayout
                                        xConstraint: Constraint.RelativeToParent(parent => parent.Width / 2 - getImageSizeConstraint(parent) / 2),
                                        //Pin the image to the top of the screen
                                        yConstraint: Constraint.Constant(0),
                                        //Width and Height should be the same
                                        widthConstraint: Constraint.RelativeToParent(parent => getImageSizeConstraint(parent)),
                                        //Width and Height should be the same
                                        heightConstraint: Constraint.RelativeToParent(parent => getImageSizeConstraint(parent)));

            relativeLayout.Children.Add(gitHubLoginButton,
                                        //Center the button horizontally within the RelativeLayout
                                        xConstraint: Constraint.RelativeToParent(parent => parent.Width / 2 - getWidth(parent, gitHubLoginButton) / 2),
                                        //Place the button below gitHubAvatarImage
                                        yConstraint: Constraint.RelativeToView(gitHubAvatarImage, (parent, view) => view.Y + view.Height + 5),
                                        //Ensure the button scales to the height of the RelativeLayout
                                        heightConstraint: Constraint.RelativeToParent(parent => getLoginButtonSizeConstraint(parent)));

            relativeLayout.Children.Add(demoButton,
                                        //Center the button horizontally within the RelativeLayout
                                        xConstraint: Constraint.RelativeToParent(parent => parent.Width / 2 - getWidth(parent, demoButton) / 2),
                                        //Place the button below gitHubLoginButton
                                        yConstraint: Constraint.RelativeToView(gitHubLoginButton, (parent, view) => view.Y + view.Height + 2),
                                        heightConstraint: Constraint.Constant(getDemoButtonSizeConstraint()));

            relativeLayout.Children.Add(activityIndicator,
                                        //Center the activityIndicator horizontally within the RelativeLayout
                                        xConstraint: Constraint.RelativeToParent(parent => parent.Width / 2 - getWidth(parent, activityIndicator) / 2),
                                        //Place the activityIndicator below gitHubLoginButton
                                        yConstraint: Constraint.RelativeToView(gitHubLoginButton, (parent, view) => view.Y + view.Height + 5));

            Content = relativeLayout;
Beispiel #7
0
        public GitHubSettingsView()
        {
            var gitHubAvatarImage = new CircleImage
            {
                HeightRequest     = 200,
                WidthRequest      = 200,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
            };

            gitHubAvatarImage.SetBinding(CircleImage.SourceProperty, nameof(SettingsViewModel.GitHubAvatarImageSource));

            var gitHubAliasLabel = new Label {
                HorizontalTextAlignment = TextAlignment.Center
            };

            gitHubAliasLabel.SetBinding(Label.TextProperty, nameof(SettingsViewModel.GitHubAliasLabelText));

            var gitHubLoginButton = new FontAwesomeButton
            {
                TextColor         = Color.White,
                FontSize          = 24,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Padding           = new Thickness(10),
                Margin            = new Thickness(0, 25, 0, 5)
            };

            gitHubLoginButton.SetDynamicResource(BackgroundColorProperty, nameof(BaseTheme.ButtonBackgroundColor));
            gitHubLoginButton.SetBinding(IsEnabledProperty, nameof(SettingsViewModel.IsNotAuthenticating));
            gitHubLoginButton.SetBinding(Button.TextProperty, nameof(SettingsViewModel.LoginButtonText));
            gitHubLoginButton.SetBinding(Button.CommandProperty, nameof(SettingsViewModel.LoginButtonCommand));

            var activityIndicator = new ActivityIndicator
            {
                VerticalOptions = LayoutOptions.Start
            };

            activityIndicator.SetDynamicResource(ActivityIndicator.ColorProperty, nameof(BaseTheme.RefreshControlColor));
            activityIndicator.SetBinding(IsVisibleProperty, nameof(SettingsViewModel.IsAuthenticating));
            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(SettingsViewModel.IsAuthenticating));

            var grid = new Grid
            {
                RowDefinitions =
                {
                    new RowDefinition {
                        Height = new GridLength(7, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition {
                        Height = new GridLength(20, GridUnitType.Absolute)
                    }
                },

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

            grid.Children.Add(gitHubAvatarImage, 0, 0);
            grid.Children.Add(gitHubLoginButton, 0, 1);
            grid.Children.Add(activityIndicator, 0, 2);

            Content = grid;
        }