예제 #1
0
        public SettingsViewModel(GitHubAuthenticationService gitHubAuthenticationService,
                                 ThemeService themeService,
                                 TrendsChartSettingsService trendsChartSettingsService,
                                 IAnalyticsService analyticsService,
                                 DeepLinkingService deepLinkingService,
                                 NotificationService notificationService,
                                 IMainThread mainThread,
                                 GitHubUserService gitHubUserService)
            : base(gitHubAuthenticationService, deepLinkingService, analyticsService, mainThread, gitHubUserService)
        {
            _trendsChartSettingsService = trendsChartSettingsService;
            _deepLinkingService         = deepLinkingService;
            _notificationService        = notificationService;
            _themeService = themeService;

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

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

            ThemePickerSelectedThemeIndex = (int)themeService.Preference;

            if (Application.Current is App app)
            {
                app.Resumed += HandleResumed;
            }

            initializeIsRegisterForNotificationsSwitch().SafeFireAndForget();

            SetGitHubValues();

            async Task initializeIsRegisterForNotificationsSwitch() => IsRegisterForNotificationsSwitchToggled = notificationService.ShouldSendNotifications && await notificationService.AreNotificationsEnabled().ConfigureAwait(false);
        }
예제 #2
0
        public TrendsViewModel(IMainThread mainThread,
                               IAnalyticsService analyticsService,
                               GitHubApiV3Service gitHubApiV3Service,
                               GitHubApiStatusService gitHubApiStatusService,
                               GitHubGraphQLApiService gitHubGraphQLApiService,
                               TrendsChartSettingsService trendsChartSettingsService) : base(analyticsService, mainThread)
        {
            _gitHubApiV3Service      = gitHubApiV3Service;
            _gitHubApiStatusService  = gitHubApiStatusService;
            _gitHubGraphQLApiService = gitHubGraphQLApiService;

            IsViewsSeriesVisible        = trendsChartSettingsService.ShouldShowViewsByDefault;
            IsUniqueViewsSeriesVisible  = trendsChartSettingsService.ShouldShowUniqueViewsByDefault;
            IsClonesSeriesVisible       = trendsChartSettingsService.ShouldShowClonesByDefault;
            IsUniqueClonesSeriesVisible = trendsChartSettingsService.ShouldShowUniqueClonesByDefault;

            ViewsCardTappedCommand        = new Command(() => IsViewsSeriesVisible = !IsViewsSeriesVisible);
            UniqueViewsCardTappedCommand  = new Command(() => IsUniqueViewsSeriesVisible = !IsUniqueViewsSeriesVisible);
            ClonesCardTappedCommand       = new Command(() => IsClonesSeriesVisible = !IsClonesSeriesVisible);
            UniqueClonesCardTappedCommand = new Command(() => IsUniqueClonesSeriesVisible = !IsUniqueClonesSeriesVisible);

            RefreshState = RefreshState.Uninitialized;

            FetchDataCommand = new AsyncCommand <(Repository Repository, CancellationToken CancellationToken)>(tuple => ExecuteFetchDataCommand(tuple.Repository, tuple.CancellationToken));
        }
예제 #3
0
        public TrendsChartSettingsView(TrendsChartSettingsService trendsChartSettingsService)
        {
            _trendsChartSettingsService = trendsChartSettingsService;

            const double cornerRadius = 5;

            var trendsChartSettingsLabel = new Label
            {
                Text                  = "Default Charts",
                FontAttributes        = FontAttributes.Bold,
                FontSize              = 18,
                VerticalTextAlignment = TextAlignment.Center
            };

            trendsChartSettingsLabel.SetDynamicResource(Label.TextColorProperty, nameof(BaseTheme.TrendsChartSettingsLabelTextColor));

            var selectionIndicatorSettings = new SelectionIndicatorSettings
            {
                CornerRadius = cornerRadius
            };

            selectionIndicatorSettings.SetDynamicResource(SelectionIndicatorSettings.ColorProperty, nameof(BaseTheme.TrendsChartSettingsSelectionIndicatorColor));

            var trendsChartSettingControl = new SfSegmentedControl
            {
                ItemsSource                = _trendsChartOptions.Values.ToList(),
                VisibleSegmentsCount       = _trendsChartOptions.Values.Count,
                CornerRadius               = cornerRadius,
                SelectedIndex              = (int)_trendsChartSettingsService.CurrentTrendsChartOption,
                SelectionIndicatorSettings = selectionIndicatorSettings
            };

            trendsChartSettingControl.SetDynamicResource(SfSegmentedControl.BorderColorProperty, nameof(BaseTheme.TrendsChartSettingsBorderColor));
            trendsChartSettingControl.SetDynamicResource(SfSegmentedControl.FontColorProperty, nameof(BaseTheme.TrendsChartSettingsFontColor));
            trendsChartSettingControl.SelectionChanged += HandleSelectionChanged;

            var grid = new Grid
            {
                RowDefinitions =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

            grid.Children.Add(trendsChartSettingsLabel, 0, 0);
            grid.Children.Add(trendsChartSettingControl, 0, 1);

            Content = grid;
        }
예제 #4
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));
        }
