Ejemplo n.º 1
0
        public ChooseSessionView(Slot slot, Session session)
        {
            BaseViewModel.CreateAndBind <ChooseSessionViewModel> (this, slot, session);

            NavigationPage.SetBackButtonTitle(this, "");

            ToolbarItems.Add(CreateSelectButton());

            SetBinding(ChooseSessionView.NavigationProperty, new Binding("Navigation"));
            SetBinding(ChooseSessionView.TitleProperty, new Binding("Title"));
            SetBinding(ChooseSessionView.SelectButtonTextProperty, new Binding("SelectButtonText"));

            var relativeLayout = new RelativeLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand
            };

            var lowerStackLayout = new StackLayout
            {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.EndAndExpand,
                Spacing           = 20,
                Padding           = new Thickness(0, 20, 0, 20),
            };

            lowerStackLayout.Children.Add(CreatePips());
            lowerStackLayout.Children.Add(CreateRateButton());

            relativeLayout.Children.Add(lowerStackLayout,
                                        Constraint.RelativeToParent((parent) => { return(parent.X); }),
                                        Constraint.RelativeToParent((parent) => { return(parent.Height - 100); }),
                                        Constraint.RelativeToParent((parent) => { return(parent.Width); })
                                        );

            sessionInfoCarousel = CreateSessionInfoCarousel();
            relativeLayout.Children.Add(sessionInfoCarousel,
                                        Constraint.RelativeToParent((parent) => { return(parent.X); }),
                                        Constraint.RelativeToParent((parent) => { return(parent.Y); }),
                                        Constraint.RelativeToParent((parent) => { return(parent.Width); }),
                                        Constraint.RelativeToView(lowerStackLayout, (parent, sibling) => { return(parent.Height - sibling.Height); })
                                        );

            var fadeOut = CreateFadeOut();

            relativeLayout.Children.Add(fadeOut,
                                        Constraint.RelativeToParent(parent => { return(parent.X); }),
                                        Constraint.RelativeToView(lowerStackLayout, (parent, sibling) => { return(sibling.Y - 30); }),
                                        Constraint.RelativeToParent(parent => { return(parent.Width); }),
                                        Constraint.Constant(40)
                                        );

            Content = relativeLayout;
        }
Ejemplo n.º 2
0
        View CreateDayRow()
        {
            var carousel = new CarouselLayout {
                HeightRequest = 40,
                ItemTemplate  = new DataTemplate(typeof(DayHeader))
            };

            carousel.SetBinding(CarouselLayout.ItemsSourceProperty, "AgendaDays", BindingMode.OneWay);
            carousel.SetBinding(CarouselLayout.SelectedItemProperty, "SelectedDay", BindingMode.TwoWay);
            return(carousel);
        }
        View CreateDayRow()
        {
            var carousel = new CarouselLayout {
                HeightRequest = 40,
                ItemTemplate  = new DataTemplate(typeof(DayHeader))
            };

            carousel.SetBinding(CarouselLayout.ItemsSourceProperty, "FullScheduleDays");
            carousel.SetBinding(CarouselLayout.SelectedItemProperty, "SelectedDay");
            return(carousel);
        }
        CarouselLayout CreatePagesCarousel()
        {
            var carousel = new CarouselLayout {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                IndicatorStyle    = _indicatorStyle,
                ItemTemplate      = new DataTemplate(typeof(HomeView))
            };

            carousel.SetBinding(CarouselLayout.ItemsSourceProperty, "Pages");
            carousel.SetBinding(CarouselLayout.SelectedItemProperty, "CurrentPage", BindingMode.TwoWay);

            return(carousel);
        }
        CarouselLayout CreatePagesCarousel()
        {
            var carousel = new CarouselLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand,
                IndicatorStyle = _indicatorStyle,
                ItemTemplate = new DataTemplate(typeof(DynamicTemplateLayout))
            };
            carousel.SetBinding(CarouselLayout.ItemsSourceProperty, "Pages");
            carousel.SetBinding(CarouselLayout.SelectedItemProperty, "CurrentPage", BindingMode.TwoWay);

            return carousel;
        }
Ejemplo n.º 6
0
        CarouselLayout CreateSessionInfoCarousel()
        {
            var carousel = new CarouselLayout
            {
                ItemTemplate      = new DataTemplate(typeof(SessionInfoView)),
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand
            };

            carousel.SetBinding(CarouselLayout.ItemsSourceProperty, "SlotSessions");
            carousel.SetBinding(CarouselLayout.SelectedItemProperty, "SlotSession");

            return(carousel);
        }
Ejemplo n.º 7
0
        View CreateCurrentSessionsCarousel()
        {
            var carousel = new CarouselLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                ItemTemplate      = new DataTemplate(typeof(HomeCurrentSessionView))
            };

            carousel.SetBinding(CarouselLayout.ItemsSourceProperty, "CurrentSessions");
            carousel.SetBinding(CarouselLayout.SelectedItemProperty, "CurrentSession");

            return(carousel);
        }
