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 RepositoryPage(RepositoryViewModel repositoryViewModel, AnalyticsService analyticsService, SortingService sortingService) : base(PageTitles.RepositoryPage, repositoryViewModel, analyticsService) { ViewModel.PullToRefreshFailed += HandlePullToRefreshFailed; SearchBarTextChanged += HandleSearchBarTextChanged; var collectionView = new CollectionView { ItemTemplate = new RepositoryDataTemplateSelector(sortingService), 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 += HandleSettingsToolbarItemCliked; ToolbarItems.Add(settingsToolbarItem); var sortToolbarItem = new ToolbarItem { Text = "Sort", IconImageSource = Device.RuntimePlatform is Device.iOS ? "Sort" : null, Order = Device.RuntimePlatform is Device.Android ? ToolbarItemOrder.Secondary : ToolbarItemOrder.Default, AutomationId = RepositoryPageAutomationIds.SortButton, }; sortToolbarItem.Clicked += HandleSortToolbarItemCliked; ToolbarItems.Add(sortToolbarItem); Content = repositoriesListRefreshView; }
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 RepositoryPage(RepositoryViewModel repositoryViewModel, AnalyticsService analyticsService, SortingService sortingService, DeepLinkingService deepLinkingService) : base(repositoryViewModel, analyticsService, PageTitles.RepositoryPage) { _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 = 8 } : null, Footer = Device.RuntimePlatform is Device.Android ? new BoxView { HeightRequest = 8 } : null, EmptyView = new EmptyDataView("EmptyRepositoriesList", RepositoryPageAutomationIds.EmptyDataView) .Bind <EmptyDataView, bool, bool>(IsVisibleProperty, nameof(RepositoryViewModel.IsRefreshing), convert: isRefreshing => !isRefreshing) .Bind(EmptyDataView.TextProperty, nameof(RepositoryViewModel.EmptyDataViewText)) }; collectionView.SelectionChanged += HandleCollectionViewSelectionChanged; collectionView.SetBinding(CollectionView.ItemsSourceProperty, nameof(RepositoryViewModel.VisibleRepositoryList)); _refreshView = new RefreshView { AutomationId = RepositoryPageAutomationIds.RefreshView, Content = collectionView }; _refreshView.SetDynamicResource(RefreshView.RefreshColorProperty, nameof(BaseTheme.PullToRefreshColor)); _refreshView.SetBinding(RefreshView.IsRefreshingProperty, nameof(RepositoryViewModel.IsRefreshing)); _refreshView.SetBinding(RefreshView.CommandProperty, nameof(RepositoryViewModel.PullToRefreshCommand)); var settingsToolbarItem = new ToolbarItem { Text = "Settings", 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 = "Sort", 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; } }
public NotificationService(AnalyticsService analyticsService, DeepLinkingService deepLinkingService, SortingService sortingService) => (_analyticsService, _deepLinkingService, _sortingService) = (analyticsService, deepLinkingService, sortingService);
public RepositoryDataTemplateSelector(SortingService sortingService) => _sortingService = sortingService;