public override void ViewDidLoad()
        {
            base.ViewDidLoad();
			_hud = new Hud(View);
			var vm = (RepositoriesExploreViewModel)ViewModel;
            var search = (UISearchBar)TableView.TableHeaderView;

			var set = this.CreateBindingSet<RepositoriesExploreView, RepositoriesExploreViewModel>();
			set.Bind(search).For(x => x.Text).To(x => x.SearchText);
			set.Apply();

			search.SearchButtonClicked += (sender, e) =>
			{
				search.ResignFirstResponder();
				vm.SearchCommand.Execute(null);
			};

			vm.Bind(x => x.IsSearching, x =>
			{
				if (x)
					_hud.Show("Searching...");
				else
					_hud.Hide();
			});

			BindCollection(vm.Repositories, repo =>
            {
				var description = vm.ShowRepositoryDescription ? repo.Description : string.Empty;
				var imageUrl = new Uri(repo.Logo);
					var sse = new RepositoryElement(repo.Name, repo.FollowersCount, repo.ForkCount, description, repo.Owner, imageUrl) { ShowOwner = true };
				sse.Tapped += () => vm.GoToRepositoryCommand.Execute(repo);
                return sse;
            });
        }
Пример #2
0
		public override void ViewDidLoad()
		{
			base.ViewDidLoad();

            var vm = (IssueVersionsViewModel)ViewModel;
            BindCollection(vm.Versions, x => {
				var e = new VersionElement(x);
				e.Tapped += () => {
                    if (vm.SelectedValue != null && string.Equals(vm.SelectedValue, x.Name))
                        vm.SelectedValue = null;
					else
                        vm.SelectedValue = x.Name;
				};
                if (vm.SelectedValue != null && string.Equals(vm.SelectedValue, x.Name))
					e.Accessory = UITableViewCellAccessory.Checkmark;
				return e;
			});

            vm.Bind(x => x.SelectedValue, x =>
				{
					if (Root.Count == 0)
						return;
					foreach (var m in Root[0].Elements.Cast<VersionElement>())
						m.Accessory = (x != null && string.Equals(m.Version.Name, x)) ? UITableViewCellAccessory.Checkmark : UITableViewCellAccessory.None;
					Root.Reload(Root[0], UITableViewRowAnimation.None);
				});

			var _hud = new Hud(View);
			vm.Bind(x => x.IsSaving, x =>
			{
				if (x) _hud.Show("Saving...");
				else _hud.Hide();
			});
		}
Пример #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

			var vm = (IssueMilestonesViewModel)ViewModel;
			BindCollection(vm.Milestones, x => {
				var e = new MilestoneElement(x);
				e.Tapped += () => {
					if (vm.SelectedMilestone != null && vm.SelectedMilestone.Number == x.Number)
						vm.SelectedMilestone = null;
					else
						vm.SelectedMilestone = x;
				};
				if (vm.SelectedMilestone != null && vm.SelectedMilestone.Number == x.Number)
					e.Accessory = UITableViewCellAccessory.Checkmark;
				return e;
			});

			vm.Bind(x => x.SelectedMilestone, x =>
			{
				if (Root.Count == 0)
					return;
				foreach (var m in Root[0].Elements.Cast<MilestoneElement>())
					m.Accessory = (x != null && m.Milestone.Number == x.Number) ? UITableViewCellAccessory.Checkmark : UITableViewCellAccessory.None;
				Root.Reload(Root[0], UITableViewRowAnimation.None);
			});

			var _hud = new Hud(View);
			vm.Bind(x => x.IsSaving, x =>
			{
				if (x) _hud.Show("Saving...");
				else _hud.Hide();
			});
        }
