示例#1
0
        private void ApplyConfigToPicturePanel(SlidingPanelConfig config)
        {
            if (config.PictureImage != null)
            {
                _headerStackLayout                   = new StackLayout();
                _headerStackLayout.Orientation       = StackOrientation.Horizontal;
                _headerStackLayout.HorizontalOptions = LayoutOptions.FillAndExpand;
                _headerStackLayout.BackgroundColor   = config.HeaderBackgroundColor;

                TapGestureRecognizer headerTapGesture = new TapGestureRecognizer();
                headerTapGesture.Tapped += TapGesture_Tapped;
                _headerStackLayout.GestureRecognizers.Add(headerTapGesture);

                if (config.IsPanSupport == true)
                {
                    PanGestureRecognizer headerPanGesture = new PanGestureRecognizer();
                    headerPanGesture.PanUpdated += PanGesture_PanUpdated;
                    _headerStackLayout.GestureRecognizers.Add(headerPanGesture);
                }


                View topLeftButton = config.HeaderLeftButton;
                if (topLeftButton != null)
                {
                    _headerStackLayout.Children.Add(topLeftButton);
                }

                View topRightButton = config.HeaderRightButton;
                if (topRightButton != null)
                {
                    topRightButton.HorizontalOptions = LayoutOptions.EndAndExpand;
                    _headerStackLayout.Children.Add(topRightButton);
                }

                _pictureMainStackLayout                 = new StackLayout();
                _pictureMainStackLayout.Orientation     = StackOrientation.Vertical;
                _pictureMainStackLayout.BackgroundColor = config.PictureBackgroundColor;
                _pictureMainStackLayout.Children.Add(_headerStackLayout);

                _pictureImage = config.PictureImage;
                if (config.IsPanSupport == true)
                {
                    PanGestureRecognizer pictureImagePanGesture = new PanGestureRecognizer();
                    pictureImagePanGesture.PanUpdated += PanGesture_PanUpdated;
                    _pictureImage.GestureRecognizers.Add(pictureImagePanGesture);
                }
                _pictureMainStackLayout.Children.Add(_pictureImage);

                Rectangle layoutBound = new Rectangle(1, 1, 1, 1);
                _pictureAbsoluteLayout.Children.Add(_pictureMainStackLayout, layoutBound, AbsoluteLayoutFlags.All);
            }
        }
示例#2
0
        public void ApplyConfig(SlidingPanelConfig config)
        {
            _hideNavBarFeature = config.HideNavBar;

            AbsoluteLayout.SetLayoutBounds(_pictureAbsoluteLayout, new Rectangle(1, 0, 1, (1.1 - config.PanelRatio)));
            AbsoluteLayout.SetLayoutBounds(_slidingPanelAbsoluteLayout, new Rectangle(1, 1, 1, config.PanelRatio));

            _mainViewStackLayout.Children.Add(config.MainView);

            ApplyConfigToTitleBodyPanel(config);
            ApplyConfigToPicturePanel(config);

            if (config.IsExpandable == true)
            {
                InitGestures();
            }
        }
示例#3
0
        private void ApplyConfigToTitleBodyPanel(SlidingPanelConfig config)
        {
            _primaryFloatingActionButtonHeight = (config != null && config.PrimaryFloatingActionButton != null && config.PrimaryFloatingActionButton.HeightRequest > 0) ?
                                                 config.PrimaryFloatingActionButton.HeightRequest : DEFAULT_FAB_HEIGHT;

            _titleStackLayout = new StackLayout();
            _titleStackLayout.BackgroundColor   = config.TitleBackgroundColor;
            _titleStackLayout.Spacing           = 0;
            _titleStackLayout.HorizontalOptions = LayoutOptions.FillAndExpand;
            _titleStackLayout.VerticalOptions   = LayoutOptions.Fill;
            _titleRelativeLayout.Children.Add(_titleStackLayout,
                                              xConstraint: Constraint.Constant(0),
                                              yConstraint: Constraint.RelativeToParent((parent) =>
            {
                return(this._primaryFloatingActionButtonHeight / 2);
            }),
                                              widthConstraint: Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width);
            }),
                                              heightConstraint: Constraint.Constant(config.TitleHeightRequest + (this._primaryFloatingActionButtonHeight / 2)));
            _titleRelativeLayout.HeightRequest = config.TitleHeightRequest + (this._primaryFloatingActionButtonHeight / 2);

            if (config.IsPanSupport == true)
            {
                PanGestureRecognizer titlePanelPanGesture = new PanGestureRecognizer();
                titlePanelPanGesture.PanUpdated += PanGesture_PanUpdated;
                _titleStackLayout.GestureRecognizers.Add(titlePanelPanGesture);
            }

            // PrimaryFloatingActionButton section
            if (config.PrimaryFloatingActionButton != null)
            {
                _primaryFloatingActionButton = config.PrimaryFloatingActionButton;

                _titleRelativeLayout.Children.Add(_primaryFloatingActionButton,
                                                  xConstraint: Constraint.RelativeToParent((parent) =>
                {
                    return(parent.Width - (_primaryFloatingActionButton.WidthRequest * 1.5));
                }),
                                                  yConstraint: Constraint.Constant(0)
                                                  );
            }

            // SecondaryFloatingActionButton section
            if (config.SecondaryFloatingActionButton != null)
            {
                _secondaryFloatingActionButton = config.SecondaryFloatingActionButton;

                double marginTop = (config.PrimaryFloatingActionButton != null) ? config.PrimaryFloatingActionButton.HeightRequest : 0;

                _titleRelativeLayout.Children.Add(_secondaryFloatingActionButton,
                                                  xConstraint: Constraint.RelativeToParent((parent) =>
                {
                    return(parent.Width - (_secondaryFloatingActionButton.WidthRequest * 1.5));
                }),
                                                  yConstraint: Constraint.Constant(marginTop)
                                                  );
            }

            if (config.TitleView != null)
            {
                _titleStackLayout.Children.Add(config.TitleView);
            }

            if (config.IsPanSupport == true)
            {
                PanGestureRecognizer bodyPanelPanGesture = new PanGestureRecognizer();
                bodyPanelPanGesture.PanUpdated += PanGesture_PanUpdated;
                _bodyStackLayout.GestureRecognizers.Add(bodyPanelPanGesture);
            }
            _bodyStackLayout.BackgroundColor = config.BodyBackgroundColor;

            if (config.BodyView != null)
            {
                _bodyStackLayout.Children.Add(config.BodyView);
            }
        }
示例#4
0
 public SlidingUpPanel(SlidingPanelConfig config) : this()
 {
     ApplyConfig(config);
 }