Exemplo n.º 1
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            if (ToolbarItems != null)
            {
                NavigationController.SetToolbarHidden(false, animated);
            }

            //Before we select which one, make sure we detach the event handler or silly things will happen
            _viewSegment.ValueChanged -= SegmentValueChanged;

            var application = Mvx.Resolve <IApplicationService>();

            //Select which one is currently selected
            if (ViewModel.Issues.Filter.Equals(IssuesFilterModel.CreateAllFilter()))
            {
                _viewSegment.SelectedSegment = 0;
            }
            else if (ViewModel.Issues.Filter.Equals(IssuesFilterModel.CreateOpenFilter()))
            {
                _viewSegment.SelectedSegment = 1;
            }
            else if (ViewModel.Issues.Filter.Equals(IssuesFilterModel.CreateMineFilter(application.Account.Username)))
            {
                _viewSegment.SelectedSegment = 2;
            }
            else
            {
                _viewSegment.SelectedSegment = 3;
            }

            _viewSegment.ValueChanged += SegmentValueChanged;
        }
Exemplo n.º 2
0
        public IssuesViewModel(
            string username, string repository,
            IApplicationService applicationService = null,
            IMessageService messageService         = null)
        {
            Username           = username;
            Repository         = repository;
            applicationService = applicationService ?? Locator.Current.GetService <IApplicationService>();
            messageService     = messageService ?? Locator.Current.GetService <IMessageService>();
            var currentUser = applicationService.Account.Username;

            GoToNewIssueCommand
            .Select(_ => new IssueAddViewModel(username, repository))
            .Subscribe(NavigateTo);

            Title = "Issues";

            this.WhenAnyValue(x => x.SelectedFilter)
            .Subscribe(x =>
            {
                if (x == 0)
                {
                    Filter = IssuesFilterModel.CreateOpenFilter();
                }
                else if (x == 1)
                {
                    Filter = IssuesFilterModel.CreateMineFilter(currentUser);
                }
                else if (x == 2)
                {
                    Filter = IssuesFilterModel.CreateAllFilter();
                }
            });

            this.WhenAnyValue(x => x.Filter)
            .Select(x => new IssueListViewModel(username, repository, x))
            .Do(x => x.LoadMoreCommand.ExecuteNow())
            .Subscribe(x => Issues = x);

            this.WhenAnyValue(x => x.Issues)
            .Select(x => x.IssueSelected)
            .Switch()
            .Select(x => new IssueViewModel(username, repository, x))
            .Subscribe(NavigateTo);
        }
Exemplo n.º 3
0
        void SegmentValueChanged(object sender, EventArgs e)
        {
            var application = Mvx.Resolve <IApplicationService>();

            if (_viewSegment.SelectedSegment == 0)
            {
                ViewModel.Issues.ApplyFilter(IssuesFilterModel.CreateAllFilter(), true);
            }
            else if (_viewSegment.SelectedSegment == 1)
            {
                ViewModel.Issues.ApplyFilter(IssuesFilterModel.CreateOpenFilter(), true);
            }
            else if (_viewSegment.SelectedSegment == 2)
            {
                ViewModel.Issues.ApplyFilter(IssuesFilterModel.CreateMineFilter(application.Account.Username), true);
            }
            else if (_viewSegment.SelectedSegment == 3)
            {
                ViewModel.GoToFiltersCommand.Execute(null);
            }
        }