コード例 #1
0
        public async Task <bool> ShowAsync()
        {
            var dialog = FragmentManager.FindFragmentByTag <ExtraPlatformDialog>(_guid.ToString());

            if (dialog != null)
            {
                return(false);
            }

            _dlgView.SetUp();

            OnceInitializeAction?.Invoke();

            var tcs = new TaskCompletionSource <bool>();

            async void cancel(object sender, EventArgs e)
            {
                _dlgView.RunDismissalAnimation();
                await Dismiss();

                tcs.SetResult(false);
            }

            async void complete(object sender, EventArgs e)
            {
                _dlgView.RunDismissalAnimation();
                await Dismiss();

                tcs.SetResult(true);
            }

            _dlgView.DialogNotifierInternal.Canceled  += cancel;
            _dlgView.DialogNotifierInternal.Completed += complete;


            var payload = new ExtraDialogPayload(_dlgView, _contentView);
            var bundle  = new Bundle();

            bundle.PutSerializable("extraDialogPayload", payload);
            _platformDialog           = new ExtraPlatformDialog();
            _platformDialog.Arguments = bundle;
            _platformDialog.Show(FragmentManager, _guid.ToString());

            try
            {
                return(await tcs.Task);
            }
            finally
            {
                _dlgView.DialogNotifierInternal.Canceled  -= cancel;
                _dlgView.DialogNotifierInternal.Completed -= complete;
                _dlgView.TearDown();
                payload.Dispose();
                bundle.Dispose();
            }
        }
コード例 #2
0
        public async Task <bool> ShowAsync()
        {
            _dlgView.SetUp();

            OnceInitializeAction?.Invoke();

            var tcs = new TaskCompletionSource <bool>();

            async void cancel(object sender, EventArgs e)
            {
                _dlgView.RunDismissalAnimation();
                await _viewController.DismissViewControllerAsync(true);

                tcs.SetResult(false);
            }

            async void complete(object sender, EventArgs e)
            {
                _dlgView.RunDismissalAnimation();
                await _viewController.DismissViewControllerAsync(true);

                tcs.SetResult(true);
            };

            _dlgView.DialogNotifierInternal.Canceled  += cancel;
            _dlgView.DialogNotifierInternal.Completed += complete;

            _dlgView.RunPresentationAnimation();
            await _viewController.PresentViewControllerAsync(_contentViewController, true);

            try
            {
                return(await tcs.Task);
            }
            finally
            {
                _dlgView.DialogNotifierInternal.Canceled  -= cancel;
                _dlgView.DialogNotifierInternal.Completed -= complete;
                _dlgView.TearDown();
            }
        }