Пример #4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

			var vm = (IssueLabelsViewModel)ViewModel;
			NavigationItem.LeftBarButtonItem = new UIBarButtonItem(Theme.CurrentTheme.BackButton, UIBarButtonItemStyle.Plain, (s, e) => vm.SaveLabelChoices.Execute(null));

			BindCollection(vm.Labels, x => 
            {
                var e = new LabelElement(x.Name, x.Color);
                e.Tapped += () =>
                {
                    if (e.Accessory == UITableViewCellAccessory.Checkmark)
						vm.SelectedLabels.Items.Remove(x);
                    else
						vm.SelectedLabels.Items.Add(x);
                };

				e.Accessory = vm.SelectedLabels.Contains(x) ? 
				               UITableViewCellAccessory.Checkmark : 
				               UITableViewCellAccessory.None;
                return e;
            });

			vm.BindCollection(x => x.SelectedLabels, x =>
			{
				if (Root.Count == 0)
					return;

				var elements = Root[0].Elements;
				foreach (var el in elements.Cast<LabelElement>())
				{
                    var element = el;
                    el.Accessory = vm.SelectedLabels.Any(y => string.Equals(y.Name, element.Name, System.StringComparison.OrdinalIgnoreCase)) ? 
					               UITableViewCellAccessory.Checkmark : 
					               UITableViewCellAccessory.None;
				}

				Root.Reload(Root[0], UITableViewRowAnimation.None);
			}, true);

			var _hud = new Hud(View);
			vm.Bind(x => x.IsSaving, x =>
			{
				if (x) _hud.Show("Saving...");
				else _hud.Hide();
			});
        }
Пример #5
0
        public override void ViewDidLoad()
        {
            Title = "Assignees".t();
            NoItemsText = "No Assignees".t();

            base.ViewDidLoad();

			var vm = (IssueAssignedToViewModel)ViewModel;
			BindCollection(vm.Users, x =>
			{
				var el = new UserElement(x.Login, string.Empty, string.Empty, x.AvatarUrl);
				el.Tapped += () => {
					if (vm.SelectedUser != null && string.Equals(vm.SelectedUser.Login, x.Login))
						vm.SelectedUser = null;
					else
						vm.SelectedUser = x;
				};
				if (vm.SelectedUser != null && string.Equals(vm.SelectedUser.Login, x.Login, StringComparison.OrdinalIgnoreCase))
					el.Accessory = UITableViewCellAccessory.Checkmark;
				else
					el.Accessory = UITableViewCellAccessory.None;
				return el;
			});

			vm.Bind(x => x.SelectedUser, x =>
			{
				if (Root.Count == 0)
					return;
				foreach (var m in Root[0].Elements.Cast<UserElement>())
					m.Accessory = (x != null && string.Equals(vm.SelectedUser.Login, m.Caption, StringComparison.OrdinalIgnoreCase)) ? 
					          	   UITableViewCellAccessory.Checkmark : UITableViewCellAccessory.None;
				Root.Reload(Root[0], UITableViewRowAnimation.None);
			});

			var _hud = new Hud(View);
			vm.Bind(x => x.IsSaving, x =>
			{
				if (x) _hud.Show("Saving...");
				else _hud.Hide();
			});
        }
        public override void ViewDidLoad()
        {
            NavigationItem.LeftBarButtonItem = new UIBarButtonItem(Theme.CurrentTheme.BackButton, UIBarButtonItemStyle.Plain, (s, e) => NavigationController.PopViewControllerAnimated(true));

            base.ViewDidLoad();

            _hud = new Hud(View);

            var loadableViewModel = ViewModel as LoadableViewModel;
            if (loadableViewModel != null)
            {

                loadableViewModel.Bind(x => x.IsLoading, x =>
                {
                    if (x)
                    {
                        MonoTouch.Utilities.PushNetworkActive();
                        _hud.Show("Loading...");

                        if (ToolbarItems != null)
                        {
                            foreach (var t in ToolbarItems)
                                t.Enabled = false;
                        }
                    }
                    else
                    {
                        MonoTouch.Utilities.PopNetworkActive();
                        _hud.Hide();

                        if (ToolbarItems != null)
                        {
                            foreach (var t in ToolbarItems)
                                t.Enabled = true;
                        }
                    }
                });
            }
        }