示例#1
0
        public SettingsViewModel(GitHubAuthenticationService gitHubAuthenticationService,
                                 ThemeService themeService,
                                 TrendsChartSettingsService trendsChartSettingsService,
                                 AnalyticsService analyticsService,
                                 DeepLinkingService deepLinkingService,
                                 NotificationService notificationService)
            : base(gitHubAuthenticationService, deepLinkingService, analyticsService)
        {
            _gitHubAuthenticationService = gitHubAuthenticationService;
            _trendsChartSettingsService  = trendsChartSettingsService;
            _deepLinkingService          = deepLinkingService;
            _notificationService         = notificationService;
            _themeService = themeService;

            CopyrightLabelTappedCommand = new AsyncCommand(ExecuteCopyrightLabelTappedCommand);
            GitHubUserViewTappedCommand = new AsyncCommand(ExecuteGitHubUserViewTappedCommand, _ => GitHubAuthenticationService.IsAuthenticated || GitHubAuthenticationService.IsDemoUser);

            _gitHubAuthenticationService.AuthorizeSessionCompleted += HandleAuthorizeSessionCompleted;
            ThemeService.PreferenceChanged += HandlePreferenceChanged;

            ThemePickerSelectedThemeIndex = (int)themeService.Preference;

            var app = (App)Application.Current;

            app.Resumed += HandleResumed;

            initializeIsRegisterForNotificationsSwitch().SafeFireAndForget();

            SetGitHubValues();

            async Task initializeIsRegisterForNotificationsSwitch() => IsRegisterForNotificationsSwitchToggled = notificationService.ShouldSendNotifications && await notificationService.AreNotificationsEnabled().ConfigureAwait(false);
        }
示例#2
0
 public UITestBackdoorService(GitHubAuthenticationService gitHubAuthenticationService,
                              NotificationService notificationService,
                              GitHubGraphQLApiService gitHubGraphQLApiService,
                              TrendsChartSettingsService trendsChartSettingsService,
                              ThemeService themeService)
 {
     _gitHubAuthenticationService = gitHubAuthenticationService;
     _gitHubGraphQLApiService     = gitHubGraphQLApiService;
     _trendsChartSettingsService  = trendsChartSettingsService;
     _notificationService         = notificationService;
     _themeService = themeService;
 }
示例#3
0
        public App(IAnalyticsService analyticsService,
                   INotificationService notificationService,
                   ThemeService themeService,
                   SplashScreenPage splashScreenPage)
        {
            Device.SetFlags(new[] { "Markup_Experimental", "IndicatorView_Experimental", "AppTheme_Experimental" });

            InitializeEssentialServices(themeService, notificationService);

            _analyticsService = analyticsService;

            MainPage = splashScreenPage;

            On <iOS>().SetHandleControlUpdatesOnMainThread(true);
        }
示例#4
0
 public UITestsBackdoorService(GitHubAuthenticationService gitHubAuthenticationService,
                               NotificationService notificationService,
                               GitHubGraphQLApiService gitHubGraphQLApiService,
                               TrendsChartSettingsService trendsChartSettingsService,
                               ThemeService themeService,
                               GitHubUserService gitHubUserService,
                               IMainThread mainThread)
 {
     _mainThread                  = mainThread;
     _themeService                = themeService;
     _gitHubUserService           = gitHubUserService;
     _notificationService         = notificationService;
     _gitHubGraphQLApiService     = gitHubGraphQLApiService;
     _trendsChartSettingsService  = trendsChartSettingsService;
     _gitHubAuthenticationService = gitHubAuthenticationService;
 }
示例#5
0
        public App(ThemeService themeService,
                   LanguageService languageService,
                   IAnalyticsService analyticsService,
                   SplashScreenPage splashScreenPage,
                   NotificationService notificationService,
                   IDeviceNotificationsService deviceNotificationsService)
        {
            InitializeEssentialServices(themeService, deviceNotificationsService, languageService);

            _languageService     = languageService;
            _analyticsService    = analyticsService;
            _notificationService = notificationService;

            MainPage = splashScreenPage;

            On <iOS>().SetHandleControlUpdatesOnMainThread(true);
        }