Ejemplo n.º 8
0
        protected override void OnElementChanged(VisualElementChangedEventArgs e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                return;
            }

            _view             = (CarouselLayout)e.NewElement;
            _native           = (UIScrollView)NativeView;
            _native.Scrolled += NativeScrolled;

            e.NewElement.PropertyChanged += ElementPropertyChanged;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Called when ItemsLayout is changed
        /// </summary>
        protected override void OnItemsLayoutChanged(Layout <View> oldLayout, Layout <View> newLayout)
        {
            base.OnItemsLayoutChanged(oldLayout, newLayout);

            if (oldLayout != null && oldLayout is CarouselLayout)
            {
                CarouselLayout layout = oldLayout as CarouselLayout;
                layout.PanChanged -= OnPanChanged;
                layout.CurrentItemIndexChanged -= OnCurrentItemIndexChanged;
            }

            if (newLayout != null && newLayout is CarouselLayout)
            {
                m_layout = newLayout as CarouselLayout;
                InitializeLayout(m_layout);
            }
            else
            {
                m_layout = null;
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Set layout bindings and other default values
        /// </summary>
        private void InitializeLayout(CarouselLayout layout)
        {
            layout.HorizontalOptions        = LayoutOptions.Fill;
            layout.VerticalOptions          = LayoutOptions.Fill;
            layout.PanChanged              += OnPanChanged;
            layout.CurrentItemIndexChanged += OnCurrentItemIndexChanged;
            layout.ScrollEnded             += OnScrollEnded;
            layout.IsDebugEnabled           = IsDebugEnabled;

            Binding bind = new Binding(CarouselView.IsFlipEnabledProperty.PropertyName);

            bind.Source = this;
            layout.SetBinding(CarouselLayout.IsFlipEnabledProperty, bind);

            bind        = new Binding(CarouselView.IsPanEnabledProperty.PropertyName);
            bind.Source = this;
            layout.SetBinding(CarouselLayout.IsPanEnabledProperty, bind);

            bind        = new Binding(CarouselView.SnapPointsTypeProperty.PropertyName);
            bind.Source = this;
            layout.SetBinding(CarouselLayout.SnapPointsTypeProperty, bind);

            bind        = new Binding(CarouselView.CurrentItemIndexProperty.PropertyName);
            bind.Source = this;
            bind.Mode   = BindingMode.TwoWay;
            layout.SetBinding(CarouselLayout.CurrentItemIndexProperty, bind);

            bind        = new Binding(CarouselView.SnapPointsAlignmentProperty.PropertyName);
            bind.Source = this;
            bind.Mode   = BindingMode.TwoWay;
            layout.SetBinding(CarouselLayout.SnapPointsAlignmentProperty, bind);

            bind        = new Binding(CarouselView.ScrollEndedCommandProperty.PropertyName);
            bind.Source = this;
            bind.Mode   = BindingMode.TwoWay;
            layout.SetBinding(CarouselLayout.ScrollEndedCommandProperty, bind);
        }
Ejemplo n.º 11
0
        public CarouselView(CarouselLayout.IndicatorStyleEnum indicatorStyle, BaseViewModel viewModel, DataTemplate dataTemplate)
        {
            _indicatorStyle = indicatorStyle;
            _dataTemplate   = dataTemplate;
            BindingContext  = viewModel;

            relativeLayout = new RelativeLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand
            };

            CarouselLayout pagesCarousel = CreatePagesCarousel();
            StackLayout    dots          = CreatePagerIndicatorContainer();

            _tabs = CreateTabs();

            switch (pagesCarousel.IndicatorStyle)
            {
            case CarouselLayout.IndicatorStyleEnum.Dots:
                relativeLayout.Children.Add(pagesCarousel,
                                            Constraint.RelativeToParent((parent) => { return(parent.X); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Y); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Width); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Height); })
                                            );

                relativeLayout.Children.Add(dots,
                                            Constraint.Constant(0),
                                            Constraint.RelativeToView(pagesCarousel,
                                                                      (parent, sibling) => { return(sibling.Height - Constants.HeightCaruselIndicator); }),
                                            Constraint.RelativeToParent(parent => parent.Width),
                                            Constraint.Constant(Constants.HeightCaruselIndicator)
                                            );
                break;

            case CarouselLayout.IndicatorStyleEnum.Tabs:
                var tabsHeight = 50;
                relativeLayout.Children.Add(_tabs,
                                            Constraint.Constant(0),
                                            Constraint.RelativeToParent((parent) => { return(parent.Height - tabsHeight); }),
                                            Constraint.RelativeToParent(parent => parent.Width),
                                            Constraint.Constant(tabsHeight)
                                            );

                relativeLayout.Children.Add(pagesCarousel,
                                            Constraint.RelativeToParent((parent) => { return(parent.X); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Y); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Width); }),
                                            Constraint.RelativeToView(_tabs, (parent, sibling) => { return(parent.Height - (sibling.Height)); })
                                            );
                break;

            default:
                relativeLayout.Children.Add(pagesCarousel,
                                            Constraint.RelativeToParent((parent) => { return(parent.X); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Y); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Width); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Height); })
                                            );
                break;
            }

            Content = relativeLayout;
        }