Exemplo n.º 1
0
		void Share (Service service, StringElement button)
		{
			Item item = new Item {
				Text = "I'm sharing great things using Xamarin!",
				Links = new List<Uri> {
					new Uri ("http://xamarin.com"),
				},
			};

			UIViewController vc = service.GetShareUI (item, shareResult => {
				dialog.DismissViewController (true, null);

				button.GetActiveCell().TextLabel.Text = service.Title + " shared: " + shareResult;
			});
			dialog.PresentViewController (vc, true, null);
		}
Exemplo n.º 2
0
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			var root = new RootElement ("Xamarin.Social Sample");

			var section = new Section ("Services");

			var facebookButton = new StringElement ("Share with Facebook");
			facebookButton.Tapped += delegate 
			{
				try
				{
					Share (Facebook, facebookButton); 
				}
				catch (Exception ex)
				{
					ShowMessage("Facebook: " + ex.Message);
				}
			};
			section.Add (facebookButton);

			var twitterButton = new StringElement ("Share with Twitter");
			twitterButton.Tapped += delegate 
			{ 
				try
				{
					Share (Twitter, twitterButton); 
				}
				catch (Exception ex)
				{
					ShowMessage("Twitter: " + ex.Message);
				}

			};
			section.Add (twitterButton);

			var twitter5Button = new StringElement ("Share with built-in Twitter");
			twitter5Button.Tapped += delegate 
			{
				try
				{
					Share (Twitter5, twitter5Button); 
				}
				catch (Exception ex)
				{
					ShowMessage("Twitter5: " +ex.Message);
				}
			};
			section.Add (twitter5Button);

			var flickr = new StringElement ("Share with Flickr");
			flickr.Tapped += () => {
				var picker = new MediaPicker(); // Set breakpoint here
				picker.PickPhotoAsync().ContinueWith (t =>
				{
					if (t.IsCanceled)
						return;

					var item = new Item ("I'm sharing great things using Xamarin!") {
						Images = new[] { new ImageData (t.Result.Path) }
					};

					Console.WriteLine ("Picked image {0}", t.Result.Path);

					UIViewController viewController = Flickr.GetShareUI (item, shareResult =>
					{
						dialog.DismissViewController (true, null);
						flickr.GetActiveCell().TextLabel.Text = "Flickr shared: " + shareResult;
					});

					dialog.PresentViewController (viewController, true, null);
				}, TaskScheduler.FromCurrentSynchronizationContext());
			};
			section.Add (flickr);
			root.Add (section);

			dialog = new DialogViewController (root);

			window = new UIWindow (UIScreen.MainScreen.Bounds);
			window.RootViewController = new UINavigationController (dialog);
			window.MakeKeyAndVisible ();
			
			return true;
		}