示例#6
0
        public ReferringSitesPage(DeepLinkingService deepLinkingService,
                                  ReferringSitesViewModel referringSitesViewModel,
                                  Repository repository,
                                  IAnalyticsService analyticsService,
                                  ThemeService themeService,
                                  ReviewService reviewService,
                                  IMainThread mainThread) : base(referringSitesViewModel, analyticsService, mainThread)
        {
            Title = PageTitles.ReferringSitesPage;

            _repository         = repository;
            _themeService       = themeService;
            _reviewService      = reviewService;
            _deepLinkingService = deepLinkingService;

            reviewService.ReviewCompleted += HandleReviewCompleted;
            ViewModel.PullToRefreshFailed += HandlePullToRefreshFailed;

            var titleRowHeight = _isiOS ? 50 : 0;

            var collectionView = new ReferringSitesCollectionView()
                                 .Bind(IsVisibleProperty, nameof(ReferringSitesViewModel.IsEmptyDataViewEnabled))
                                 .Bind(EmptyDataView.TitleProperty, nameof(ReferringSitesViewModel.EmptyDataViewTitle))
                                 .Bind(EmptyDataView.DescriptionProperty, nameof(ReferringSitesViewModel.EmptyDataViewDescription))
                                 .Bind(CollectionView.ItemsSourceProperty, nameof(ReferringSitesViewModel.MobileReferringSitesList))
                                 .Invoke(collectionView => collectionView.SelectionChanged += HandleCollectionViewSelectionChanged);

            var closeButton = new CloseButton(titleRowHeight).Invoke(closeButton => closeButton.Clicked += HandleCloseButtonClicked);

            Content = new RelativeLayout()
                      .Add(new ReferringSitesRefreshView(collectionView, repository, _refreshViewCancelltionTokenSource.Token).Assign(out _refreshView)
                           .DynamicResource(RefreshView.RefreshColorProperty, nameof(BaseTheme.PullToRefreshColor))
                           .Bind(RefreshView.CommandProperty, nameof(ReferringSitesViewModel.RefreshCommand))
                           .Bind(RefreshView.IsRefreshingProperty, nameof(ReferringSitesViewModel.IsRefreshing)),
                           Constant(0), Constant(titleRowHeight), RelativeToParent(parent => parent.Width), RelativeToParent(parent => parent.Height - titleRowHeight))
                      .Add(_isiOS ? new TitleShadowView(themeService) : null,
                           Constant(0), Constant(0), RelativeToParent(parent => parent.Width), Constant(titleRowHeight))
                      .Add(_isiOS ? new TitleLabel() : null,
                           Constant(10), Constant(0))
                      .Add(_isiOS ? closeButton : null,
                           RelativeToParent(parent => parent.Width - closeButton.GetWidth(parent) - 10), Constant(0), RelativeToParent(parent => closeButton.GetWidth(parent)))
                      .Add(_storeRatingRequestView,
                           Constant(0), RelativeToParent(parent => parent.Height - _storeRatingRequestView.GetHeight(parent)), RelativeToParent(parent => parent.Width));
        }
