FlowPerformTap() private method

private FlowPerformTap ( object item ) : void
item object
return void
        async Task ExecuteTapGestureRecognizer(View view)
        {
            var flowCell = view as IFlowViewCell;

            if (flowCell != null)
            {
                flowCell.OnTapped();
            }

            FlowListView flowListView = null;

            _flowListViewRef.TryGetTarget(out flowListView);

            if (flowListView != null)
            {
                int tapBackgroundEffectDelay = flowListView.FlowTappedBackgroundDelay;

                try
                {
                    if (tapBackgroundEffectDelay != 0)
                    {
                        view.BackgroundColor = flowListView.FlowTappedBackgroundColor;
                    }

                    flowListView.FlowPerformTap(view, view.BindingContext);
                }
                finally
                {
                    if (tapBackgroundEffectDelay != 0)
                    {
                        await Task.Delay(tapBackgroundEffectDelay);

                        view.BackgroundColor = flowListView.FlowRowBackgroundColor;
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Override this method to execute an action when the BindingContext changes.
        /// </summary>
        /// <remarks></remarks>
        protected override void OnBindingContextChanged()
        {
            rootLayout.BindingContext = BindingContext;
            base.OnBindingContextChanged();

            var container = BindingContext as IList;

            if (container == null)
            {
                return;
            }

            // Getting view types from templates
            var          containerCount = container.Count;
            IList <Type> columnTypes    = GetViewTypesFromTemplates(container);
            bool         layoutChanged  = RowLayoutChanged(containerCount, columnTypes);

            if (!layoutChanged)             // REUSE VIEWS
            {
                for (int i = 0; i < containerCount; i++)
                {
                    SetBindingContextForView(rootLayout.Children[i], container[i]);
                }
            }
            else             // RECREATE COLUMNS
            {
                if (rootLayout.Children.Count > 0)
                {
                    rootLayout.Children.Clear();
                }

                for (int i = 0; i < containerCount; i++)
                {
                    var view = (View)Activator.CreateInstance(columnTypes[i]);
                    view.BindingContext = container[i];
                    view.GestureRecognizers.Add(new TapGestureRecognizer()
                    {
                        Command = new Command(async(obj) => {
                            var flowCell = view as IFlowViewCell;
                            if (flowCell != null)
                            {
                                flowCell.OnTapped();
                            }

                            FlowListView flowListView = null;
                            flowListViewRef.TryGetTarget(out flowListView);

                            if (flowListView != null)
                            {
                                int tapBackgroundEffectDelay = flowListView.FlowTappedBackgroundDelay;

                                try
                                {
                                    if (tapBackgroundEffectDelay != 0)
                                    {
                                        view.BackgroundColor = flowListView.FlowTappedBackgroundColor;
                                    }

                                    flowListView.FlowPerformTap(view.BindingContext);
                                }
                                finally
                                {
                                    if (tapBackgroundEffectDelay != 0)
                                    {
                                        await Task.Delay(tapBackgroundEffectDelay);
                                        view.BackgroundColor = Color.Transparent;
                                    }
                                }
                            }
                        })
                    });

                    SetBindingContextForView(view, container[i]);
                    AddViewToLayout(view, containerCount, i);
                }
            }
        }