예제 #5
0
 public UITestBackdoorService(GitHubAuthenticationService gitHubAuthenticationService,
                              GitHubGraphQLApiService gitHubGraphQLApiService,
                              TrendsChartSettingsService trendsChartSettingsService)
 {
     _gitHubAuthenticationService = gitHubAuthenticationService;
     _gitHubGraphQLApiService     = gitHubGraphQLApiService;
     _trendsChartSettingsService  = trendsChartSettingsService;
 }
예제 #6
0
        public SettingsPage(SettingsViewModel settingsViewModel,
                            TrendsChartSettingsService trendsChartSettingsService,
                            AnalyticsService analyticsService) : base(PageTitles.SettingsPage, settingsViewModel, analyticsService)
        {
            _trendsChartSettingsService = trendsChartSettingsService;

            ViewModel.GitHubLoginUrlRetrieved           += HandleGitHubLoginUrlRetrieved;
            ViewModel.RegisterForNotificationsCompleted += HandleRegisterForNotificationsCompleted;
        }
예제 #7
0
        public SettingsPage(SettingsViewModel settingsViewModel,
                            TrendsChartSettingsService trendsChartSettingsService,
                            AnalyticsService analyticsService,
                            DeepLinkingService deepLinkingService) : base(PageTitles.SettingsPage, settingsViewModel, analyticsService)
        {
            _trendsChartSettingsService = trendsChartSettingsService;
            _deepLinkingService         = deepLinkingService;

            ViewModel.GitHubLoginUrlRetrieved += HandleGitHubLoginUrlRetrieved;
        }
예제 #8
0
        public SettingsViewModel(GitHubAuthenticationService gitHubAuthenticationService, TrendsChartSettingsService trendsChartSettingsService)
        {
            _gitHubAuthenticationService = gitHubAuthenticationService;
            _trendsChartSettingsService  = trendsChartSettingsService;

            LoginButtonCommand = new AsyncCommand(ExecuteLoginButtonCommand);

            _gitHubAuthenticationService.AuthorizeSessionCompleted += HandleAuthorizeSessionCompleted;
            _gitHubAuthenticationService.AuthorizeSessionStarted   += HandleAuthorizeSessionStarted;

            SetGitHubValues();
        }
예제 #9
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;
 }
예제 #10
0
        public TrendsViewModel(GitHubApiV3Service gitHubApiV3Service,
                               AnalyticsService analyticsService,
                               TrendsChartSettingsService trendsChartSettingsService) : base(analyticsService)
        {
            _gitHubApiV3Service = gitHubApiV3Service;

            IsViewsSeriesVisible        = trendsChartSettingsService.ShouldShowViewsByDefault;
            IsUniqueViewsSeriesVisible  = trendsChartSettingsService.ShouldShowUniqueViewsByDefault;
            IsClonesSeriesVisible       = trendsChartSettingsService.ShouldShowClonesByDefault;
            IsUniqueClonesSeriesVisible = trendsChartSettingsService.ShouldShowUniqueClonesByDefault;

            ViewsCardTappedCommand        = new Command(() => IsViewsSeriesVisible = !IsViewsSeriesVisible);
            UniqueViewsCardTappedCommand  = new Command(() => IsUniqueViewsSeriesVisible = !IsUniqueViewsSeriesVisible);
            ClonesCardTappedCommand       = new Command(() => IsClonesSeriesVisible = !IsClonesSeriesVisible);
            UniqueClonesCardTappedCommand = new Command(() => IsUniqueClonesSeriesVisible = !IsUniqueClonesSeriesVisible);

            FetchDataCommand = new AsyncCommand <(Repository Repository, CancellationToken CancellationToken)>(tuple => ExecuteFetchDataCommand(tuple.Repository, tuple.CancellationToken));
        }