示例#7
0
        public SettingsViewModel(IMainThread mainThread,
                                 ThemeService themeService,
                                 LanguageService languageService,
                                 IVersionTracking versionTracking,
                                 IAnalyticsService analyticsService,
                                 GitHubUserService gitHubUserService,
                                 DeepLinkingService deepLinkingService,
                                 NotificationService notificationService,
                                 TrendsChartSettingsService trendsChartSettingsService,
                                 GitHubAuthenticationService gitHubAuthenticationService)
            : base(mainThread, analyticsService, gitHubUserService, deepLinkingService, gitHubAuthenticationService)
        {
            _themeService               = themeService;
            _versionTracking            = versionTracking;
            _languageService            = languageService;
            _deepLinkingService         = deepLinkingService;
            _notificationService        = notificationService;
            _trendsChartSettingsService = trendsChartSettingsService;

            CopyrightLabelTappedCommand = new AsyncCommand(ExecuteCopyrightLabelTappedCommand);
            GitHubUserViewTappedCommand = new AsyncCommand(ExecuteGitHubUserViewTappedCommand, _ => IsNotAuthenticating);

            App.Resumed += HandleResumed;

            GitHubUserService.NameChanged      += HandleNameChanged;
            GitHubUserService.AliasChanged     += HandleAliasChanged;
            GitHubUserService.AvatarUrlChanged += HandleAvatarUrlChanged;

            ThemeService.PreferenceChanged           += HandlePreferenceChanged;
            LanguageService.PreferredLanguageChanged += HandlePreferredLanguageChanged;
            GitHubAuthenticationService.AuthorizeSessionCompleted += HandleAuthorizeSessionCompleted;

            ThemePickerSelectedIndex     = (int)themeService.Preference;
            PreferredChartsSelectedIndex = (int)trendsChartSettingsService.CurrentTrendsChartOption;
            LanguagePickerSelectedIndex  = CultureConstants.CulturePickerOptions.Keys.ToList().IndexOf(languageService.PreferredLanguage ?? string.Empty);

            initializeIsRegisterForNotificationsSwitch().SafeFireAndForget();

            InitializeText();

            async Task initializeIsRegisterForNotificationsSwitch() => IsRegisterForNotificationsSwitchToggled = notificationService.ShouldSendNotifications && await notificationService.AreNotificationsEnabled().ConfigureAwait(false);
        }
        public ReferringSitesPage(DeepLinkingService deepLinkingService,
                                  ReferringSitesViewModel referringSitesViewModel,
                                  Repository repository,
                                  IAnalyticsService analyticsService,
                                  ThemeService themeService,
                                  ReviewService reviewService,
                                  IMainThread mainThread) : base(referringSitesViewModel, analyticsService, mainThread)
        {
            Title = PageTitles.ReferringSitesPage;

            this.repository         = repository;
            this.themeService       = themeService;
            this.reviewService      = reviewService;
            this.deepLinkingService = deepLinkingService;

            ViewModel.PullToRefreshFailed += HandlePullToRefreshFailed;
            reviewService.ReviewCompleted += HandleReviewCompleted;

            Build();
        }
示例#9
0
        public App(ThemeService themeService,
                   LanguageService languageService,
                   IAnalyticsService analyticsService,
                   SplashScreenPage splashScreenPage,
                   NotificationService notificationService,
                   IDeviceNotificationsService deviceNotificationsService)
        {
            _languageService     = languageService;
            _analyticsService    = analyticsService;
            _notificationService = notificationService;

            analyticsService.Track("App Initialized", new Dictionary <string, string>
            {
                { nameof(LanguageService.PreferredLanguage), _languageService.PreferredLanguage ?? "default" },
                { nameof(CultureInfo.CurrentUICulture), CultureInfo.CurrentUICulture.TwoLetterISOLanguageName }
            });

            InitializeEssentialServices(themeService, deviceNotificationsService, languageService);

            MainPage = splashScreenPage;

            On <iOS>().SetHandleControlUpdatesOnMainThread(true);
        }
