private void ShareButtonPress(object o, EventArgs args) { var sheet = new UIActionSheet(); var shareButton = sheet.AddButton("Share"); var showButton = sheet.AddButton("Show in GitHub"); var cancelButton = sheet.AddButton("Cancel"); sheet.CancelButtonIndex = cancelButton; sheet.Dismissed += (sender, e) => { BeginInvokeOnMainThread(() => { if (e.ButtonIndex == showButton) { ViewModel.GoToGitHubCommand.Execute(null); } else if (e.ButtonIndex == shareButton) { AlertDialogService.Share( $"{ViewModel.RepositoryOwner}/{ViewModel.RepositoryName} Readme", CurrentContent, ViewModel.HtmlUrl, o as UIBarButtonItem); } }); sheet.Dispose(); }; sheet.ShowFrom(_actionButton, true); }
private void ShareButtonPress(UIBarButtonItem barButtonItem) { var sheet = new UIActionSheet(); var shareButton = sheet.AddButton("Share"); var showButton = sheet.AddButton("Show in GitHub"); var cancelButton = sheet.AddButton("Cancel"); sheet.CancelButtonIndex = cancelButton; sheet.Dismissed += (sender, e) => { BeginInvokeOnMainThread(() => { if (e.ButtonIndex == showButton) { var viewController = new WebBrowserViewController(Readme.HtmlUrl); PresentViewController(viewController, true, null); } else if (e.ButtonIndex == shareButton) { AlertDialogService.Share( $"{_owner}/{_repository} Readme", url: Readme.HtmlUrl, barButtonItem: barButtonItem); } }); sheet.Dispose(); }; sheet.ShowFrom(barButtonItem, true); }
void ShareButtonTap(object sender) { if (ViewModel.Gist == null) { return; } var app = Mvx.Resolve <IApplicationService>(); var isOwner = string.Equals(app.Account.Username, ViewModel.Gist?.Owner?.Login, StringComparison.OrdinalIgnoreCase); var gist = ViewModel.Gist; var sheet = new UIActionSheet(); var editButton = sheet.AddButton(isOwner ? "Edit" : "Fork"); var starButton = sheet.AddButton(ViewModel.IsStarred ? "Unstar" : "Star"); var shareButton = sheet.AddButton("Share"); var showButton = sheet.AddButton("Show in GitHub"); var cancelButton = sheet.AddButton("Cancel"); sheet.CancelButtonIndex = cancelButton; sheet.DismissWithClickedButtonIndex(cancelButton, true); sheet.Dismissed += (s, e) => { BeginInvokeOnMainThread(() => { try { if (e.ButtonIndex == shareButton) { AlertDialogService.Share( $"Gist {gist.Files?.Select(x => x.Key).FirstOrDefault() ?? gist.Id}", gist.Description, gist.HtmlUrl, sender as UIBarButtonItem); } else if (e.ButtonIndex == showButton) { ViewModel.GoToHtmlUrlCommand.Execute(null); } else if (e.ButtonIndex == starButton) { ViewModel.ToggleStarCommand.Execute(null); } else if (e.ButtonIndex == editButton) { Compose().ToBackground(); } } catch { } }); sheet.Dispose(); }; sheet.ShowFromToolbar(NavigationController.Toolbar); }
private void ShowExtraMenu(UIBarButtonItem item) { if (ViewModel.Issue == null) { return; } var issue = ViewModel.Issue; var sheet = new UIActionSheet(); var editButton = ViewModel.IsCollaborator ? sheet.AddButton("Edit") : -1; var openButton = ViewModel.IsCollaborator ? sheet.AddButton(ViewModel.Issue.State == "open" ? "Close" : "Open") : -1; var commentButton = sheet.AddButton("Comment"); var shareButton = sheet.AddButton("Share"); var showButton = sheet.AddButton("Show in GitHub"); var cancelButton = sheet.AddButton("Cancel"); sheet.CancelButtonIndex = cancelButton; sheet.Dismissed += (s, e) => { BeginInvokeOnMainThread(() => { if (e.ButtonIndex == editButton) { ViewModel.GoToEditCommand.Execute(null); } else if (e.ButtonIndex == openButton) { ViewModel.ToggleStateCommand.Execute(null); } else if (e.ButtonIndex == shareButton) { AlertDialogService.Share( Title, issue.Body, issue.HtmlUrl, NavigationItem.RightBarButtonItem); } else if (e.ButtonIndex == showButton) { ViewModel.GoToUrlCommand.Execute(ViewModel.Issue.HtmlUrl); } else if (e.ButtonIndex == commentButton) { AddCommentTapped(); } }); sheet.Dispose(); }; sheet.ShowFrom(item, true); }
private void ShowExtraMenu() { var repoModel = ViewModel.Repository; if (repoModel == null || ViewModel.IsStarred == null || ViewModel.IsWatched == null) { return; } var sheet = new UIActionSheet(); var pinButton = sheet.AddButton(ViewModel.IsPinned ? "Unpin from Slideout Menu" : "Pin to Slideout Menu"); var starButton = sheet.AddButton(ViewModel.IsStarred.Value ? "Unstar This Repo" : "Star This Repo"); var watchButton = sheet.AddButton(ViewModel.IsWatched.Value ? "Unwatch This Repo" : "Watch This Repo"); var showButton = ViewModel?.Repository?.HtmlUrl != null?sheet.AddButton("Show in GitHub") : -1; var shareButton = sheet.AddButton("Share"); var cancelButton = sheet.AddButton("Cancel"); sheet.CancelButtonIndex = cancelButton; sheet.Dismissed += (s, e) => { // Pin to menu if (e.ButtonIndex == pinButton) { ViewModel.PinCommand.Execute(null); } else if (e.ButtonIndex == starButton) { ViewModel.ToggleStarCommand.Execute(null); } else if (e.ButtonIndex == watchButton) { ViewModel.ToggleWatchCommand.Execute(null); } else if (e.ButtonIndex == showButton) { ViewModel.GoToHtmlUrlCommand.Execute(null); } else if (e.ButtonIndex == shareButton) { AlertDialogService.Share( repoModel.FullName, repoModel.Description, repoModel.HtmlUrl, NavigationItem.RightBarButtonItem); } sheet.Dispose(); }; sheet.ShowFrom(NavigationItem.RightBarButtonItem, true); }
private void Share(UIBarButtonItem barButtonItem) { var url = Content?.HtmlUrl; if (url == null) { return; } AlertDialogService.Share( Title, url: Content?.HtmlUrl, barButtonItem: barButtonItem); }
private void ShowExtraMenu() { if (ViewModel.PullRequest == null) return; var pullRequest = ViewModel.PullRequest; var sheet = new UIActionSheet(); var editButton = ViewModel.GoToEditCommand.CanExecute(null) ? sheet.AddButton("Edit") : -1; var openButton = ViewModel.IsCollaborator ? sheet.AddButton(ViewModel.PullRequest.State == "open" ? "Close" : "Open") : -1; var commentButton = sheet.AddButton("Comment"); var shareButton = !string.IsNullOrEmpty(ViewModel.PullRequest?.HtmlUrl) ? sheet.AddButton("Share") : -1; var showButton = sheet.AddButton("Show in GitHub"); var cancelButton = sheet.AddButton("Cancel"); sheet.CancelButtonIndex = cancelButton; sheet.Dismissed += (s, e) => { BeginInvokeOnMainThread(() => { if (e.ButtonIndex == editButton) ViewModel.GoToEditCommand.Execute(null); else if (e.ButtonIndex == openButton) ViewModel.ToggleStateCommand.Execute(null); else if (e.ButtonIndex == shareButton) { AlertDialogService.Share( Title, pullRequest.Body, pullRequest.HtmlUrl, NavigationItem.RightBarButtonItem); } else if (e.ButtonIndex == showButton) ViewModel.GoToUrlCommand.Execute(ViewModel.PullRequest.HtmlUrl); else if (e.ButtonIndex == commentButton) AddCommentTapped(); }); sheet.Dispose(); }; sheet.ShowInView(View); }
private void ShowExtraMenu(object o, EventArgs arg) { var sheet = CreateActionSheet(Title); var vm = ViewModel; var openButton = !string.IsNullOrEmpty(ViewModel.FilePath) ? sheet.AddButton("Open In") : -1; var shareButton = !string.IsNullOrEmpty(ViewModel.HtmlUrl) ? sheet.AddButton("Share") : -1; var showButton = ViewModel.GoToHtmlUrlCommand.CanExecute(null) ? sheet.AddButton("Show in GitHub") : -1; var cancelButton = sheet.AddButton("Cancel"); sheet.CancelButtonIndex = cancelButton; sheet.Dismissed += (s, e) => BeginInvokeOnMainThread(() => { try { if (e.ButtonIndex == openButton) { var ctrl = new UIDocumentInteractionController(); ctrl.Url = NSUrl.FromFilename(ViewModel.FilePath); ctrl.PresentOpenInMenu(NavigationItem.RightBarButtonItem, true); } else if (e.ButtonIndex == shareButton) { AlertDialogService.Share( ViewModel.Title, url: ViewModel?.HtmlUrl, barButtonItem: o as UIBarButtonItem); } else if (e.ButtonIndex == showButton) { vm.GoToHtmlUrlCommand.Execute(null); } } catch { } }); sheet.ShowFrom(NavigationItem.RightBarButtonItem, true); }