Exemple #1
0
        void OpenAccordion(AccordionEntry entry)
        {
            // Get the element (cell) touched
            var element = m_cellStackLayout.Children.FirstOrDefault(x => x == entry.Cell);

            if (element == null)
            {
                return;
            }
            double position = 0;

            entry.View.Animate("expand",
                               x =>
            {
                entry.View.IsVisible     = true;
                entry.View.HeightRequest = entry.OriginalSize.Height * x;

                // calculate te position to be scrolled based on the X from Animate and element Y position
                position = element.Y * x;
            }, 16, AnimationDuration, Easing.SpringOut, (d, b) =>
            {
                m_scrollView.ScrollToAsync(0, position, true);
                entry.View.IsVisible = true;
            });
        }
Exemple #2
0
 void CloseAccordion(AccordionEntry entry)
 {
     entry.View.Animate("colapse",
                        x =>
     {
         var change = entry.OriginalSize.Height * x;
         entry.View.HeightRequest = entry.OriginalSize.Height - change;
     }, 0, AnimationDuration, Easing.SpringIn, (d, b) =>
     {
         entry.View.IsVisible = false;
     });
 }
Exemple #3
0
        /// <summary>
        /// Add the specified cell and view.
        /// </summary>
        /// <param name="cell">cell.</param>
        /// <param name="view">View.</param>
        public void Add(View cell, View view)
        {
            if (cell == null)
            {
                throw new ArgumentNullException(nameof(cell));
            }

            if (view == null)
            {
                throw new ArgumentNullException(nameof(view));
            }

            var entry = new AccordionEntry()
            {
                Cell = cell,
                View = new ScrollView()
                {
                    Content = view
                },
                OriginalSize = new Size(view.WidthRequest, view.HeightRequest)
            };

            m_entries.Add(entry);

            m_cellStackLayout.Children.Add(entry.Cell);
            m_cellStackLayout.Children.Add(entry.View);

            var cellIndex = m_entries.Count - 1;

            var tapGestureRecognizer = new TapGestureRecognizer();

            if (CellTouched == null)
            {
                tapGestureRecognizer.Tapped += (object sender, EventArgs e) => OnCellTouchUpInside(cellIndex);
            }
            else
            {
                tapGestureRecognizer.Tapped += (object sender, EventArgs e) => CellTouched(cellIndex);
            }

            cell.GestureRecognizers.Add(tapGestureRecognizer);
        }
 void CloseAccordion(AccordionEntry entry)
 {
     entry.View.Animate("colapse",
         x =>
         {
             var change = entry.OriginalSize.Height * x;
             entry.View.HeightRequest = entry.OriginalSize.Height - change;
         }, 0, AnimationDuration, Easing.SpringIn, (d, b) =>
         {
             entry.View.IsVisible = false;
         });
 }
        void OpenAccordion(AccordionEntry entry)
        {
            // Get the element (cell) touched
            var element = m_cellStackLayout.Children.FirstOrDefault(x => x == entry.Cell);
            if (element == null)
                return;
            double position = 0;
            entry.View.Animate("expand",
                x =>
                {
                    entry.View.IsVisible = true;
                    entry.View.HeightRequest = entry.OriginalSize.Height * x;

                    // calculate te position to be scrolled based on the X from Animate and element Y position
                    position = element.Y * x;


                }, 16, AnimationDuration, Easing.SpringOut, (d, b) =>
                {
                    m_scrollView.ScrollToAsync(0, position, true);
                    entry.View.IsVisible = true;
                });
        }
        /// <summary>
        /// Add the specified cell and view.
        /// </summary>
        /// <param name="cell">cell.</param>
        /// <param name="view">View.</param>
        public void Add(View cell, View view)
        {
            if (cell == null)
                throw new ArgumentNullException(nameof(cell));

            if (view == null)
                throw new ArgumentNullException(nameof(view));

            var entry = new AccordionEntry()
            {
                Cell = cell,
                View = new ScrollView()
                {
                    Content = view
                },
                OriginalSize = new Size(view.WidthRequest, view.HeightRequest)
            };

            m_entries.Add(entry);

            m_cellStackLayout.Children.Add(entry.Cell);
            m_cellStackLayout.Children.Add(entry.View);

            var cellIndex = m_entries.Count - 1;

            var tapGestureRecognizer = new TapGestureRecognizer();

            if (CellTouched == null)
                tapGestureRecognizer.Tapped += (object sender, EventArgs e) => OnCellTouchUpInside(cellIndex);
            else
                tapGestureRecognizer.Tapped += (object sender, EventArgs e) => CellTouched(cellIndex);

            cell.GestureRecognizers.Add(tapGestureRecognizer);
        }