示例#10
0
        public ReferringSitesPage(DeepLinkingService deepLinkingService,
                                  ReferringSitesViewModel referringSitesViewModel,
                                  Repository repository,
                                  IAnalyticsService analyticsService,
                                  ThemeService themeService,
                                  ReviewService reviewService,
                                  IMainThread mainThread) : base(referringSitesViewModel, analyticsService, mainThread, PageTitles.ReferringSitesPage)
        {
            _reviewService      = reviewService;
            _deepLinkingService = deepLinkingService;

            ViewModel.PullToRefreshFailed += HandlePullToRefreshFailed;
            reviewService.ReviewCompleted += HandleReviewCompleted;

            var collectionView = new CollectionView
            {
                AutomationId    = ReferringSitesPageAutomationIds.CollectionView,
                BackgroundColor = Color.Transparent,
                ItemTemplate    = new ReferringSitesDataTemplate(),
                SelectionMode   = SelectionMode.Single,
                ItemsLayout     = new LinearItemsLayout(ItemsLayoutOrientation.Vertical),
                //Set iOS Header to `new BoxView { HeightRequest = titleRowHeight + titleTopMargin }` following this bug fix: https://github.com/xamarin/Xamarin.Forms/issues/9879
                Header = Device.RuntimePlatform is Device.Android ? new BoxView {
                    HeightRequest = ReferringSitesDataTemplate.BottomPadding
                } : null,
                Footer = Device.RuntimePlatform is Device.Android ? new BoxView {
                    HeightRequest = ReferringSitesDataTemplate.TopPadding
                } : null,
                EmptyView = new EmptyDataView("EmptyReferringSitesList", ReferringSitesPageAutomationIds.EmptyDataView)
                            .Bind(IsVisibleProperty, nameof(ReferringSitesViewModel.IsEmptyDataViewEnabled))
                            .Bind(EmptyDataView.TitleProperty, nameof(ReferringSitesViewModel.EmptyDataViewTitle))
                            .Bind(EmptyDataView.DescriptionProperty, nameof(ReferringSitesViewModel.EmptyDataViewDescription))
            };

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

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

            var relativeLayout = new RelativeLayout();

            //Add Title and Close Button to UIModalPresentationStyle.FormSheet
            if (Device.RuntimePlatform is Device.iOS)
            {
                const int titleTopMargin = 10;
                const int titleRowHeight = 50;

                var closeButton = new Button
                {
                    Text              = ReferringSitesPageConstants.CloseButtonText,
                    FontFamily        = FontFamilyConstants.RobotoRegular,
                    HeightRequest     = titleRowHeight * 3 / 5,
                    HorizontalOptions = LayoutOptions.End,
                    VerticalOptions   = LayoutOptions.Center,
                    AutomationId      = ReferringSitesPageAutomationIds.CloseButton,
                    Padding           = new Thickness(5, 0)
                };
                closeButton.Clicked += HandleCloseButtonClicked;
                closeButton.SetDynamicResource(Button.TextColorProperty, nameof(BaseTheme.CloseButtonTextColor));
                closeButton.SetDynamicResource(BackgroundColorProperty, nameof(BaseTheme.CloseButtonBackgroundColor));

                var titleLabel = new Label
                {
                    FontSize   = 30,
                    Text       = PageTitles.ReferringSitesPage,
                    FontFamily = FontFamilyConstants.RobotoMedium,
                }.Center().TextCenterVertical();
                titleLabel.SetDynamicResource(Label.TextColorProperty, nameof(BaseTheme.TextColor));

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

                var titleShadow = new BoxView();
                titleShadow.SetDynamicResource(BackgroundColorProperty, nameof(BaseTheme.CardSurfaceColor));

                if (isLightTheme(themeService.Preference))
                {
                    titleShadow.On <iOS>().SetIsShadowEnabled(true)
                    .SetShadowColor(Color.Gray)
                    .SetShadowOffset(new Size(0, 1))
                    .SetShadowOpacity(0.5)
                    .SetShadowRadius(4);
                }


                relativeLayout.Children.Add(_refreshView,
                                            Constraint.Constant(0),
                                            Constraint.Constant(titleRowHeight),                                    //Set to `0` following this bug fix: https://github.com/xamarin/Xamarin.Forms/issues/9879
                                            Constraint.RelativeToParent(parent => parent.Width),
                                            Constraint.RelativeToParent(parent => parent.Height - titleRowHeight)); //Set to `parent => parent.Height` following this bug fix: https://github.com/xamarin/Xamarin.Forms/issues/9879

                relativeLayout.Children.Add(titleShadow,
                                            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 - closeButton.GetWidth(parent) - 10),
                                            Constraint.Constant(0),
                                            Constraint.RelativeToParent(parent => closeButton.GetWidth(parent)));
            }
            else
            {
                relativeLayout.Children.Add(_refreshView,
                                            Constraint.Constant(0),
                                            Constraint.Constant(0),
                                            Constraint.RelativeToParent(parent => parent.Width),
                                            Constraint.RelativeToParent(parent => parent.Height));
            }

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

            Content = relativeLayout;
        public ReferringSitesPage(IMainThread mainThread,
                                  Repository repository,
                                  ThemeService themeService,
                                  ReviewService reviewService,
                                  IAnalyticsService analyticsService,
                                  DeepLinkingService deepLinkingService,
                                  ReferringSitesViewModel referringSitesViewModel) : base(referringSitesViewModel, analyticsService, mainThread)
        {
            Title = PageTitles.ReferringSitesPage;

            _repository         = repository;
            _themeService       = themeService;
            _reviewService      = reviewService;
            _deepLinkingService = deepLinkingService;

            ReviewService.ReviewCompleted += HandleReviewCompleted;
            ReferringSitesViewModel.PullToRefreshFailed += HandlePullToRefreshFailed;

            var isiOS          = Device.RuntimePlatform is Device.iOS;
            var titleRowHeight = isiOS ? 50 : 0;
            var shadowHeight   = isiOS ? 1 : 0;

            var collectionView = new ReferringSitesCollectionView()
                                 .Bind(IsVisibleProperty, nameof(ReferringSitesViewModel.IsEmptyDataViewEnabled))
                                 .Bind(EmptyDataView.TitleProperty, nameof(ReferringSitesViewModel.EmptyDataViewTitle))
                                 .Bind(EmptyDataView.DescriptionProperty, nameof(ReferringSitesViewModel.EmptyDataViewDescription))
                                 .Bind(CollectionView.ItemsSourceProperty, nameof(ReferringSitesViewModel.MobileReferringSitesList))
                                 .Invoke(collectionView => collectionView.SelectionChanged += HandleCollectionViewSelectionChanged);

            Content = new Grid
            {
                RowSpacing = 0,

                RowDefinitions = Rows.Define(
                    (Row.Title, Auto),
                    (Row.TitleShadow, AbsoluteGridLength(shadowHeight)),
                    (Row.List, Star),
                    (Row.RatingRequest, Auto)),

                ColumnDefinitions = Columns.Define(
                    (Column.Title, StarGridLength(3)),
                    (Column.Button, StarGridLength(1))),

                Children =
                {
                    new ReferringSitesRefreshView(collectionView,       repository, _refreshViewCancelltionTokenSource.Token).Assign(out _refreshView)
                    .Row(Row.TitleShadow).RowSpan(3).ColumnSpan(All <Column>())
                    .Bind(RefreshView.CommandProperty,                  nameof(ReferringSitesViewModel.RefreshCommand))
                    .Bind(RefreshView.IsRefreshingProperty,             nameof(ReferringSitesViewModel.IsRefreshing))
                    .DynamicResource(RefreshView.RefreshColorProperty,  nameof(BaseTheme.PullToRefreshColor)),

                    _storeRatingRequestView
                    .Row(Row.RatingRequest).ColumnSpan(All <Column>()),
                }
            };

            if (isiOS)
            {
                var grid = (Grid)Content;

                grid.Children.Add(new TitleShadowView(themeService, titleRowHeight, shadowHeight).Row(Row.Title).ColumnSpan(All <Column>()));
                grid.Children.Add(new TitleLabel().Row(Row.Title).Column(Column.Title));
                grid.Children.Add(new CloseButton(titleRowHeight).Invoke(closeButton => closeButton.Clicked += HandleCloseButtonClicked).Row(Row.Title).Column(Column.Button));
            }
        }