protected virtual IDisposable Present(Func<UIAlertController> alertControllerFactory) { UIAlertController alertController = null; InvokeOnMainThread(() => { alertController = alertControllerFactory(); var viewController = ViewControllerFactory(); if (viewController == null) { throw new InvalidOperationException("'ViewControllerFactory' must produce not null view controller"); } viewController.PresentViewController(alertController, true, null); }); return new DisposableAction(() => { try { InvokeOnMainThread(() => alertController.DismissViewController(true, null)); } catch (Exception exception) { Mvx.TaggedError(Tag, exception.ToString()); } }); }
public static bool CheckForPhotoPermissionGranted(UIViewController vc) { if (vc == null) { return(false); } if (PHPhotoLibrary.AuthorizationStatus == PHAuthorizationStatus.NotDetermined) { PHPhotoLibrary.RequestAuthorization((PHAuthorizationStatus obj) => { if (obj != PHAuthorizationStatus.Authorized) { CheckForPhotoPermissionGranted(vc); return; } }); } else if (PHPhotoLibrary.AuthorizationStatus != PHAuthorizationStatus.Authorized) { UIAlertController alertController = UIAlertController.Create(Strings.Basic.error, Strings.Permissions.photos_disabled, UIAlertControllerStyle.Alert); alertController.AddAction(UIAlertAction.Create(Strings.Basic.settings, UIAlertActionStyle.Default, delegate { UIApplication.SharedApplication.OpenUrl(NSUrl.FromString(UIApplication.OpenSettingsUrlString)); })); alertController.AddAction(UIAlertAction.Create(Strings.Basic.ok, UIAlertActionStyle.Cancel, delegate { alertController.DismissViewController(true, null); })); vc.PresentViewController(alertController, true, null); return(false); } return(true); }
// TODO Andrew, Alexander, please review this approach public async Task ConfirmAsync(string message, string title, string positiveButton, Action onPositive, string negativeButton, Action onNegative, bool hideOnClickOutside = false) { CancelAlertController(); Utilities.Dispatch(() => { _AlertController = UIAlertController.Create(title ?? string.Empty, message, UIAlertControllerStyle.Alert); _AlertController.AddAction(UIAlertAction.Create(positiveButton, UIAlertActionStyle.Default, (action) => { onPositive?.Invoke(); })); _AlertController.AddAction(UIAlertAction.Create(negativeButton, UIAlertActionStyle.Cancel, (action) => { onNegative?.Invoke(); })); if (hideOnClickOutside) { UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(_AlertController, true, () => { UITapGestureRecognizer recognizer = new UITapGestureRecognizer((tapRecognizer) => { _AlertController.DismissViewController(true, null); }); _AlertController.View.Superview.Subviews[0].AddGestureRecognizer(recognizer); }); } else { UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(_AlertController, true, null); } }); }
protected virtual IDisposable Present(UIAlertController alert) { var app = UIApplication.SharedApplication; app.InvokeOnMainThread(() => { var top = app.GetTopViewController(); if (alert.PreferredStyle == UIAlertControllerStyle.ActionSheet && UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { var x = top.View.Bounds.Width / 2; var y = top.View.Bounds.Bottom; var rect = new CGRect(x, y, 0, 0); alert.PopoverPresentationController.SourceView = top.View; alert.PopoverPresentationController.SourceRect = rect; alert.PopoverPresentationController.PermittedArrowDirections = UIPopoverArrowDirection.Unknown; } top.PresentViewController(alert, true, null); }); return(new DisposableAction(() => { try { app.InvokeOnMainThread(() => alert.DismissViewController(true, null)); } catch { } })); }
private void CreateFilterSheet(List <Category> categories) { alertController = UIAlertController.Create("Categorias", "", UIAlertControllerStyle.ActionSheet); alertController.View.UserInteractionEnabled = true; var height = NSLayoutConstraint.Create(alertController.View, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, 200); alertController.View.AddConstraint(height); categoriesPicker = new UIPickerView(new CGRect(0, 20, UIScreen.MainScreen.Bounds.Width - 20, 180)) { Model = new FilterCategoriesPickerModel(categories, FilterAndClose) }; alertController.View.AddSubview(categoriesPicker); categoriesPicker.Select(_selectedCategory, 0, true); PresentViewController(alertController, true, () => { UITapGestureRecognizer recognizer = new UITapGestureRecognizer((tapRecognizer) => { alertController.DismissViewController(true, null); }); alertController.View.Superview.Subviews[0].AddGestureRecognizer(recognizer); }); }
public void ShowMessageDialog(string title, string message, string okBtn, PlatformDialogServiceArguments platformArguments) { UIViewController presentViewController = null; UIAlertController dialogViewController = null; if (platformArguments.Context != null && platformArguments.Context is UIViewController viewController) { presentViewController = viewController; } else { AttempToLookForPresentViewController(out presentViewController, out dialogViewController); } DialogViewModel viewModel = new DialogViewModel() { Title = title, Body = message, OkBtnTxt = okBtn }; if (dialogViewController != null) { dialogViewController.DismissViewController(false, () => { DialogHelper.ShowDialog(presentViewController, viewModel, null); }); } else { DialogHelper.ShowDialog(presentViewController, viewModel, null); } }
private async Task Login(string login, string password, bool newUser) { //TODO: try to move it to Shared logic LoadingView.Hidden = false; View.BringSubviewToFront(LoadingView); LoadingView.StartAnimating(); var configurationProvider = ServiceLocator.Current.GetInstance <ISyncConfigurationsProvider>(); var result = await configurationProvider.DoLogin(login, password, newUser); if (result) { var syncingManager = ServiceLocator.Current.GetInstance <ISyncingManager>(); await syncingManager.Sync(); SyncCompleted(); } else { var popup = new UIAlertController { Title = "Some shit happened" }; popup.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Cancel, obj => { popup.DismissViewController(true, null); })); PresentViewController(popup, true, null); LoadingView.Hidden = true; LoadingView.StopAnimating(); } }
public void Hide() { _runOnUiThread(() => { _alert.DismissViewController(true, null); }); }
public void DismissPresentedAlert() { InvokeOnMainThread(() => { AlertController?.DismissViewController(true, null); }); }
void DismissMessage(UIAlertController alert, NSTimer alertDelay, Action complete) { alert?.DismissViewController(true, complete); alert?.Dispose(); alertDelay?.Dispose(); _lastAlertDelay = null; _lastAlert = null; }
// ==================================================================================================== // ==================================================================================================== #region MÉTODOS PRIVADOS // ==================================================================================================== private void mostrarToast(string message, double seconds) { temporizador = NSTimer.CreateScheduledTimer(seconds, (obj) => { dialogo?.DismissViewController(true, null); temporizador?.Dispose(); }); dialogo = UIAlertController.Create(null, message, UIAlertControllerStyle.Alert); UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(dialogo, true, null); }
public void ShowDialog(string text, string NegativeButton, string PositiveButton, Action positiveAction) { var bundle = Locator.Current.GetService <NSBundle>(); UIAlertController _error = UIAlertController.Create(null, bundle.GetLocalizedString(text), UIAlertControllerStyle.Alert); UIAlertAction alertAction = UIAlertAction.Create(bundle.GetLocalizedString(PositiveButton), UIAlertActionStyle.Default, (o) => { _error.DismissViewController(false, null); positiveAction?.Invoke(); }); UIAlertAction alertNegativeAction = UIAlertAction.Create(bundle.GetLocalizedString(NegativeButton), UIAlertActionStyle.Default, (o) => { _error.DismissViewController(false, null); }); _error.AddAction(alertAction); _error.AddAction(alertNegativeAction); PresentViewController(_error, false, null); }
void MesajReddet() { if (alert != null) { alert.DismissViewController(true, null); } if (alertDelay != null) { alertDelay.Dispose(); } }
public void DismissAlert() { if (alert != null) { alert.DismissViewController(true, null); } if (alertDelay != null) { alertDelay.Dispose(); } }
private void DismissMessage(UIAlertController alert, NSTimer alertDelay) { if (alert != null) { alert.DismissViewController(true, null); } if (alertDelay != null) { alertDelay.Dispose(); } }
void dismissMessage() { if (alert != null) { alert.DismissViewController(true, null); } if (alertDelay != null) { alertDelay.Dispose(); } }
private void DismissToast() { if (alert != null) { alert.DismissViewController(true, null); } if (alertDelay != null) { alertDelay.Dispose(); } }
void DismissMessage() { if (Alert != null) { Alert.DismissViewController(true, null); } if (Delay != null) { Delay.Dispose(); } }
public void HideLoading() { if (_progressAlert == null) { return; } _progressAlert.DismissViewController(true, () => { }); _progressAlert.Dispose(); _progressAlert = null; }
private void CancelAlertController() { if (_AlertController == null) { return; } _ToastTimer?.Invalidate(); _ToastTimer?.Dispose(); _ToastTimer = null; Utilities.Dispatch(() => _AlertController.DismissViewController(true, null)); }
public Task HideLoadingAsync() { var result = new TaskCompletionSource <int>(); if (_progressAlert == null) { result.TrySetResult(0); } _progressAlert.DismissViewController(false, () => result.TrySetResult(0)); _progressAlert.Dispose(); _progressAlert = null; return(result.Task); }
public void ShowDialogDefaultStyleButtons(string text, string NegativeButton, string PositiveButton, Action negativeAction, Action positiveAction) { UIAlertController _error = UIAlertController.Create(null, text, UIAlertControllerStyle.Alert); UIAlertAction alertAction = UIAlertAction.Create(PositiveButton, UIAlertActionStyle.Default, (o) => { _error.DismissViewController(false, null); positiveAction?.Invoke(); }); _error.AddAction(alertAction); UIAlertAction negAlertAction = UIAlertAction.Create(NegativeButton, UIAlertActionStyle.Default, (o) => { _error.DismissViewController(false, null); negativeAction?.Invoke(); }); _error.AddAction(negAlertAction); PresentViewController(_error, false, null); }
public void ConnectionStateDidChangeOfReader(CMBReaderDevice reader) { if (Element != null) { if (reader.ConnectionState == CMBConnectionState.Connected) { if (connectingAlert != null) { connectingAlert.DismissViewController(true, () => { connectingAlert = null; }); } Element.OnConnectionStateChanged(ScannerConnectionStatus.Connected); } else if (reader.ConnectionState == CMBConnectionState.Connecting) { Element.OnConnectionStateChanged(ScannerConnectionStatus.Connecting); } else if (reader.ConnectionState == CMBConnectionState.Disconnected) { if (connectingAlert != null) { connectingAlert.DismissViewController(true, () => { connectingAlert = null; }); } Element.OnConnectionStateChanged(ScannerConnectionStatus.Disconnected); } else if (reader.ConnectionState == CMBConnectionState.Disconnecting) { Element.OnConnectionStateChanged(ScannerConnectionStatus.Disconnecting); } } }
public void destroy() { UIApplication.SharedApplication.InvokeOnMainThread(() => { if (alert != null) { alert.DismissViewController(true, null); } if (alertDelay != null) { alertDelay.Dispose(); } }); }
public Task ShowAlert(string message) { UIAlertController alert = UIAlertController.Create(null, message, UIAlertControllerStyle.Alert); NSTimer alertDelay = NSTimer.CreateScheduledTimer(2, (obj) => { if (alert != null) { alert.DismissViewController(true, null); } }); UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(alert, true, null); return(Task.Run(() => "")); }
public void ShowDialogWithTextField(string text, string textFieldPlaceholder, bool isSecureField, string negativeButton, string positiveButton, Action <string> positiveAction) { var bundle = Locator.Current.GetService <NSBundle>(); UIAlertController alert = UIAlertController.Create(null, bundle.GetLocalizedString(text), UIAlertControllerStyle.Alert); UIAlertAction okAction = UIAlertAction.Create(bundle.GetLocalizedString(positiveButton), UIAlertActionStyle.Default, (o) => { alert.DismissViewController(false, null); positiveAction?.Invoke(alert.TextFields[0]?.Text); }); UIAlertAction cancelAction = UIAlertAction.Create(bundle.GetLocalizedString(negativeButton), UIAlertActionStyle.Cancel, (o) => { alert.DismissViewController(false, null); }); alert.AddAction(okAction); alert.AddAction(cancelAction); alert.AddTextField((textField) => { textField.Placeholder = textFieldPlaceholder; textField.SecureTextEntry = isSecureField; }); PresentViewController(alert, false, null); }
protected void ShowAlert(string message, string title, double seconds) { UIAlertController alert = null; var alertDelay = NSTimer.CreateScheduledTimer(seconds, obj => { try { alert?.DismissViewController(true, null); obj?.Dispose(); } catch { } }); alert = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert); UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(alert, true, null); }
public void ShowToast(string message) { alertDelay = NSTimer.CreateScheduledTimer(3, (obj) => { if (alert != null) { alert.DismissViewController(true, null); } if (alertDelay != null) { alertDelay.Dispose(); } }); alert = UIAlertController.Create(null, message, UIAlertControllerStyle.Alert); UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(alert, true, null); }
public void ShowDialog(string text, string buttonText, Action action) { InvokeOnMainThread(() => { var bundle = Locator.Current.GetService <NSBundle>(); UIAlertController _error = UIAlertController.Create(null, bundle.GetLocalizedString(text), UIAlertControllerStyle.Alert); UIAlertAction alertAction = UIAlertAction.Create(bundle.GetLocalizedString(buttonText), UIAlertActionStyle.Default, (o) => { _error.DismissViewController(false, null); action?.Invoke(); }); _error.AddAction(alertAction); PresentViewController(_error, false, null); }); }
public override void DidSignInForUser(GIDSignIn signIn, GIDGoogleUser user, NSError error) { if (error == null) { var message = string.Format("Successfully signed with {0}", user.Profile.Email); UIAlertController controller = UIAlertController.Create("Google SignIn", message, UIAlertControllerStyle.Alert); UIAlertAction okAction = UIAlertAction.Create("OK", UIAlertActionStyle.Default, (a) => { controller.DismissViewController(true, null); }); controller.AddAction(okAction); UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(controller, true, null); } else { Console.WriteLine(error.LocalizedDescription); } }