Пример #1
0
        private static StackLayout BuildHeaderLayout(AcNodeConfiguration configuration)
        {
            //Header layout
            StackLayout headerLayout = new StackLayout()
            {
                Margin = new Thickness(0, 0, 0, 0)
            };

            headerLayout.SetBinding(StackLayout.BackgroundColorProperty, "HeaderBackGroundColor");

            //Line one
            BoxView lineOne = new BoxView()
            {
                HeightRequest = 1, HorizontalOptions = LayoutOptions.FillAndExpand
            };

            lineOne.SetBinding(BoxView.ColorProperty, "LineColor");
            headerLayout.Children.Add(lineOne);

            headerLayout.Children.Add(BuildHeaderLabelsLayout(configuration));

            //Line two
            BoxView lineTwo = new BoxView()
            {
                HeightRequest = 1, HorizontalOptions = LayoutOptions.FillAndExpand
            };

            lineTwo.SetBinding(BoxView.ColorProperty, "LineColor");
            headerLayout.Children.Add(lineTwo);

            return(headerLayout);
        }
Пример #2
0
        public static StackLayout CreateNewNode(AcNodeConfiguration configuration, View contentView)
        {
            if (configuration.ExpandedContentHeight == 0)
            {
                configuration.ExpandedContentHeight = contentView.Height;
            }
            AccordionNodeViewModel accordionNodeView = new AccordionNodeViewModel(configuration.HeaderText,
                                                                                  (int)configuration.ExpandedContentHeight,
                                                                                  configuration.HeaderBackGroundColor,
                                                                                  configuration.HeaderTextColor,
                                                                                  configuration.LineColor,
                                                                                  configuration.iconExpandedText,
                                                                                  configuration.iconContractedText,
                                                                                  configuration.ExpandInitially);
            var result = new StackLayout()
            {
                BindingContext = accordionNodeView,
                Spacing        = 0,
                Margin         = new Thickness(0, 0, 0, 0)
            };

            result.Children.Add(BuildHeaderLayout(configuration));
            result.Children.Add(BuildContentLayout(contentView));

            return(result);
        }
Пример #3
0
        private static StackLayout BuildHeaderLabelsLayout(AcNodeConfiguration configuration)
        {
            StackLayout headerLabelsLayout = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Padding     = new Thickness(5, 10, 10, 10)
            };

            TapGestureRecognizer headerTapGestureRecognizer = new TapGestureRecognizer();

            headerTapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandProperty, "ExpandContractAccordion");
            headerLabelsLayout.GestureRecognizers.Add(headerTapGestureRecognizer);

            headerLabelsLayout.Children.Add(CreateLabel("HeaderText", "HeaderTextColor", configuration, null));
            headerLabelsLayout.Children.Add(CreateLabel("IconText", "HeaderTextColor", configuration, LayoutOptions.EndAndExpand));

            return(headerLabelsLayout);
        }
Пример #4
0
        private static Label CreateLabel(string textBinding, string textColorBinding, AcNodeConfiguration configuration,
                                         LayoutOptions?layoutOptions)
        {
            Label lbl = new Label();

            lbl.SetBinding(Label.TextProperty, textBinding);
            lbl.SetBinding(Label.TextColorProperty, textColorBinding);


            lbl.FontFamily = configuration.FontFamily;
            lbl.FontSize   = configuration.GetFontSize();

            if (configuration.HeaderFontAttributes.HasValue)
            {
                lbl.FontAttributes = configuration.HeaderFontAttributes.Value;
            }

            if (layoutOptions.HasValue)
            {
                lbl.HorizontalOptions = layoutOptions.Value;
            }

            return(lbl);
        }