Пример #1
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));
        }
Пример #2
0
        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));
            }
        }