예제 #11
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);
        }
예제 #12
0
        public SettingsPage(SettingsViewModel settingsViewModel, TrendsChartSettingsService trendsChartSettingsService) : base(PageTitles.SettingsPage, settingsViewModel)
        {
            ViewModel.GitHubLoginUrlRetrieved += HandleGitHubLoginUrlRetrieved;

            var stackLayout = new StackLayout
            {
                Padding           = new Thickness(20),
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Center,
                Children          =
                {
                    new GitHubSettingsView(),
                    new TrendsChartSettingsView(trendsChartSettingsService)
                }
            };

            Content = new ScrollView {
                Content = stackLayout
            };
        }
예제 #13
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;
        }
예제 #14
0
        public SettingsPage(SettingsViewModel settingsViewModel,
                            TrendsChartSettingsService trendsChartSettingsService,
                            IAnalyticsService analyticsService,
                            IMainThread mainThread,
                            IVersionTracking versionTracking) : base(settingsViewModel, analyticsService, mainThread, PageTitles.SettingsPage, true)
        {
            const int separatorRowHeight = 1;
            const int settingsRowHeight  = 38;

            var loginRowTapGesture = new TapGestureRecognizer();

            loginRowTapGesture.Tapped += HandleLoginRowTapped;

            Content = new ScrollView
            {
                Content = _contentGrid = new Grid
                {
                    RowSpacing    = 8,
                    ColumnSpacing = 16.5,

                    Margin = new Thickness(30, 0, 30, 5),

                    RowDefinitions = Rows.Define(
                        (Row.GitHubUser, AbsoluteGridLength(GitHubUserView.TotalHeight)),
                        (Row.GitHubUserSeparator, AbsoluteGridLength(separatorRowHeight)),
                        (Row.Login, AbsoluteGridLength(settingsRowHeight)),
                        (Row.LoginSeparator, AbsoluteGridLength(separatorRowHeight)),
                        (Row.Notifications, AbsoluteGridLength(settingsRowHeight)),
                        (Row.NotificationsSeparator, AbsoluteGridLength(separatorRowHeight)),
                        (Row.Theme, AbsoluteGridLength(settingsRowHeight)),
                        (Row.ThemeSeparator, AbsoluteGridLength(separatorRowHeight)),
                        (Row.PreferredCharts, AbsoluteGridLength(80)),
                        (Row.Copyright, Star)),

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

                    Children =
                    {
                        new GitHubUserView().Row(Row.GitHubUser).ColumnSpan(All <Column>()),

                        new Separator().Row(Row.GitHubUserSeparator).ColumnSpan(All <Column>()),

                        new LoginRowTappableView(loginRowTapGesture).Row(Row.Login).ColumnSpan(All <Column>()),
                        new LoginRowSvg("logout.svg",                                                                  getSVGIconColor).Row(Row.Login).Column(Column.Icon),
                        new LoginLabel().Row(Row.Login).Column(Column.Title),
                        new LoginRowSvg("right_arrow.svg",                                                             getSVGIconColor).End().Row(Row.Login).Column(Column.Button),

                        new Separator().Row(Row.LoginSeparator).ColumnSpan(All <Column>()),

                        new SvgImage("bell.svg",                                                                       getSVGIconColor).Row(Row.Notifications).Column(Column.Icon),
                        new RegisterForNotificationsLabel().Row(Row.Notifications).Column(Column.Title),
                        new EnableNotificationsSwitch().Row(Row.Notifications).Column(Column.Button),

                        new Separator().Row(Row.NotificationsSeparator).ColumnSpan(All <Column>()),

                        new SvgImage("theme.svg",                                                                      getSVGIconColor).Row(Row.Theme).Column(Column.Icon),
                        new ThemeLabel().Row(Row.Theme).Column(Column.Title),
                        new ThemePicker().Row(Row.Theme).Column(Column.Button),

                        new Separator().Row(Row.ThemeSeparator).ColumnSpan(All <Column>()),

                        new PreferredChartsView(settingsViewModel).Row(Row.PreferredCharts).ColumnSpan(All <Column>()),

                        new CopyrightLabel(versionTracking).Row(Row.Copyright).ColumnSpan(All <Column>())
                    }
                }
            };