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 }; _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 = 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)); }
public WelcomeViewModel(GitHubAuthenticationService gitHubAuthenticationService, DeepLinkingService deepLinkingService, AnalyticsService analyticsService) : base(gitHubAuthenticationService, deepLinkingService, analyticsService) { }
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(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)); } }
public AboutPage(IMainThread mainThread, AboutViewModel aboutViewModel, IAnalyticsService analyticsService, DeepLinkingService deepLinkingService) : base(aboutViewModel, analyticsService, mainThread) { const int horizontalPadding = 28; var titleRowHeight = IsSmallScreen ? 16 : 20; var descriptionRowHeight = IsSmallScreen ? 28 : 32; _deepLinkingService = deepLinkingService; Title = PageTitles.AboutPage; Padding = new Thickness(0, 16, 0, 0); Content = new Grid { ColumnSpacing = 2, RowSpacing = 6, ColumnDefinitions = Columns.Define( (Column.LeftPadding, horizontalPadding), (Column.Icon, 108), (Column.Statistics, Star), (Column.RightPadding, horizontalPadding)), RowDefinitions = Rows.Define( (Row.Title, IsSmallScreen ? 28 : 32), (Row.Description, IsSmallScreen ? 44 : 48), (Row.Statistics, IsSmallScreen ? 28 : 36), (Row.ActionButtons, IsSmallScreen ? 64 : 68), (Row.CollaboratorTitle, titleRowHeight), (Row.CollaboratorDescription, descriptionRowHeight), (Row.CollaboratorCollection, IsSmallScreen ? 84 : 100), (Row.LibrariesTitle, titleRowHeight), (Row.LibrariesDescription, descriptionRowHeight), (Row.LibrariesCollection, Star)), Children = { new Image().CenterExpand().Margins(right: IsSmallScreen ? 8 : 12) .Row(Row.Title).RowSpan(3).Column(Column.Icon) .DynamicResource(Image.SourceProperty, nameof(BaseTheme.GitTrendsImageSource)), new Label { Text = "GitTrends" }.Font(FontFamilyConstants.RobotoMedium, 24) .Row(Row.Title).Column(Column.Statistics) .DynamicResource(Label.TextColorProperty, nameof(BaseTheme.SettingsLabelTextColor)), new DescriptionLabel(AboutPageConstants.DescriptionText) { MaxLines = 3 } .Row(Row.Description).Column(Column.Statistics), new GitTrendsStatisticsView() .Row(Row.Statistics).Column(Column.Statistics), new ButtonLayout().Center() .Row(Row.ActionButtons).Column(Column.Icon).ColumnSpan(2), new TitleLabel(AboutPageConstants.CollaboratorsTitle).TextBottom().BottomExpand() .Row(Row.CollaboratorTitle).Column(Column.Icon).ColumnSpan(2), new DescriptionLabel(AboutPageConstants.CollaboratorsDescription) .Row(Row.CollaboratorDescription).Column(Column.Icon).ColumnSpan(2), new CollectionView { HorizontalScrollBarVisibility = ScrollBarVisibility.Never, HeightRequest = ContributorDataTemplate.RowHeight + 8, Header = new BoxView { WidthRequest = horizontalPadding }, SelectionMode = SelectionMode.Single, ItemTemplate = new ContributorDataTemplate(), ItemsSource = ViewModel.GitTrendsContributors, ItemsLayout = new LinearItemsLayout(ItemsLayoutOrientation.Horizontal) }.Top() .Row(Row.CollaboratorCollection).ColumnSpan(All <Column>()) .Invoke(collectionView => collectionView.SelectionChanged += HandleContributorSelectionChanged), new TitleLabel(AboutPageConstants.LibrariesTitle) .Row(Row.LibrariesTitle).Column(Column.Icon).ColumnSpan(2), new DescriptionLabel(AboutPageConstants.LibrariesDescription) .Row(Row.LibrariesDescription).Column(Column.Icon).ColumnSpan(2), new CollectionView { HorizontalScrollBarVisibility = ScrollBarVisibility.Never, HeightRequest = IsSmallScreen ? LibraryDataTemplate.RowHeight + 8 : LibraryDataTemplate.RowHeight * 2 + 8, Header = new BoxView { WidthRequest = horizontalPadding }, SelectionMode = SelectionMode.Single, ItemTemplate = new LibraryDataTemplate(), ItemsSource = ViewModel.InstalledLibraries, ItemsLayout = IsSmallScreen ? new LinearItemsLayout(ItemsLayoutOrientation.Horizontal) : new GridItemsLayout(2, ItemsLayoutOrientation.Horizontal) }.Top() .Row(Row.LibrariesCollection).ColumnSpan(All <Column>()) .Invoke(collectionView => collectionView.SelectionChanged += HandleLibrarySelectionChanged), } }; }
public ReferringSitesPage(DeepLinkingService deepLinkingService, ReferringSitesViewModel referringSitesViewModel, Repository repository, AnalyticsService analyticsService, ThemeService themeService, ReviewService reviewService) : base(referringSitesViewModel, analyticsService, PageTitles.ReferringSitesPage) { _deepLinkingService = deepLinkingService; _reviewService = reviewService; 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.TextProperty, nameof(ReferringSitesViewModel.EmptyDataViewText)) }; 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 = "Close", 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.NavigationBarTextColor)); closeButton.SetDynamicResource(Button.BorderColorProperty, nameof(BaseTheme.BorderButtonBorderColor)); closeButton.SetDynamicResource(BackgroundColorProperty, nameof(BaseTheme.NavigationBarBackgroundColor)); 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.PageBackgroundColor)); 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 NotificationService(AnalyticsService analyticsService, DeepLinkingService deepLinkingService) => (_analyticsService, _deepLinkingService) = (analyticsService, deepLinkingService);
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);