protected virtual void ShowDialogFragment( Type view, MvxDialogFragmentPresentationAttribute attribute, MvxViewModelRequest request) { var fragmentName = FragmentJavaName(attribute.ViewType); IMvxFragmentView mvxFragmentView = CreateFragment(attribute, fragmentName); var dialog = (DialogFragment)mvxFragmentView; // MvxNavigationService provides an already instantiated ViewModel here, // therefore just assign it if (request is MvxViewModelInstanceRequest instanceRequest) { mvxFragmentView.ViewModel = instanceRequest.ViewModelInstance; } else { mvxFragmentView.LoadViewModelFrom(request, null); } dialog.Cancelable = attribute.Cancelable; Dialogs.Add(mvxFragmentView.ViewModel, dialog); var ft = CurrentFragmentManager.BeginTransaction(); OnBeforeFragmentChanging(ft, attribute); if (attribute.AddToBackStack == true) { ft.AddToBackStack(fragmentName); } dialog.Show(ft, fragmentName); }
protected override void ShowDialogFragment(Type view, MvxDialogFragmentPresentationAttribute attribute, MvxViewModelRequest request) { var fragmentName = FragmentJavaName(attribute.ViewType); IMvxFragmentView mvxFragmentView = CreateFragment(attribute, fragmentName); var dialog = (DialogFragment)mvxFragmentView; // MvxNavigationService provides an already instantiated ViewModel here, // therefore just assign it if (request is MvxViewModelInstanceRequest instanceRequest) { mvxFragmentView.ViewModel = instanceRequest.ViewModelInstance; } else { mvxFragmentView.LoadViewModelFrom(request, null); } dialog.Cancelable = attribute.Cancelable; Dialogs.Add(mvxFragmentView.ViewModel, dialog); var ft = CurrentFragmentManager.BeginTransaction(); if (attribute.SharedElements != null) { foreach (var item in attribute.SharedElements) { string name = item.Key; if (string.IsNullOrEmpty(name)) { name = ViewCompat.GetTransitionName(item.Value); } ft.AddSharedElement(item.Value, name); } } if (!attribute.EnterAnimation.Equals(int.MinValue) && !attribute.ExitAnimation.Equals(int.MinValue)) { if (!attribute.PopEnterAnimation.Equals(int.MinValue) && !attribute.PopExitAnimation.Equals(int.MinValue)) { ft.SetCustomAnimations(attribute.EnterAnimation, attribute.ExitAnimation, attribute.PopEnterAnimation, attribute.PopExitAnimation); } else { ft.SetCustomAnimations(attribute.EnterAnimation, attribute.ExitAnimation); } } if (attribute.TransitionStyle != int.MinValue) { ft.SetTransitionStyle(attribute.TransitionStyle); } if (attribute.AddToBackStack == true) { ft.AddToBackStack(fragmentName); } dialog.Show(ft, fragmentName); }
protected virtual Task <bool> ShowDialogFragment( Type view, MvxDialogFragmentPresentationAttribute attribute, MvxViewModelRequest request) { ValidateArguments(view, attribute, request); if (CurrentActivity == null) { throw new InvalidOperationException("CurrentActivity is null"); } if (CurrentFragmentManager == null) { throw new InvalidOperationException("CurrentFragmentManager is null. Cannot create Fragment Transaction."); } if (attribute.ViewType == null) { throw new InvalidOperationException($"{nameof(MvxDialogFragmentPresentationAttribute)}.ViewType is null"); } var fragmentName = attribute.Tag ?? attribute.ViewType.FragmentJavaName(); IMvxFragmentView mvxFragmentView = CreateFragment(CurrentActivity.SupportFragmentManager, attribute, attribute.ViewType); var dialog = (DialogFragment)mvxFragmentView; // MvxNavigationService provides an already instantiated ViewModel here, // therefore just assign it if (request is MvxViewModelInstanceRequest instanceRequest) { mvxFragmentView.ViewModel = instanceRequest.ViewModelInstance; } else { mvxFragmentView.LoadViewModelFrom(request, null); } dialog.Cancelable = attribute.Cancelable; var ft = CurrentFragmentManager.BeginTransaction(); OnBeforeFragmentChanging(ft, dialog, attribute, request); if (attribute.AddToBackStack) { ft.AddToBackStack(fragmentName); } OnFragmentChanging(ft, dialog, attribute, request); dialog.Show(ft, fragmentName); OnFragmentChanged(ft, dialog, attribute, request); return(Task.FromResult(true)); }
protected override Task <bool> ShowDialogFragment(Type view, MvxDialogFragmentPresentationAttribute attribute, MvxViewModelRequest request) { var fragmentName = attribute.ViewType.FragmentJavaName(); var tag = attribute.Tag ?? fragmentName; IMvxFragmentView mvxFragmentView = CreateFragment(attribute, fragmentName); var dialog = mvxFragmentView as DialogFragment; if (dialog == null) { throw new MvxException("Fragment {0} does not extend {1}", fragmentName, typeof(DialogFragment).FullName); } // MvxNavigationService provides an already instantiated ViewModel here, // therefore just assign it if (request is MvxViewModelInstanceRequest instanceRequest) { mvxFragmentView.ViewModel = instanceRequest.ViewModelInstance; } else { mvxFragmentView.LoadViewModelFrom(request); } dialog.Cancelable = attribute.Cancelable; var ft = CurrentFragmentManager.BeginTransaction(); OnBeforeFragmentChanging(ft, dialog, attribute, request); if (attribute.AddToBackStack) { ft.AddToBackStack(fragmentName); } OnFragmentChanging(ft, dialog, attribute, request); dialog.Show(ft, tag); OnFragmentChanged(ft, dialog, attribute, request); return(Task.FromResult(true)); }
protected virtual async ValueTask<bool> ShowDialogFragment( Type view, MvxDialogFragmentPresentationAttribute? attribute, MvxViewModelRequest request) { var fragmentName = attribute?.ViewType?.FragmentJavaName(); IMvxFragmentView mvxFragmentView = CreateFragment(CurrentActivity.SupportFragmentManager, attribute, attribute.ViewType); var dialog = (DialogFragment)mvxFragmentView; // MvxNavigationService provides an already instantiated ViewModel here, // therefore just assign it if (request is MvxViewModelInstanceRequest instanceRequest) { mvxFragmentView.ViewModel = instanceRequest.ViewModelInstance; } else { await mvxFragmentView.LoadViewModelFrom(request, null).ConfigureAwait(false); } dialog.Cancelable = attribute.Cancelable; var ft = CurrentFragmentManager.BeginTransaction(); OnBeforeFragmentChanging(ft, dialog, attribute, request); if (attribute.AddToBackStack) ft.AddToBackStack(fragmentName); OnFragmentChanging(ft, dialog, attribute, request); dialog.Show(ft, fragmentName); OnFragmentChanged(ft, dialog, attribute, request); return true; }