public override void ViewDidLoad() { base.ViewDidLoad (); ModalPresentationStyle = UIModalPresentationStyle.FormSheet; // Perform any additional setup after loading the view, typically from a nib. eventDetailWebView.ShouldStartLoad = (webView, request, navType) => { if (navType == UIWebViewNavigationType.LinkClicked) { UIApplication.SharedApplication.OpenUrl (request.Url); return false; } return true; }; if (_thisEvent.Description.Length == 0) _thisEvent.Description = "There is no description for this event."; eventDetailWebView.LoadHtmlString (_thisEvent.Description, null); addToCalendarBtn.TouchUpInside += delegate { // get the permission first EventSingleton.Current.EventStore.RequestAccess ( EKEntityType.Event, (granted, e) => InvokeOnMainThread (() => { if (granted) { var calendarView = new AddToCalendar (this); string description = eventDetailWebView.EvaluateJavascript (@"document.documentElement.innerText"); _thisEvent.Description = description; calendarView.PresentView (_thisEvent); PresentViewController (calendarView, true, null); } else BTProgressHUD.ShowToast ("User Denied the Access to Calendar"); })); }; if (_thisEvent.RegistrationUrl != null) { registerButton.Hidden = false; registerButton.TouchUpInside += delegate { UIApplication.SharedApplication.OpenUrl (new NSUrl (_thisEvent.RegistrationUrl)); }; } shareButton.TouchUpInside += delegate { string title = EventTitle () + "Location: " + _thisEvent.Place + ". " + EventTimeSpan (); string timesSpan = EventTimeSpan (); SetUpShareActivityView (title, timesSpan, _thisEvent.RegistrationUrl); }; }
private UIActionSheet SetUpActionSheet() { var actionSheet = new UIActionSheet (); actionSheet.AddButton ("Add to Calendar"); actionSheet.AddButton ("Send Email"); actionSheet.AddButton ("Share to Twitter"); actionSheet.AddButton ("Share to Facebook"); actionSheet.AddButton ("Cancel"); actionSheet.CancelButtonIndex = 4; actionSheet.Clicked += delegate(object sender, UIButtonEventArgs e) { if (e.ButtonIndex == 0) { EventSingleton.Current.EventStore.RequestAccess ( EKEntityType.Event, (granted, exception) => InvokeOnMainThread (() => { if (granted) { var calendarView = new AddToCalendar (this); NavigationController.SetNavigationBarHidden (true, true); string description = eventContentWebView.EvaluateJavascript (@"document.documentElement.innerText"); _thisEvent.Description = description; calendarView.PresentView (_thisEvent); PresentViewController (calendarView, true, null); } else new UIAlertView ("Access Denied", "User Denied Access to Calendars/Reminders", null, "ok", null).Show (); })); } if (e.ButtonIndex == 1) { if (MFMailComposeViewController.CanSendMail) { var mailController = new MFMailComposeViewController (); mailController.SetSubject (_thisEvent.Title); mailController.SetMessageBody (_thisEvent.Description, true); mailController.Finished += (object s, MFComposeResultEventArgs args) => { if (args.Result == MFMailComposeResult.Failed) BTProgressHUD.ShowErrorWithStatus ("Sorry can't send the email right now."); else mailController.DismissViewController (true, null); }; PresentViewController (mailController, true, null); } else { BTProgressHUD.ShowErrorWithStatus ("Email function is not supported."); } } string eventFacebook = "Event: " + _thisEvent.Title + "." + "\n" + "Location: " + _thisEvent.Place + "." + "\n" + "Time: " + EventTimeSpan (); string eventTweet = TweetEventTitle () + "Location: " + _thisEvent.Place + ". " + EventTimeSpan (); if (e.ButtonIndex == 2) { SLComposeViewController twitterFeed = SLComposeViewController.FromService (SLServiceType.Twitter); twitterFeed.SetInitialText (eventTweet); if (_thisEvent.RegistrationUrl != null) twitterFeed.AddUrl (new NSUrl (_thisEvent.RegistrationUrl ?? "")); PresentViewController (twitterFeed, true, null); } if (e.ButtonIndex == 3) { SLComposeViewController facebookFeed = SLComposeViewController.FromService (SLServiceType.Facebook); facebookFeed.SetInitialText (eventFacebook); if (_thisEvent.RegistrationUrl != null) facebookFeed.AddUrl (new NSUrl (_thisEvent.RegistrationUrl)); PresentViewController (facebookFeed, true, null); } }; return actionSheet; }
public CalendarViewDelegate(AddToCalendar controller) { _parentController = controller; }