public GistFileViewController( string gistId, string filename, Octokit.Gist gist = null, IApplicationService applicationService = null, IAlertDialogService alertDialogService = null, IMessageService messageService = null) : base(false) { _gistId = gistId; _filename = filename; _gist = gist; _applicationService = applicationService ?? Locator.Current.GetService <IApplicationService>(); _alertDialogService = alertDialogService ?? Locator.Current.GetService <IAlertDialogService>(); messageService = messageService ?? Locator.Current.GetService <IMessageService>(); Title = System.IO.Path.GetFileName(filename); var actionButton = new UIBarButtonItem(UIBarButtonSystemItem.Action) { Enabled = false }; NavigationItem.RightBarButtonItem = actionButton; var loadCommand = ReactiveCommand.CreateFromTask(Load); loadCommand .ThrownExceptions .Select(HandleLoadError) .SelectMany(Interactions.Errors.Handle) .Subscribe(); this.OnActivation(d => { d(this.WhenAnyValue(x => x.Gist) .Select(x => x != null) .Subscribe(x => actionButton.Enabled = x)); d(actionButton .GetClickedObservable() .Subscribe(CreateActionSheet)); d(loadCommand .IsExecuting .Subscribe(x => actionButton.Enabled = !x)); }); Appearing .Take(1) .Select(_ => Unit.Default) .InvokeReactiveCommand(loadCommand); }
public GistAddMessage(Octokit.Gist gist) { Gist = gist; }