Beispiel #1
0
        public SplashScreenPage(IMainThread mainThread,
                                FirstRunService firstRunService,
                                IAnalyticsService analyticsService,
                                SplashScreenViewModel splashScreenViewModel)
            : base(splashScreenViewModel, analyticsService, mainThread)
        {
            //Remove BaseContentPageBackground
            RemoveDynamicResource(BackgroundColorProperty);
            this.DynamicResource(BackgroundColorProperty, nameof(BaseTheme.GitTrendsImageBackgroundColor));

            _firstRunService = firstRunService;

            SplashScreenViewModel.InitializationCompleted += HandleInitializationCompleted;

            _statusMessageEnumerator.MoveNext();

            Content = new Grid
            {
                RowDefinitions = Rows.Define(
                    (Row.Image, Star),
                    (Row.Text, Auto),
                    (Row.BottomPadding, AbsoluteGridLength(50))),

                Children =
                {
                    new LoadingLabel().Center().Assign(out _loadingLabel)
                    .Row(Row.Text),

                    new GitTrendsImage().Center().Assign(out _gitTrendsImage)
                    .RowSpan(All <Row>()),
                }
            };
        }
        public SplashScreenPage(IAnalyticsService analyticsService,
                                SplashScreenViewModel splashScreenViewModel,
                                IMainThread mainThread,
                                FirstRunService firstRunService)
            : base(splashScreenViewModel, analyticsService, mainThread)
        {
            //Remove BaseContentPageBackground
            RemoveDynamicResource(BackgroundColorProperty);
            SetDynamicResource(BackgroundColorProperty, nameof(BaseTheme.GitTrendsImageBackgroundColor));

            _firstRunService = firstRunService;

            ViewModel.InitializationComplete += HandleInitializationComplete;

            IEnumerable <string> statusMessageList = new[] { SplashScreenPageConstants.Initializing, SplashScreenPageConstants.ConnectingToServers, SplashScreenPageConstants.Initializing, SplashScreenPageConstants.ConnectingToServers, SplashScreenPageConstants.Initializing, SplashScreenPageConstants.ConnectingToServers, SplashScreenPageConstants.StillWorkingOnIt, SplashScreenPageConstants.LetsTryItLikeThis, SplashScreenPageConstants.MaybeThis, SplashScreenPageConstants.AnotherTry, SplashScreenPageConstants.ItShouldntTakeThisLong, SplashScreenPageConstants.AreYouSureInternetConnectionIsGood };

            _statusMessageEnumerator = statusMessageList.GetEnumerator();
            _statusMessageEnumerator.MoveNext();

            _gitTrendsImage = new Image
            {
                AutomationId      = SplashScreenPageAutomationIds.GitTrendsImage,
                Opacity           = 0,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                Aspect            = Aspect.AspectFit
            };
            _gitTrendsImage.SetDynamicResource(Image.SourceProperty, nameof(BaseTheme.GitTrendsImageSource));

            _statusLabel = new Label
            {
                //Begin with Label off of the screen
                TranslationX            = DeviceDisplay.MainDisplayInfo.Width / 2,
                Margin                  = new Thickness(10, 0),
                AutomationId            = SplashScreenPageAutomationIds.StatusLabel,
                HorizontalTextAlignment = TextAlignment.Center,
            };
            _statusLabel.SetDynamicResource(Label.TextColorProperty, nameof(BaseTheme.SplashScreenStatusColor));

            var relativeLayout = new RelativeLayout();

            relativeLayout.Children.Add(_statusLabel,
                                        Constraint.RelativeToParent(parent => parent.Width / 2 - _statusLabel.GetWidth(parent) / 2),
                                        Constraint.RelativeToParent(parent => parent.Height - _statusLabel.GetHeight(parent) - (DeviceDisplay.MainDisplayInfo.Orientation is DisplayOrientation.Landscape ? 25 : 50)));

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

            Content = relativeLayout;
        }
Beispiel #3
0
        public OnboardingViewModel(DeepLinkingService deepLinkingService,
                                   GitHubAuthenticationService gitHubAuthenticationService,
                                   NotificationService notificationService,
                                   IAnalyticsService analyticsService,
                                   IMainThread mainThread,
                                   FirstRunService firstRunService,
                                   GitHubUserService gitHubUserService)
            : base(gitHubAuthenticationService, deepLinkingService, analyticsService, mainThread, gitHubUserService)
        {
            const string defaultNotificationSvg = "bell.svg";

            _notificationService = notificationService;
            _analyticsService    = analyticsService;
            _firstRunService     = firstRunService;

            NotificationStatusSvgImageSource = defaultNotificationSvg;

            EnableNotificationsButtonTapped = new AsyncCommand(ExecuteEnableNotificationsButtonTapped);
        }
