示例#1
0
        public MainMasterDetailRenderer() : base(Forms.Context)
        {
            unchecked
            {
                SetScrimColor((int)_defaultScrimColor);
            }

            //main content view

            _detailLayout = new MasterDetailContainer(false, Context)
            {
                LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)
            };
            AddView(_detailLayout);

            //navigation drawer

            _masterLayout = new MasterDetailContainer(true, Context)
            {
                LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)
                {
                    Gravity = (int)GravityFlags.Start
                }
            };
            AddView(_masterLayout);

            //additional setup

            AddDrawerListener(this);
            Tracker = new VisualElementTracker(this);

            //events

            ViewTreeObserver.GlobalLayout += handleGlobalLayout;
        }
示例#2
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                ViewTreeObserver.GlobalLayout -= handleGlobalLayout;

                RemoveDrawerListener(this);

                if (Tracker != null)
                {
                    Tracker.Dispose();
                    Tracker = null;
                }

                if (_detailLayout != null)
                {
                    _detailLayout.Dispose();
                    _detailLayout = null;
                }

                if (_masterLayout != null)
                {
                    _masterLayout.Dispose();
                    _masterLayout = null;
                }

                cleanOldElement();
            }

            base.Dispose(disposing);
        }
		public void SetElement(VisualElement element)
		{
			MasterDetailPage oldElement = _page;
			_page = element as MasterDetailPage;

			_detailLayout = new MasterDetailContainer(_page, false, Context) { LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent) };

			_masterLayout = new MasterDetailContainer(_page, true, Context)
			{
				LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent) { Gravity = (int)GravityFlags.Start }
			};

			AddView(_detailLayout);

			AddView(_masterLayout);

			var activity = Context as Activity;
			activity.ActionBar.SetDisplayShowHomeEnabled(true);
			activity.ActionBar.SetHomeButtonEnabled(true);

			UpdateBackgroundColor(_page);
			UpdateBackgroundImage(_page);

			OnElementChanged(oldElement, element);

			if (oldElement != null)
				((IMasterDetailPageController)oldElement).BackButtonPressed -= OnBackButtonPressed;

			if (_page != null)
				MasterDetailPageController.BackButtonPressed += OnBackButtonPressed;

			if (Tracker == null)
				Tracker = new VisualElementTracker(this);

			_page.PropertyChanged += HandlePropertyChanged;
			_page.Appearing += MasterDetailPageAppearing;
			_page.Disappearing += MasterDetailPageDisappearing;

			UpdateMaster();
			UpdateDetail();

			Device.Info.PropertyChanged += DeviceInfoPropertyChanged;
			SetGestureState();

			Presented = _page.IsPresented;

			AddDrawerListener(this);

			if (element != null)
				element.SendViewInitialized(this);

			if (element != null && !string.IsNullOrEmpty(element.AutomationId))
				ContentDescription = element.AutomationId;
		}
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (Tracker != null)
                {
                    Tracker.Dispose();
                    Tracker = null;
                }

                if (_detailLayout != null)
                {
                    _detailLayout.Dispose();
                    _detailLayout = null;
                }

                if (_masterLayout != null)
                {
                    if (_masterLayout.ChildView != null)
                    {
                        _masterLayout.ChildView.PropertyChanged -= HandleMasterPropertyChanged;
                    }

                    _masterLayout.Dispose();
                    _masterLayout = null;
                }

                RemoveDrawerListener(this);

                Device.Info.PropertyChanged -= DeviceInfoPropertyChanged;

                if (_page != null)
                {
                    MasterDetailPageController.BackButtonPressed -= OnBackButtonPressed;
                    _page.PropertyChanged -= HandlePropertyChanged;
                    _page.Appearing       -= MasterDetailPageAppearing;
                    _page.Disappearing    -= MasterDetailPageDisappearing;
                    _page.ClearValue(Platform.RendererProperty);
                    _page = null;
                }
            }

            base.Dispose(disposing);
        }
示例#5
0
        public void SetElement(VisualElement element)
        {
            MasterDetailPage oldElement = _page;

            _page = element as MasterDetailPage;

            _detailLayout = new MasterDetailContainer(_page, false, Context)
            {
                LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)
            };

            _masterLayout = new MasterDetailContainer(_page, true, Context)
            {
                LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)
                {
                    Gravity = (int)GravityFlags.Start
                }
            };

            AddView(_detailLayout);

            AddView(_masterLayout);

            var activity = Context as Activity;

            activity.ActionBar.SetDisplayShowHomeEnabled(true);
            activity.ActionBar.SetHomeButtonEnabled(true);

            UpdateBackgroundColor(_page);
            UpdateBackgroundImage(_page);

            OnElementChanged(oldElement, element);

            if (oldElement != null)
            {
                ((IMasterDetailPageController)oldElement).BackButtonPressed -= OnBackButtonPressed;
            }

            if (_page != null)
            {
                MasterDetailPageController.BackButtonPressed += OnBackButtonPressed;
            }

            if (Tracker == null)
            {
                Tracker = new VisualElementTracker(this);
            }

            _page.PropertyChanged += HandlePropertyChanged;
            _page.Appearing       += MasterDetailPageAppearing;
            _page.Disappearing    += MasterDetailPageDisappearing;

            UpdateMaster();
            UpdateDetail();

            Device.Info.PropertyChanged += DeviceInfoPropertyChanged;
            SetGestureState();

            Presented = _page.IsPresented;

            AddDrawerListener(this);

            if (element != null)
            {
                element.SendViewInitialized(this);
            }

            if (element != null && !string.IsNullOrEmpty(element.AutomationId))
            {
                ContentDescription = element.AutomationId;
            }
        }
		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				if (Tracker != null)
				{
					Tracker.Dispose();
					Tracker = null;
				}

				if (_detailLayout != null)
				{
					_detailLayout.Dispose();
					_detailLayout = null;
				}

				if (_masterLayout != null)
				{
					_masterLayout.Dispose();
					_masterLayout = null;
				}

				Device.Info.PropertyChanged -= DeviceInfoPropertyChanged;

				if (_page != null)
				{
					MasterDetailPageController.BackButtonPressed -= OnBackButtonPressed;
					_page.PropertyChanged -= HandlePropertyChanged;
					_page.Appearing -= MasterDetailPageAppearing;
					_page.Disappearing -= MasterDetailPageDisappearing;
					_page.ClearValue(Platform.RendererProperty);
					_page = null;
				}
			}

			base.Dispose(disposing);
		}