public async Task <List <ReferringSiteModel> > GetReferringSites(string owner, string repo) { if (GitHubAuthenticationService.IsDemoUser) { //Yield off of main thread to generate MobileReferringSiteModels await Task.Yield(); var referringSitesList = new List <ReferringSiteModel>(); for (int i = 0; i < DemoDataConstants.ReferringSitesCount; i++) { referringSitesList.Add(new ReferringSiteModel(DemoDataConstants.GetRandomNumber(), DemoDataConstants.GetRandomNumber(), DemoDataConstants.GetRandomText())); } return(referringSitesList); } else { var token = await GitHubAuthenticationService.GetGitHubToken().ConfigureAwait(false); var referringSites = await AttemptAndRetry_Mobile(() => GithubApiClient.GetReferingSites(owner, repo, GetGitHubBearerTokenHeader(token))).ConfigureAwait(false); return(referringSites); } }
public OnboardingCarouselPage(GitTrendsOnboardingPage welcomeOnboardingPage, ChartOnboardingPage chartOnboardingPage, NotificationsOnboardingPage notificationsOnboardingPage, ConnectToGitHubOnboardingPage connectToGitHubOnboardingPage, OnboardingViewModel onboardingViewModel, GitHubAuthenticationService gitHubAuthenticationService, IAnalyticsService analyticsService, IMainThread mainThread) { On <iOS>().SetModalPresentationStyle(UIModalPresentationStyle.OverFullScreen); ChildAdded += HandleChildAdded; ChildRemoved += HandleChildRemoved; BindingContext = onboardingViewModel; _analyticsService = analyticsService; _mainThread = mainThread; onboardingViewModel.SkipButtonTapped += HandleSkipButtonTapped; gitHubAuthenticationService.DemoUserActivated += HandleDemoUserActivated; Children.Add(welcomeOnboardingPage); Children.Add(chartOnboardingPage); Children.Add(notificationsOnboardingPage); Children.Add(connectToGitHubOnboardingPage); }
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); }
public async Task <RepositoryClonesModel> GetRepositoryCloneStatistics(string owner, string repo) { if (GitHubAuthenticationService.IsDemoUser) { //Yield off of the main thread to generate dailyViewsModelList await Task.Yield(); var dailyViewsModelList = new List <DailyClonesModel>(); for (int i = 0; i < 14; i++) { var count = DemoDataConstants.GetRandomNumber() / 2; //Ensures the average clone count is smaller than the average view count var uniqeCount = count / 2; //Ensures uniqueCount is always less than count dailyViewsModelList.Add(new DailyClonesModel(DateTimeOffset.UtcNow.Subtract(TimeSpan.FromDays(i)), count, uniqeCount)); } return(new RepositoryClonesModel(dailyViewsModelList.Sum(x => x.TotalClones), dailyViewsModelList.Sum(x => x.TotalUniqueClones), dailyViewsModelList)); } else { var token = await GitHubAuthenticationService.GetGitHubToken().ConfigureAwait(false); return(await AttemptAndRetry_Mobile(() => GithubApiClient.GetRepositoryCloneStatistics(owner, repo, GetGitHubBearerTokenHeader(token))).ConfigureAwait(false)); } }
public async IAsyncEnumerable <MobileReferringSiteModel> GetReferringSites(string owner, string repo) { if (GitHubAuthenticationService.IsDemoUser) { //Yield off of main thread to generate MobileReferringSiteModels await Task.Yield(); for (int i = 0; i < DemoDataConstants.ReferringSitesCount; i++) { yield return(new MobileReferringSiteModel(new ReferringSiteModel(DemoDataConstants.GetRandomNumber(), DemoDataConstants.GetRandomNumber(), DemoDataConstants.GetRandomText()), "DefaultProfileImage")); } //Allow UI to update await Task.Delay(1000).ConfigureAwait(false); } else { var token = await GitHubAuthenticationService.GetGitHubToken().ConfigureAwait(false); var referringSites = await AttemptAndRetry_Mobile(() => GithubApiClient.GetReferingSites(owner, repo, GetGitHubBearerTokenHeader(token))).ConfigureAwait(false); await foreach (var referringSite in getMobileReferringSiteModels(referringSites).ConfigureAwait(false)) { yield return(referringSite); }
public ConnectToGitHubOnboardingPage(GitHubAuthenticationService gitHubAuthenticationService, IAnalyticsService analyticsService, IMainThread mainthread) : base(analyticsService, mainthread, Color.FromHex(BaseTheme.CoralColorHex), OnboardingConstants.TryDemoText, 3) { gitHubAuthenticationService.AuthorizeSessionCompleted += HandleAuthorizeSessionCompleted; }
async Task <RepositoryConnection> GetRepositoryConnection(string repositoryOwner, string?endCursor, CancellationToken cancellationToken, int numberOfRepositoriesPerRequest = 100) { var token = await GitHubAuthenticationService.GetGitHubToken().ConfigureAwait(false); var data = await ExecuteGraphQLRequest(() => GitHubApiClient.RepositoryConnectionQuery(new RepositoryConnectionQueryContent(repositoryOwner, getEndCursorString(endCursor), numberOfRepositoriesPerRequest), GetGitHubBearerTokenHeader(token)), cancellationToken).ConfigureAwait(false); return(data.GitHubUser.RepositoryConnection);
public async Task <RepositoryViewsResponseModel> GetRepositoryViewStatistics(string owner, string repo, CancellationToken cancellationToken = default) { if (GitHubAuthenticationService.IsDemoUser) { //Yield off of the main thread to generate dailyViewsModelList await Task.Yield(); var dailyViewsModelList = new List <DailyViewsModel>(); for (int i = 1; i < 14; i++) { var count = DemoDataConstants.GetRandomNumber(); var uniqeCount = count / 2; //Ensures uniqueCount is always less than count dailyViewsModelList.Add(new DailyViewsModel(DateTimeOffset.UtcNow.Subtract(TimeSpan.FromDays(i)), count, uniqeCount)); } //Add one trending repo dailyViewsModelList.Add(new DailyViewsModel(DateTimeOffset.UtcNow, DemoDataConstants.MaximumRandomNumber * 4, DemoDataConstants.MaximumRandomNumber / 2)); return(new RepositoryViewsResponseModel(repo, owner, dailyViewsModelList.Sum(x => x.TotalViews), dailyViewsModelList.Sum(x => x.TotalUniqueViews), dailyViewsModelList)); } else { var token = await GitHubAuthenticationService.GetGitHubToken().ConfigureAwait(false); var response = await AttemptAndRetry_Mobile(() => GithubApiClient.GetRepositoryViewStatistics(owner, repo, GetGitHubBearerTokenHeader(token))).ConfigureAwait(false); return(new RepositoryViewsResponseModel(repo, owner, response.TotalCount, response.TotalUniqueCount, response.DailyViewsList)); } }
public RepositoryViewModel(RepositoryDatabase repositoryDatabase, GitHubAuthenticationService gitHubAuthenticationService, GitHubGraphQLApiService gitHubGraphQLApiService, IAnalyticsService analyticsService, SortingService sortingService, GitHubApiV3Service gitHubApiV3Service, NotificationService notificationService, IMainThread mainThread, GitHubUserService gitHubUserService) : base(analyticsService, mainThread) { _repositoryDatabase = repositoryDatabase; _gitHubAuthenticationService = gitHubAuthenticationService; _gitHubGraphQLApiService = gitHubGraphQLApiService; _sortingService = sortingService; _gitHubApiV3Service = gitHubApiV3Service; _gitHubUserService = gitHubUserService; RefreshState = RefreshState.Uninitialized; PullToRefreshCommand = new AsyncCommand(() => ExecutePullToRefreshCommand(gitHubUserService.Alias)); FilterRepositoriesCommand = new Command <string>(SetSearchBarText); SortRepositoriesCommand = new Command <SortingOption>(ExecuteSortRepositoriesCommand); notificationService.SortingOptionRequested += HandleSortingOptionRequested; gitHubAuthenticationService.LoggedOut += HandleGitHubAuthenticationServiceLoggedOut; gitHubAuthenticationService.AuthorizeSessionCompleted += HandleAuthorizeSessionCompleted; gitHubAuthenticationService.DemoUserActivated += HandleDemoUserActivated; }
public ReferringSitesViewModel(IMainThread mainThread, ReviewService reviewService, FavIconService favIconService, IVersionTracking versionTracking, IAnalyticsService analyticsService, GitHubUserService gitHubUserService, GitHubApiV3Service gitHubApiV3Service, DeepLinkingService deepLinkingService, ReferringSitesDatabase referringSitesDatabase, GitHubAuthenticationService gitHubAuthenticationService) : base(analyticsService, mainThread) { ReviewService.ReviewRequested += HandleReviewRequested; ReviewService.ReviewCompleted += HandleReviewCompleted; _reviewService = reviewService; _favIconService = favIconService; _versionTracking = versionTracking; _gitHubUserService = gitHubUserService; _gitHubApiV3Service = gitHubApiV3Service; _deepLinkingService = deepLinkingService; _referringSitesDatabase = referringSitesDatabase; _gitHubAuthenticationService = gitHubAuthenticationService; RefreshState = RefreshState.Uninitialized; RefreshCommand = new AsyncCommand <(string Owner, string Repository, string RepositoryUrl, CancellationToken Token)>(tuple => ExecuteRefreshCommand(tuple.Owner, tuple.Repository, tuple.RepositoryUrl, tuple.Token)); NoButtonCommand = new Command(() => HandleReviewRequestButtonTapped(ReviewAction.NoButtonTapped)); YesButtonCommand = new Command(() => HandleReviewRequestButtonTapped(ReviewAction.YesButtonTapped)); UpdateStoreRatingRequestView(); }
public UITestBackdoorService(GitHubAuthenticationService gitHubAuthenticationService, GitHubGraphQLApiService gitHubGraphQLApiService, TrendsChartSettingsService trendsChartSettingsService) { _gitHubAuthenticationService = gitHubAuthenticationService; _gitHubGraphQLApiService = gitHubGraphQLApiService; _trendsChartSettingsService = trendsChartSettingsService; }
public async Task <(string login, string name, Uri avatarUri)> GetCurrentUserInfo() { var token = await GitHubAuthenticationService.GetGitHubToken().ConfigureAwait(false); var data = await ExecuteGraphQLRequest(() => GitHubApiClient.ViewerLoginQuery(new ViewerLoginQueryContent(), GetGitHubBearerTokenHeader(token))).ConfigureAwait(false); return(data.Viewer.Alias, data.Viewer.Name, data.Viewer.AvatarUri); }
public async Task <User> GetUser(string username) { var token = await GitHubAuthenticationService.GetGitHubToken().ConfigureAwait(false); var data = await ExecuteGraphQLRequest(() => GitHubApiClient.UserQuery(new UserQueryContent(username), GetGitHubBearerTokenHeader(token))).ConfigureAwait(false); return(data.User); }
public async Task <Repository> GetRepository(string repositoryOwner, string repositoryName, int numberOfIssuesPerRequest = 100) { var token = await GitHubAuthenticationService.GetGitHubToken().ConfigureAwait(false); var data = await ExecuteGraphQLRequest(() => GitHubApiClient.RepositoryQuery(new RepositoryQueryContent(repositoryOwner, repositoryName, numberOfIssuesPerRequest), GetGitHubBearerTokenHeader(token))).ConfigureAwait(false); return(data.Repository); }
public WelcomeViewModel(GitHubAuthenticationService gitHubAuthenticationService, DeepLinkingService deepLinkingService, IAnalyticsService analyticsService, IMainThread mainThread, GitHubUserService gitHubUserService) : base(gitHubAuthenticationService, deepLinkingService, analyticsService, mainThread, gitHubUserService) { }
public WelcomePage(GitHubAuthenticationService gitHubAuthenticationService, IAnalyticsService analyticsService, WelcomeViewModel welcomeViewModel, IMainThread mainThread, IAppInfo appInfo) : base(welcomeViewModel, analyticsService, mainThread, shouldUseSafeArea: true) { _appInfo = appInfo; RemoveDynamicResource(BackgroundColorProperty); On <iOS>().SetModalPresentationStyle(UIModalPresentationStyle.OverFullScreen); var pageBackgroundColor = Color.FromHex(BaseTheme.LightTealColorHex); BackgroundColor = pageBackgroundColor; gitHubAuthenticationService.DemoUserActivated += HandleDemoUserActivated; gitHubAuthenticationService.AuthorizeSessionCompleted += HandleAuthorizeSessionCompleted; var browserLaunchOptions = new Xamarin.Essentials.BrowserLaunchOptions { PreferredToolbarColor = pageBackgroundColor.MultiplyAlpha(0.75), PreferredControlColor = Color.White, Flags = Xamarin.Essentials.BrowserLaunchFlags.PresentAsFormSheet }; Content = new Grid { RowSpacing = 24, RowDefinitions = Rows.Define( (Row.WelcomeLabel, StarGridLength(2)), (Row.Image, StarGridLength(4)), (Row.GitHubButton, StarGridLength(2)), (Row.DemoButton, StarGridLength(1)), (Row.VersionLabel, StarGridLength(1))), Children = { new WelcomeLabel() .Row(Row.WelcomeLabel), new Image { Source = "WelcomeImage" }.Center() .Row(Row.Image), new ConnectToGitHubButton(_connectToGitHubCancellationTokenSource.Token, browserLaunchOptions) .Row(Row.GitHubButton), new DemoLabel() .Row(Row.DemoButton), new ConnectToGitHubActivityIndicator() .Row(Row.DemoButton), new VersionNumberLabel(_appInfo) .Row(Row.VersionLabel) } }; }
public async IAsyncEnumerable <MobileReferringSiteModel> GetReferingSites(string owner, string repo) { var token = await GitHubAuthenticationService.GetGitHubToken().ConfigureAwait(false); var referringSites = await AttemptAndRetry_Mobile(() => GithubApiClient.GetReferingSites(owner, repo, GetGitHubBearerTokenHeader(token))).ConfigureAwait(false); await foreach (var referringSite in getMobileReferringSiteModels(referringSites).ConfigureAwait(false)) { yield return(referringSite); }
protected GitHubAuthenticationViewModel(GitHubAuthenticationService gitHubAuthenticationService, DeepLinkingService deepLinkingService, AnalyticsService analyticsService) : base(analyticsService) { gitHubAuthenticationService.AuthorizeSessionStarted += HandleAuthorizeSessionStarted; gitHubAuthenticationService.AuthorizeSessionCompleted += HandleAuthorizeSessionCompleted; ConnectToGitHubButtonCommand = new AsyncCommand <(CancellationToken CancellationToken, BrowserLaunchOptions?BrowserLaunchOptions)>(tuple => ExecuteConnectToGitHubButtonCommand(gitHubAuthenticationService, deepLinkingService, tuple.CancellationToken, tuple.BrowserLaunchOptions), _ => IsNotAuthenticating); DemoButtonCommand = new AsyncCommand <string>(text => ExecuteDemoButtonCommand(text), _ => IsNotAuthenticating); GitHubAuthenticationService = gitHubAuthenticationService; }
public FirstRunService(IPreferences preferences, GitHubAuthenticationService gitHubAuthenticationService) { #if !AppStore UITestsBackdoorService.PopPageStarted += HandlePagePopped; #endif gitHubAuthenticationService.AuthorizeSessionCompleted += HandleAuthorizeSessionCompleted; gitHubAuthenticationService.DemoUserActivated += HandleDemoUserActivated; _preferences = preferences; }
public RepositoryViewModel(RepositoryDatabase repositoryDatabase, GitHubAuthenticationService gitHubAuthenticationService, GitHubGraphQLApiService gitHubGraphQLApiService) { _repositoryDatabase = repositoryDatabase; _gitHubAuthenticationService = gitHubAuthenticationService; _gitHubGraphQLApiService = gitHubGraphQLApiService; PullToRefreshCommand = new AsyncCommand(() => ExecutePullToRefreshCommand(_gitHubAuthenticationService.Alias)); FilterRepositoriesCommand = new Command <string>(text => SetSearchBarText(text)); }
public SettingsViewModel(GitHubAuthenticationService gitHubAuthenticationService, TrendsChartSettingsService trendsChartSettingsService) { _gitHubAuthenticationService = gitHubAuthenticationService; _trendsChartSettingsService = trendsChartSettingsService; LoginButtonCommand = new AsyncCommand(ExecuteLoginButtonCommand); _gitHubAuthenticationService.AuthorizeSessionCompleted += HandleAuthorizeSessionCompleted; _gitHubAuthenticationService.AuthorizeSessionStarted += HandleAuthorizeSessionStarted; SetGitHubValues(); }
public OnboardingViewModel(DeepLinkingService deepLinkingService, GitHubAuthenticationService gitHubAuthenticationService, NotificationService notificationService, AnalyticsService analyticsService) : base(gitHubAuthenticationService, deepLinkingService, analyticsService) { const string defaultNotificationSvg = "bell.svg"; _notificationService = notificationService; _analyticsService = analyticsService; NotificationStatusSvgImageSource = defaultNotificationSvg; EnableNotificationsButtonTapped = new AsyncCommand(ExecuteEnableNotificationsButtonTapped); }
protected GitHubAuthenticationViewModel(IMainThread mainThread, IAnalyticsService analyticsService, GitHubUserService gitHubUserService, DeepLinkingService deepLinkingService, GitHubAuthenticationService gitHubAuthenticationService) : base(analyticsService, mainThread) { GitHubAuthenticationService.AuthorizeSessionStarted += HandleAuthorizeSessionStarted; GitHubAuthenticationService.AuthorizeSessionCompleted += HandleAuthorizeSessionCompleted; DemoButtonCommand = new AsyncCommand <string?, object?>(text => ExecuteDemoButtonCommand(text), _ => IsNotAuthenticating); ConnectToGitHubButtonCommand = new AsyncCommand <(CancellationToken CancellationToken, Xamarin.Essentials.BrowserLaunchOptions?BrowserLaunchOptions), object?>(tuple => ExecuteConnectToGitHubButtonCommand(gitHubAuthenticationService, deepLinkingService, gitHubUserService, tuple.CancellationToken, tuple.BrowserLaunchOptions), _ => IsNotAuthenticating); GitHubUserService = gitHubUserService; GitHubAuthenticationService = gitHubAuthenticationService; }
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; }
public RepositoryViewModel(RepositoryDatabase repositoryDatabase, GitHubAuthenticationService gitHubAuthenticationService, GitHubGraphQLApiService gitHubGraphQLApiService, AnalyticsService analyticsService, SortingService sortingService, GitHubApiV3Service gitHubApiV3Service) : base(analyticsService) { _repositoryDatabase = repositoryDatabase; _gitHubAuthenticationService = gitHubAuthenticationService; _gitHubGraphQLApiService = gitHubGraphQLApiService; _sortingService = sortingService; _gitHubApiV3Service = gitHubApiV3Service; PullToRefreshCommand = new AsyncCommand(() => ExecutePullToRefreshCommand(GitHubAuthenticationService.Alias)); FilterRepositoriesCommand = new Command <string>(SetSearchBarText); SortRepositoriesCommand = new Command <SortingOption>(ExecuteSortRepositoriesCommand); _gitHubAuthenticationService.LoggedOut += HandleGitHubAuthenticationServiceLoggedOut; }
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 RepositoryPage(RepositoryViewModel repositoryViewModel, GitHubAuthenticationService gitHubAuthenticationService, AnalyticsService analyticsService) : base(PageTitles.RepositoryPage, repositoryViewModel, analyticsService) { _gitHubAuthenticationService = gitHubAuthenticationService; ViewModel.PullToRefreshFailed += HandlePullToRefreshFailed; SearchBarTextChanged += HandleSearchBarTextChanged; var collectionView = new CollectionView { ItemTemplate = new RepositoryDataTemplate(), BackgroundColor = Color.Transparent, SelectionMode = SelectionMode.Single, AutomationId = RepositoryPageAutomationIds.CollectionView }; collectionView.SelectionChanged += HandleCollectionViewSelectionChanged; collectionView.SetBinding(CollectionView.ItemsSourceProperty, nameof(RepositoryViewModel.VisibleRepositoryList)); var repositoriesListRefreshView = new RefreshView { AutomationId = RepositoryPageAutomationIds.RefreshView, Content = collectionView }; repositoriesListRefreshView.SetDynamicResource(RefreshView.RefreshColorProperty, nameof(BaseTheme.RefreshControlColor)); repositoriesListRefreshView.SetBinding(RefreshView.IsRefreshingProperty, nameof(RepositoryViewModel.IsRefreshing)); repositoriesListRefreshView.SetBinding(RefreshView.CommandProperty, nameof(RepositoryViewModel.PullToRefreshCommand)); var settingsToolbarItem = new ToolbarItem { Text = "Settings", Order = Device.RuntimePlatform is Device.Android ? ToolbarItemOrder.Secondary : ToolbarItemOrder.Default, AutomationId = RepositoryPageAutomationIds.SettingsButton }; settingsToolbarItem.Clicked += HandleSettingsToolbarItem; ToolbarItems.Add(settingsToolbarItem); Content = repositoriesListRefreshView; }
public RepositoryPage(RepositoryViewModel repositoryViewModel, GitHubAuthenticationService gitHubAuthenticationService, bool isInitiatedByCallBackUri = false) : base(PageTitles.RepositoryPage, repositoryViewModel) { _shouldNavigateToSettingsPageOnAppearing = isInitiatedByCallBackUri; _gitHubAuthenticationService = gitHubAuthenticationService; ViewModel.PullToRefreshFailed += HandlePullToRefreshFailed; SearchBarTextChanged += HandleSearchBarTextChanged; var collectionView = new CollectionView { ItemTemplate = new RepositoryDataTemplate(), BackgroundColor = Color.Transparent, SelectionMode = SelectionMode.Single }; collectionView.SelectionChanged += HandleCollectionViewSelectionChanged; collectionView.SetBinding(CollectionView.ItemsSourceProperty, nameof(RepositoryViewModel.VisibleRepositoryList)); var repositoriesListRefreshView = new RefreshView { Content = collectionView }; repositoriesListRefreshView.SetDynamicResource(RefreshView.RefreshColorProperty, nameof(BaseTheme.RefreshControlColor)); repositoriesListRefreshView.SetBinding(RefreshView.IsRefreshingProperty, nameof(RepositoryViewModel.IsRefreshing)); repositoriesListRefreshView.SetBinding(RefreshView.CommandProperty, nameof(RepositoryViewModel.PullToRefreshCommand)); var settingsToolbarItem = new ToolbarItem { Text = "Settings", Order = Device.RuntimePlatform is Device.Android ? ToolbarItemOrder.Secondary : ToolbarItemOrder.Default }; settingsToolbarItem.Clicked += HandleSettingsToolbarItem; ToolbarItems.Add(settingsToolbarItem); Content = repositoriesListRefreshView; }
public RepositoryViewModel(IMainThread mainThread, ImageCachingService imageService, IAnalyticsService analyticsService, GitHubUserService gitHubUserService, MobileSortingService sortingService, RepositoryDatabase repositoryDatabase, GitHubApiV3Service gitHubApiV3Service, GitHubGraphQLApiService gitHubGraphQLApiService, GitHubApiExceptionService gitHubApiExceptionService, GitHubAuthenticationService gitHubAuthenticationService, GitHubApiRepositoriesService gitHubApiRepositoriesService) : base(analyticsService, mainThread) { LanguageService.PreferredLanguageChanged += HandlePreferredLanguageChanged; SetTitleText(); _imageService = imageService; _gitHubUserService = gitHubUserService; _mobileSortingService = sortingService; _repositoryDatabase = repositoryDatabase; _gitHubApiV3Service = gitHubApiV3Service; _gitHubGraphQLApiService = gitHubGraphQLApiService; _gitHubApiExceptionService = gitHubApiExceptionService; _gitHubAuthenticationService = gitHubAuthenticationService; _gitHubApiRepositoriesService = gitHubApiRepositoriesService; RefreshState = RefreshState.Uninitialized; PullToRefreshCommand = new AsyncCommand(() => ExecutePullToRefreshCommand(gitHubUserService.Alias)); FilterRepositoriesCommand = new Command <string>(SetSearchBarText); SortRepositoriesCommand = new Command <SortingOption>(ExecuteSortRepositoriesCommand); NotificationService.SortingOptionRequested += HandleSortingOptionRequested; GitHubAuthenticationService.DemoUserActivated += HandleDemoUserActivated; GitHubAuthenticationService.LoggedOut += HandleGitHubAuthenticationServiceLoggedOut; GitHubAuthenticationService.AuthorizeSessionCompleted += HandleAuthorizeSessionCompleted; }
protected override async Task ExecuteDemoButtonCommand(string?buttonText) { await base.ExecuteDemoButtonCommand(buttonText).ConfigureAwait(false); await GitHubAuthenticationService.ActivateDemoUser().ConfigureAwait(false); }