Beispiel #4
0
        public RepositoryPage(RepositoryViewModel repositoryViewModel,
                              IAnalyticsService analyticsService,
                              MobileSortingService sortingService,
                              DeepLinkingService deepLinkingService,
                              IMainThread mainThread,
                              FirstRunService firstRunService,
                              GitHubUserService gitHubUserService) : base(repositoryViewModel, analyticsService, mainThread)
        {
            _firstRunService    = firstRunService;
            _gitHubUserService  = gitHubUserService;
            _deepLinkingService = deepLinkingService;

            ViewModel.PullToRefreshFailed += HandlePullToRefreshFailed;
            SearchBarTextChanged          += HandleSearchBarTextChanged;

            var collectionView = new CollectionView
            {
                ItemTemplate    = new RepositoryDataTemplateSelector(sortingService),
                BackgroundColor = Color.Transparent,
                SelectionMode   = SelectionMode.Single,
                AutomationId    = RepositoryPageAutomationIds.CollectionView,
                //Work around for https://github.com/xamarin/Xamarin.Forms/issues/9879
                Header = Device.RuntimePlatform is Device.Android ? new BoxView {
                    HeightRequest = BaseRepositoryDataTemplate.BottomPadding
                } : null,
                Footer = Device.RuntimePlatform is Device.Android ? new BoxView {
                    HeightRequest = BaseRepositoryDataTemplate.TopPadding
                } : null,
                EmptyView = new EmptyDataView("EmptyRepositoriesList", RepositoryPageAutomationIds.EmptyDataView)
                            .Bind <EmptyDataView, bool, bool>(IsVisibleProperty, nameof(RepositoryViewModel.IsRefreshing), convert: isRefreshing => !isRefreshing)
                            .Bind(EmptyDataView.TitleProperty, nameof(RepositoryViewModel.EmptyDataViewTitle))
                            .Bind(EmptyDataView.DescriptionProperty, nameof(RepositoryViewModel.EmptyDataViewDescription))
            };

            collectionView.SelectionChanged += HandleCollectionViewSelectionChanged;
            collectionView.SetBinding(CollectionView.ItemsSourceProperty, nameof(RepositoryViewModel.VisibleRepositoryList));

            _refreshView = new RefreshView
            {
                AutomationId = RepositoryPageAutomationIds.RefreshView,
                Content      = collectionView
            }.DynamicResource(RefreshView.RefreshColorProperty, nameof(BaseTheme.PullToRefreshColor))
            .Bind(RefreshView.IsRefreshingProperty, nameof(RepositoryViewModel.IsRefreshing))
            .Bind(RefreshView.CommandProperty, nameof(RepositoryViewModel.PullToRefreshCommand));

            var settingsToolbarItem = new ToolbarItem
            {
                Text            = PageTitles.SettingsPage,
                IconImageSource = Device.RuntimePlatform is Device.iOS ? "Settings" : null,
                Order           = Device.RuntimePlatform is Device.Android ? ToolbarItemOrder.Secondary : ToolbarItemOrder.Default,
                AutomationId    = RepositoryPageAutomationIds.SettingsButton,
                Command         = new AsyncCommand(ExecuteSetttingsToolbarItemCommand)
            };

            ToolbarItems.Add(settingsToolbarItem);

            var sortToolbarItem = new ToolbarItem
            {
                Text            = RepositoryPageConstants.SortToolbarItemText,
                Priority        = 1,
                IconImageSource = Device.RuntimePlatform is Device.iOS ? "Sort" : null,
                Order           = Device.RuntimePlatform is Device.Android ? ToolbarItemOrder.Secondary : ToolbarItemOrder.Default,
                AutomationId    = RepositoryPageAutomationIds.SortButton,
                Command         = new AsyncCommand(ExecuteSortToolbarItemCommand)
            };

            ToolbarItems.Add(sortToolbarItem);

            //Work-around to prevent LargeNavigationBar from collapsing when CollectionView is scrolled; prevents janky animation when LargeNavigationBar collapses
            if (Device.RuntimePlatform is Device.iOS)
            {
                Content = new Grid
                {
                    Children =
                    {
                        new BoxView {
                            HeightRequest = 0
                        },
                        _refreshView
                    }
                };
            }
            else
            {
                Content = _refreshView;
            }

            this.SetBinding(TitleProperty, nameof(RepositoryViewModel.TitleText));
        }
