public void Add(string title, UIAlertActionStyle style, Action action)
 {
     var a = UIAlertAction.Create (title, style, (ac) => {
         if(action != null)
             action ();
     });
     AddAction (a);
 }
        protected virtual void AddActionSheetOption(ActionSheetOption opt, UIAlertController controller, UIAlertActionStyle style, IBitmap image = null)
        {
            var alertAction = UIAlertAction.Create(opt.Text, style, x => opt.Action?.Invoke());

            if (opt.ItemIcon == null && image != null)
                opt.ItemIcon = image;

            if (opt.ItemIcon != null)
                alertAction.SetValueForKey(opt.ItemIcon.ToNative(), new Foundation.NSString("image"));

            controller.AddAction(alertAction);
        }
Example #3
0
 protected virtual void AddActionSheetOption(ActionSheetOption opt, UIAlertController controller, UIAlertActionStyle style)
 {
     controller.AddAction(UIAlertAction.Create(opt.Text, style, x => opt.TryExecute()));
 }
Example #4
0
        protected virtual void AddActionSheetOption(ActionSheetOption opt, UIAlertController controller, UIAlertActionStyle style, string imageName)
        {
            var alertAction = UIAlertAction.Create(opt.Text, style, x => opt.Action?.Invoke());

            if (opt.ItemIcon == null && imageName != null)
            {
                opt.ItemIcon = imageName;
            }

            if (opt.ItemIcon != null)
            {
                var icon = UIImage.FromBundle(opt.ItemIcon);
                alertAction.SetValueForKey(icon, new NSString("image"));
            }
            controller.AddAction(alertAction);
        }
Example #5
0
        protected virtual void AddActionSheetOption(ActionSheetOption opt, UIAlertController controller, UIAlertActionStyle style, IBitmap image = null)
        {
            var alertAction = UIAlertAction.Create(opt.Text, style, x => opt.Action?.Invoke());

            if (opt.ItemIcon == null && image != null)
            {
                opt.ItemIcon = image;
            }

            if (opt.ItemIcon != null)
            {
                alertAction.SetValueForKey(opt.ItemIcon.ToNative(), new NSString("image"));
            }

            controller.AddAction(alertAction);
        }
Example #6
0
 private AlertAction(string text, UIAlertActionStyle style, Action action)
 {
     Text   = text;
     Style  = style;
     Action = action;
 }
Example #7
0
 protected virtual void AddActionSheetOption(ActionSheetOption opt, UIAlertController controller, UIAlertActionStyle style)
 {
     controller.AddAction(UIAlertAction.Create(opt.Text, style, x => opt.TryExecute()));
 }
Example #8
0
        public static void ShowChoiceDialog <T>(UIViewController viewController, string title, string message, string choice1,
                                                Action <T> choice1Action, string choice2, Action <T> choice2Action, T data, UIAlertActionStyle choice1Style = UIAlertActionStyle.Default)
        {
            var alertController = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert);

            alertController.AddAction(UIAlertAction.Create(choice1, choice1Style, (obj) =>
            {
                choice1Action?.Invoke(data);
            }));
            alertController.AddAction(UIAlertAction.Create(choice2, (choice2Action != null) ? UIAlertActionStyle.Default : UIAlertActionStyle.Cancel, (obj) =>
            {
                choice2Action?.Invoke(data);
            }));
            viewController.PresentViewController(alertController, true, null);
        }
Example #9
0
        public static void ShowDialog(UIViewController parent, DialogViewModel viewModel, Action <UIAlertAction> onOKTapped, UIAlertActionStyle OkBtnStyle = UIAlertActionStyle.Default, Action <UIAlertAction> OnCancelTapped = null)
        {
            parent.InvokeOnMainThread(() =>
            {
                UIAlertController controller = UIAlertController.Create(viewModel.Title, viewModel.Body, UIAlertControllerStyle.Alert);

                if (!String.IsNullOrWhiteSpace(viewModel.CancelbtnTxt))
                {
                    controller.AddAction(UIAlertAction.Create(viewModel.CancelbtnTxt, UIAlertActionStyle.Cancel, OnCancelTapped));
                }
                if (!String.IsNullOrWhiteSpace(viewModel.OkBtnTxt))
                {
                    controller.AddAction(UIAlertAction.Create(viewModel.OkBtnTxt, OkBtnStyle, onOKTapped));
                }

                parent.PresentViewController(controller, true, null);
            });
        }