示例#1
0
            public ModalContainer(Context context, Page modal) : base(context)
            {
                _modal = modal;

                _backgroundView = new global::Android.Views.View(context);
                _backgroundView.SetWindowBackground();
                AddView(_backgroundView);

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

                AddView(_renderer.View);

                Id = Platform.GenerateViewId();
            }
示例#2
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;
            }
        }
示例#3
0
            public ModalContainer(Context context, Page modal) : base(context)
            {
                _modal = modal;

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

                _renderer = CreateRenderer(modal, context);
                SetRenderer(modal, _renderer);

                AddView(_renderer.View);

                Id = Platform.GenerateViewId();

                _modal.PropertyChanged += OnModalPagePropertyChanged;
            }
示例#4
0
 public NavigationPageRenderer()
 {
     AutoPackage = false;
     Id          = Platform.GenerateViewId();
     Device.Info.PropertyChanged += DeviceInfoPropertyChanged;
 }
示例#5
0
        protected override void OnElementChanged(ElementChangedEventArgs <TabbedPage> e)
        {
            base.OnElementChanged(e);

            var activity = (FormsAppCompatActivity)Context;

            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(activity, 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)
                        {
                            tabs = _tabLayout = activity.LayoutInflater.Inflate(FormsAppCompatActivity.TabLayoutResource, null).JavaCast <TabLayout>();
                        }
                        else
                        {
                            tabs = _tabLayout = new TabLayout(activity)
                            {
                                TabMode = TabLayout.ModeFixed, TabGravity = TabLayout.GravityFill
                            }
                        };

                        FormsViewPager pager = _viewPager = CreateFormsViewPager(activity, 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();
                UpdateSwipePaging();
                UpdateOffscreenPageLimit();
            }
        }
示例#6
0
 public MasterDetailContainer(MasterDetailPage parent, bool isMaster, Context context) : base(parent, isMaster, context)
 {
     Id        = Platform.GenerateViewId();
     _parent   = parent;
     _isMaster = isMaster;
 }
        protected override void OnElementChanged(ElementChangedEventArgs <TabbedPage> e)
        {
            base.OnElementChanged(e);

            var activity = (FormsAppCompatActivity)Context;

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

            if (e.NewElement != null)
            {
                if (_tabLayout == null)
                {
                    TabLayout tabs;
                    if (FormsAppCompatActivity.TabLayoutResource > 0)
                    {
                        tabs = _tabLayout = activity.LayoutInflater.Inflate(FormsAppCompatActivity.TabLayoutResource, null).JavaCast <TabLayout>();
                    }
                    else
                    {
                        tabs = _tabLayout = new TabLayout(activity)
                        {
                            TabMode = TabLayout.ModeFixed, TabGravity = TabLayout.GravityFill
                        }
                    };
                    FormsViewPager pager =
                        _viewPager =
                            new FormsViewPager(activity)
                    {
                        OverScrollMode   = OverScrollMode.Never,
                        EnableGesture    = UseAnimations,
                        LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent),
                        Adapter          = new FormsFragmentPagerAdapter <Page>(e.NewElement, FragmentManager)
                        {
                            CountOverride = e.NewElement.Children.Count
                        }
                    };
                    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();
                }

                ((IPageController)tabbedPage).InternalChildren.CollectionChanged += OnChildrenCollectionChanged;
                UpdateBarBackgroundColor();
                UpdateBarTextColor();
                UpdateSwipePaging();
                UpdateOffscreenPageLimit();
            }
        }
 public FlyoutPageContainer(FlyoutPage parent, bool isFlyout, Context context) : base(context)
 {
     Id        = APlatform.GenerateViewId();
     _parent   = parent;
     _isFlyout = isFlyout;
 }