Beispiel #5
0
        public RepositoryPage(IMainThread mainThread,
                              FirstRunService firstRunService,
                              IAnalyticsService analyticsService,
                              GitHubUserService gitHubUserService,
                              DeepLinkingService deepLinkingService,
                              RepositoryViewModel repositoryViewModel,
                              MobileSortingService mobileSortingService) : base(repositoryViewModel, analyticsService, mainThread)
        {
            _firstRunService    = firstRunService;
            _gitHubUserService  = gitHubUserService;
            _deepLinkingService = deepLinkingService;

            SearchBarTextChanged += HandleSearchBarTextChanged;
            RepositoryViewModel.PullToRefreshFailed  += HandlePullToRefreshFailed;
            LanguageService.PreferredLanguageChanged += HandlePreferredLanguageChanged;

            this.SetBinding(TitleProperty, nameof(RepositoryViewModel.TitleText));

            ToolbarItems.Add(new ToolbarItem
            {
                Text            = PageTitles.SettingsPage,
                IconImageSource = Device.RuntimePlatform is Device.iOS ? "Settings" : null,
                Order           = Device.RuntimePlatform is Device.Android ? ToolbarItemOrder.Secondary : ToolbarItemOrder.Default,
                AutomationId    = RepositoryPageAutomationIds.SettingsButton,
                Command         = new AsyncCommand(ExecuteSetttingsToolbarItemCommand)
            });

            ToolbarItems.Add(new ToolbarItem
            {
                Text            = RepositoryPageConstants.SortToolbarItemText,
                Priority        = 1,
                IconImageSource = Device.RuntimePlatform is Device.iOS ? "Sort" : null,
                Order           = Device.RuntimePlatform is Device.Android ? ToolbarItemOrder.Secondary : ToolbarItemOrder.Default,
                AutomationId    = RepositoryPageAutomationIds.SortButton,
                Command         = new AsyncCommand(ExecuteSortToolbarItemCommand)
            });

            Content = new Grid
            {
                RowDefinitions = Rows.Define(
                    (Row.Totals, AbsoluteGridLength(125)),
                    (Row.CollectionView, Star),
                    (Row.Information, AbsoluteGridLength(100))),

                ColumnDefinitions = Columns.Define(
                    (Column.CollectionView, Star),
                    (Column.Information, AbsoluteGridLength(100))),

                Children =
                {
                    new TotalsLabel().Row(Row.Totals).ColumnSpan(All <Column>())
                    .Bind <Label,                                                bool,                                  bool>(IsVisibleProperty,    nameof(RepositoryViewModel.IsRefreshing),          convert: isRefreshing => !isRefreshing)
                    .Bind <Label,                                                IReadOnlyList <Repository>,            string>(Label.TextProperty, nameof(RepositoryViewModel.VisibleRepositoryList), convert: repositories => totalsLabelConverter(repositories, mobileSortingService)),

                    new RefreshView
                    {
                        AutomationId = RepositoryPageAutomationIds.RefreshView,
                        Content      = new CollectionView
                        {
                            ItemTemplate    = new RepositoryDataTemplateSelector(mobileSortingService),
                            BackgroundColor = Color.Transparent,
                            SelectionMode   = SelectionMode.Single,
                            AutomationId    = RepositoryPageAutomationIds.CollectionView,
                            //Work around for https://github.com/xamarin/Xamarin.Forms/issues/9879
                            Header = Device.RuntimePlatform is Device.Android ? new BoxView {
                                HeightRequest = BaseRepositoryDataTemplate.BottomPadding
                            } : null,
                            Footer = Device.RuntimePlatform is Device.Android ? new BoxView {
                                HeightRequest = BaseRepositoryDataTemplate.TopPadding
                            } : null,
                            EmptyView = new EmptyDataView("EmptyRepositoriesList",RepositoryPageAutomationIds.EmptyDataView)
                                        .Bind <EmptyDataView,                    bool,                                  bool>(IsVisibleProperty,    nameof(RepositoryViewModel.IsRefreshing),          convert: isRefreshing => !isRefreshing)
                                        .Bind(EmptyDataView.TitleProperty,       nameof(RepositoryViewModel.EmptyDataViewTitle))
                                        .Bind(EmptyDataView.DescriptionProperty, nameof(RepositoryViewModel.EmptyDataViewDescription))
                        }.Bind(CollectionView.ItemsSourceProperty,               nameof(RepositoryViewModel.VisibleRepositoryList))
                        .Invoke(collectionView => collectionView.SelectionChanged += HandleCollectionViewSelectionChanged)
                    }.RowSpan(All <Row>()).ColumnSpan(All <Column>()).Assign(out _refreshView)
                    .Bind(RefreshView.IsRefreshingProperty,                      nameof(RepositoryViewModel.IsRefreshing))
                    .Bind(RefreshView.CommandProperty,                           nameof(RepositoryViewModel.PullToRefreshCommand))
                    .DynamicResource(RefreshView.RefreshColorProperty,           nameof(BaseTheme.PullToRefreshColor)),
                }
            }.Assign(out Grid grid);