Exemplo n.º 1
0
        public UserGistsViewModel(ISessionService sessionService)
            : base(sessionService)
        {
            _sessionService = sessionService;
            Username        = _sessionService.Account.Username;

            GoToCreateGistCommand = ReactiveCommand.Create();
            GoToCreateGistCommand.Subscribe(_ =>
            {
                var vm = this.CreateViewModel <GistCreateViewModel>();
                vm.SaveCommand
                .Delay(TimeSpan.FromMilliseconds(200))
                .ObserveOn(RxApp.MainThreadScheduler)
                .Subscribe(x => InternalItems.Insert(0, x));
                NavigateTo(vm);
            });

            this.WhenAnyValue(x => x.Username).Subscribe(x =>
            {
                if (IsMine)
                {
                    Title = "My Gists";
                }
                else if (x == null)
                {
                    Title = "Gists";
                }
                else if (x.EndsWith("s", StringComparison.OrdinalIgnoreCase))
                {
                    Title = x + "' Gists";
                }
                else
                {
                    Title = x + "'s Gists";
                }
            });
        }