Exemplo n.º 1
0
        public void Handle(UIView view, T viewModel)
        {
            _viewModel = viewModel;
            _lastContextMenuComponent = _contextMenuComponentFunc.Execute(viewModel);

            if (_lastContextMenuComponent == null)
            {
                return;
            }

            var menuController = UIMenuController.SharedMenuController;

            if (menuController.MenuVisible)
            {
                return;
            }

            _notification?.Dispose();
            _notification = UIMenuController.Notifications.ObserveWillHideMenu(menuController, HideNotificationHandler);

            Execute.BeginOnUIThread(() =>
            {
                if (!menuController.MenuVisible)
                {
                    var targetRect = CalculateMenuPosition(view);

                    menuController.MenuItems = _lastContextMenuComponent.BuildMenuItems();
                    menuController.Update();
                    menuController.SetTargetRect(targetRect, view);
                    menuController.SetMenuVisible(true, true);
                }
            });
        }
Exemplo n.º 2
0
        private void CleanUp(bool cleanAll = true)
        {
            _notification?.Dispose();
            _notification = null;

            if (cleanAll)
            {
                _lastContextMenuComponent = null;
                _viewModel = default(T);
            }
        }