Example #1
0
        public void CreateEmail(List <string> emailAddresses, List <string> ccs, string subject, string body, string htmlBody)
        {
            var vc = new MFMailComposeViewController();

            vc.MailComposeDelegate = this;

            if (emailAddresses?.Count > 0)
            {
                vc.SetToRecipients(emailAddresses.ToArray());
            }

            if (ccs?.Count > 0)
            {
                vc.SetCcRecipients(ccs.ToArray());
            }

            vc.SetSubject(subject);
            vc.SetMessageBody(htmlBody, true);
            vc.Finished += (sender, e) =>
            {
                vc.DismissModalViewController(true);
            };



            UIApplication.SharedApplication.Windows[0].
            RootViewController.PresentViewController(vc, true, null);
        }
        // Overridden from MFMailComposeViewControllerDelegate
        public override void Finished(MFMailComposeViewController controller, MFMailComposeResult result, NSError error)
        {
            // TODO [email protected]: These toasts don't work
            // the view controller is gone by the time they post. we will need to figure out
            // a better way to notify the user.
            switch (result)
            {
            case MFMailComposeResult.Sent:
                Toast.New(controller.View, Strings.Help.SENT_FEEDBACK);
                break;

            case MFMailComposeResult.Failed:
                Toast.New(controller.View, Strings.Errors.FAILED_TO_SEND_FEEDBACK);
                break;
            }

            controller.DismissModalViewController(true);
        }
Example #3
0
        public override void LoadView()
        {
            base.LoadView();
            View.BackgroundColor = UIColor.LightGray;

            var foo = ProgressHUD.Shared;

            MakeButton ("Using Mail controller view", () => {
                MFMailComposeViewController mailController;
                if (MFMailComposeViewController.CanSendMail)
                {
                    mailController = new MFMailComposeViewController();

                    mailController.SetSubject("New User.");

                    mailController.SetMessageBody("Please describe your issue: ", false);

                    mailController.Finished += (object s, MFComposeResultEventArgs args) =>
                    {
                        InvokeOnMainThread(() =>
                            {
                                mailController.DismissModalViewController(true);
                                switch (args.Result)
                                {
                                case MFMailComposeResult.Sent:
                                    //clsGlobal.ShowSimpleAlert(clsGlobal.strAppTitle, "Mail Sent Successfully");
                                    break;
                                case MFMailComposeResult.Cancelled:
                                    //clsGlobal.ShowSimpleAlert(clsGlobal.strAppTitle, "Mail Sending Cancelled");
                                    //Task.Delay(1000);
                                    BTProgressHUD.ShowToast("Ok Done", true, 3000);
                                    break;
                                }
                            });
                    };
                    this.PresentViewController(mailController, false, null);
                }

            });

            MakeButton("Run first - off main thread", () =>
            {
                //this must be the first one to run.
                // once BTProgressHUD.ANTYTHING has been called once on the UI thread,
                // it'll be setup. So this is an initial call OFF the main thread.
                // Should except in debug.
                var task = Task.Factory.StartNew(() =>
                {
                    try
                    {
                        BTProgressHUD.Show();
                        KillAfter();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                });
            });

            MakeButton("Show", () =>
            {
                BTProgressHUD.Show();
                KillAfter();
            });

            MakeButton("Cancel problem 3", () =>
                BTProgressHUD.Show("Cancel", () => KillAfter(), "Cancel and text")
            );

            MakeButton("Cancel problem 2", () =>
                BTProgressHUD.Show("Cancel", () => KillAfter())
            );

            MakeButton("Cancel problem", () =>
                BTProgressHUD.Show("Cancel", () => KillAfter(), "This is a multilinetext\nSome more text\n more text\n and again more text")
            );

            MakeButton("Show Message", () =>
            {
                BTProgressHUD.Show("Processing your image", -1, ProgressHUD.MaskType.Black);
                KillAfter();
            });

            MakeButton("Show Success", () =>
            {
                BTProgressHUD.ShowSuccessWithStatus("Great success!");
            });

            MakeButton("Show Fail", () =>
            {
                BTProgressHUD.ShowErrorWithStatus("Oh, thats bad");
            });

            MakeButton("Toast", () =>
            {
                BTProgressHUD.ShowToast("Hello from the toast", showToastCentered: false, timeoutMs: 1000);

            });

            MakeButton("Dismiss", () =>
            {
                BTProgressHUD.Dismiss();
            });

            MakeButton("Progress", () =>
            {
                progress = 0;
                BTProgressHUD.Show("Hello!", progress);
                if (timer != null)
                {
                    timer.Invalidate();
                }
                timer = NSTimer.CreateRepeatingTimer(0.5f, delegate
                {
                    progress += 0.1f;
                    if (progress > 1)
                    {
                        timer.Invalidate();
                        timer = null;
                        BTProgressHUD.Dismiss();
                    }
                    else
                    {
                        BTProgressHUD.Show("Hello!", progress);
                    }

                });
                NSRunLoop.Current.AddTimer(timer, NSRunLoopMode.Common);
            });

            MakeButton("Dismiss", () =>
            {
                BTProgressHUD.Dismiss();
            });
        }
 public override void Finished(MFMailComposeViewController controller, MFMailComposeResult result, NSError error)
 {
     _MV.DismissModalViewController(true);
 }