Ejemplo n.º 1
0
        protected override void OnElementChanged(ElementChangedEventArgs <CarouselPage> e)
        {
            base.OnElementChanged(e);

            var activity = (FormsAppCompatActivity)Context.GetActivity();

            if (e.OldElement != null)
            {
                ((IPageController)e.OldElement).InternalChildren.CollectionChanged -= OnChildrenCollectionChanged;
            }

            if (e.NewElement != null)
            {
                if (_viewPager != null)
                {
                    _viewPager.RemoveOnPageChangeListener(this);

                    ViewGroup.RemoveView(_viewPager);

                    _viewPager.Dispose();
                }

                FormsViewPager pager = _viewPager = new FormsViewPager(activity)
                {
                    OverScrollMode   = OverScrollMode.Never,
                    EnableGesture    = true,
                    LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent),
                    Adapter          = new FormsFragmentPagerAdapter <ContentPage>(e.NewElement, FragmentManager)
                    {
                        CountOverride = e.NewElement.Children.Count
                    }
                };
                pager.Id = Platform.GenerateViewId();
                pager.AddOnPageChangeListener(this);

                ViewGroup.AddView(pager);
                CarouselPage carouselPage = e.NewElement;
                if (carouselPage.CurrentPage != null)
                {
                    _previousPage = carouselPage.CurrentPage;
                    ScrollToCurrentPage();
                }

                ((IPageController)carouselPage).InternalChildren.CollectionChanged += OnChildrenCollectionChanged;
            }
        }
Ejemplo n.º 2
0
            public ModalContainer(Context context, Page modal) : base(context)
            {
                _modal = modal;

                _backgroundView = new AView(context);
                UpdateBackgroundColor();
                AddView(_backgroundView);

                _renderer = Android.Platform.CreateRenderer(modal, context);
                Android.Platform.SetRenderer(modal, _renderer);

                AddView(_renderer.View);

                Id = Platform.GenerateViewId();

                _modal.PropertyChanged += OnModalPagePropertyChanged;
            }
Ejemplo n.º 3
0
        protected override void OnElementChanged(ElementChangedEventArgs <TabbedPage> e)
        {
            base.OnElementChanged(e);

            var activity     = Context.GetActivity();
            var isDesigner   = Context.IsDesignerContext();
            var themeContext = isDesigner ? Context : activity;

            if (e.OldElement != null)
            {
                ((IPageController)e.OldElement).InternalChildren.CollectionChanged -= OnChildrenCollectionChanged;
            }

            if (e.NewElement != null)
            {
                if (IsBottomTabPlacement)
                {
                    if (_relativeLayout == null)
                    {
                        _relativeLayout = new AWidget.RelativeLayout(Context)
                        {
                            LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent),
                        };

                        if (_bottomNavigationView != null)
                        {
                            _relativeLayout.RemoveView(_bottomNavigationView);
                            _bottomNavigationView.SetOnNavigationItemSelectedListener(null);
                        }

                        var bottomNavigationViewLayoutParams = new AWidget.RelativeLayout.LayoutParams(
                            LayoutParams.MatchParent,
                            LayoutParams.WrapContent);

                        bottomNavigationViewLayoutParams.AddRule(AWidget.LayoutRules.AlignParentBottom);

                        _bottomNavigationView = new BottomNavigationView(Context)
                        {
                            LayoutParameters = bottomNavigationViewLayoutParams,
                            Id = Platform.GenerateViewId()
                        };

                        var viewPagerParams = new AWidget.RelativeLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
                        viewPagerParams.AddRule(AWidget.LayoutRules.Above, _bottomNavigationView.Id);

                        FormsViewPager pager = _viewPager = CreateFormsViewPager(themeContext, e.NewElement);

                        pager.Id = Platform.GenerateViewId();
                        pager.AddOnPageChangeListener(this);

                        _relativeLayout.AddView(pager, viewPagerParams);
                        _relativeLayout.AddView(_bottomNavigationView, bottomNavigationViewLayoutParams);

                        AddView(_relativeLayout);
                    }
                }
                else
                {
                    if (_tabLayout == null)
                    {
                        TabLayout tabs;

                        if (FormsAppCompatActivity.TabLayoutResource > 0 && !isDesigner)
                        {
                            tabs = _tabLayout = activity.LayoutInflater.Inflate(FormsAppCompatActivity.TabLayoutResource, null).JavaCast <TabLayout>();
                        }
                        else
                        {
                            tabs = _tabLayout = new TabLayout(themeContext)
                            {
                                TabMode = TabLayout.ModeFixed, TabGravity = TabLayout.GravityFill
                            }
                        };

                        FormsViewPager pager = _viewPager = CreateFormsViewPager(themeContext, e.NewElement);

                        pager.Id = Platform.GenerateViewId();
                        pager.AddOnPageChangeListener(this);

                        AddView(pager);
                        AddView(tabs);
                    }
                }

                OnChildrenCollectionChanged(null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));

                TabbedPage tabbedPage = e.NewElement;
                if (tabbedPage.CurrentPage != null)
                {
                    ScrollToCurrentPage();
                }

                _previousPage = tabbedPage.CurrentPage;

                ((IPageController)tabbedPage).InternalChildren.CollectionChanged += OnChildrenCollectionChanged;
                UpdateBarBackgroundColor();
                UpdateBarTextColor();
                UpdateItemIconColor();
                if (!isDesigner)
                {
                    UpdateSwipePaging();
                    UpdateOffscreenPageLimit();
                }
            }
        }
Ejemplo n.º 4
0
 public NavigationPageRenderer()
 {
     AutoPackage = false;
     Id          = Platform.GenerateViewId();
     Device.Info.PropertyChanged += DeviceInfoPropertyChanged;
 }
Ejemplo n.º 5
0
 public MasterDetailContainer(MasterDetailPage parent, bool isMaster, Context context) : base(parent, isMaster, context)
 {
     Id        = Platform.GenerateViewId();
     _parent   = parent;
     _isMaster = isMaster;
 }