コード例 #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var model = _filterController.Filter.Clone();

            //Load the root
            var root = new RootElement(Title) {
                new Section("Filter") {
                    (_filter = CreateEnumElement("Type", model.FilterType)),
                    (_open = new TrueFalseElement("Open?", model.Open)),
                    (_labels = new InputElement("Labels", "bug,ui,@user", model.Labels) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }),
                },
                new Section("Order By") {
                    (_sort = CreateEnumElement("Field", model.SortType)),
                    (_asc = new TrueFalseElement("Ascending", model.Ascending))
                },
                new Section() {
                    new StyledStringElement("Save as Default", () =>{
                        _filterController.ApplyFilter(CreateFilterModel(), true);
                        CloseViewController();
                    }, Images.Size) { Accessory = UITableViewCellAccessory.None },
                }
            };

            Root = root;
        }
コード例 #2
0
ファイル: SettingsView.cs プロジェクト: jrschumacher/CodeHub
		private void CreateTable()
		{
			var application = Mvx.Resolve<IApplicationService>();
			var vm = (SettingsViewModel)ViewModel;
			var currentAccount = application.Account;
            var accountSection = new Section("Account");

            accountSection.Add(new TrueFalseElement("Save Credentials".t(), !currentAccount.DontRemember, e =>
            { 
                currentAccount.DontRemember = !e.Value;
                application.Accounts.Update(currentAccount);
            }));

			var showOrganizationsInEvents = new TrueFalseElement("Show Organizations in Events".t(), currentAccount.ShowOrganizationsInEvents, e =>
			{ 
				currentAccount.ShowOrganizationsInEvents = e.Value;
				application.Accounts.Update(currentAccount);
			});

			var showOrganizations = new TrueFalseElement("List Organizations in Menu".t(), currentAccount.ExpandOrganizations, e =>
			{ 
				currentAccount.ExpandOrganizations = e.Value;
				application.Accounts.Update(currentAccount);
			});

			var repoDescriptions = new TrueFalseElement("Show Repo Descriptions".t(), currentAccount.ShowRepositoryDescriptionInList, e =>
			{ 
				currentAccount.ShowRepositoryDescriptionInList = e.Value;
				application.Accounts.Update(currentAccount);
			});

			var startupView = new StyledStringElement("Startup View", vm.DefaultStartupViewName, MonoTouch.UIKit.UITableViewCellStyle.Value1)
			{ 
				Accessory = MonoTouch.UIKit.UITableViewCellAccessory.DisclosureIndicator,
			};
			startupView.Tapped += () => vm.GoToDefaultStartupViewCommand.Execute(null);

            if (vm.PushNotificationsActivated)
                accountSection.Add(new TrueFalseElement("Push Notifications".t(), vm.PushNotificationsEnabled, e => vm.PushNotificationsEnabled = e.Value));

			var totalCacheSizeMB = vm.CacheSize.ToString("0.##");
			var deleteCache = new StyledStringElement("Delete Cache".t(), string.Format("{0} MB", totalCacheSizeMB), MonoTouch.UIKit.UITableViewCellStyle.Value1);
			deleteCache.Tapped += () =>
			{ 
				vm.DeleteAllCacheCommand.Execute(null);
				deleteCache.Value = string.Format("{0} MB", 0);
				ReloadData();
			};

			var usage = new TrueFalseElement("Send Anonymous Usage".t(), vm.AnalyticsEnabled, e => vm.AnalyticsEnabled = e.Value);

			//Assign the root
			var root = new RootElement(Title);
            root.Add(accountSection);
			root.Add(new Section("Appearance") { showOrganizationsInEvents, showOrganizations, repoDescriptions, startupView });
			root.Add(new Section ("Internal") { deleteCache, usage });
			Root = root;

		}
コード例 #3
0
ファイル: GistCreateView.cs プロジェクト: royalwang/CodeHub
        protected void UpdateView()
        {
            var root = new RootElement(Title) { UnevenRows = true };
            var section = new Section();
            root.Add(section);

            var desc = new MultilinedElement("Description") { Value = ViewModel.Description };
            desc.Tapped += ChangeDescription;
            section.Add(desc);

            var pub = new TrueFalseElement("Public", ViewModel.Public, (e) => ViewModel.Public = e.Value); 
            section.Add(pub);

            var fileSection = new Section();
            root.Add(fileSection);

            foreach (var file in ViewModel.Files.Keys)
            {
                var key = file;
                if (string.IsNullOrEmpty(ViewModel.Files[file]))
                    continue;

                var size = System.Text.Encoding.UTF8.GetByteCount(ViewModel.Files[file]);
                var el = new StyledStringElement(file, size + " bytes", UITableViewCellStyle.Subtitle) { Accessory = UITableViewCellAccessory.DisclosureIndicator };
                el.Tapped += () => {
                    if (!ViewModel.Files.ContainsKey(key))
                        return;
                    var createController = new ModifyGistFileController(key, ViewModel.Files[key]);
                    createController.Save = (name, content) => {

                        if (string.IsNullOrEmpty(name))
                            throw new InvalidOperationException("Please enter a name for the file");

                        //If different name & exists somewhere else
                        if (!name.Equals(key) && ViewModel.Files.ContainsKey(name))
                            throw new InvalidOperationException("A filename by that type already exists");

                        ViewModel.Files.Remove(key);
                        ViewModel.Files[name] = content;
                        ViewModel.Files = ViewModel.Files; // Trigger refresh
                    };

                    NavigationController.PushViewController(createController, true);
                };
                fileSection.Add(el);
            }

            fileSection.Add(new StyledStringElement("Add New File", AddFile));

            Root = root;
        }
コード例 #4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var model = _filterController.Filter.Clone();

            //Load the root
            var root = new RootElement(Title) {
                new Section("Filter") {
                    (_open = new TrueFalseElement("Open?", model.Open)),
                    (_labels = new InputElement("Labels", "bug,ui,@user", model.Labels) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }),
                    (_mentioned = new InputElement("Mentioned", "User", model.Mentioned) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }),
                    (_creator = new InputElement("Creator", "User", model.Creator) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }),
                    (_assignee = new InputElement("Assignee", "User", model.Assignee) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }),
                    (_milestone = new StyledStringElement("Milestone", "None", UITableViewCellStyle.Value1)),
                },
                new Section("Order By") {
                    (_sort = CreateEnumElement("Field", model.SortType)),
                    (_asc = new TrueFalseElement("Ascending", model.Ascending))
                },
                new Section(string.Empty, "Saving this filter as a default will save it only for this repository.") {
                    new StyledStringElement("Save as Default", () =>{
                        _filterController.ApplyFilter(CreateFilterModel(), true);
                        CloseViewController();
                    }, Images.Size) { Accessory = UITableViewCellAccessory.None },
                }
            };

            RefreshMilestone();

            _milestone.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            _milestone.Tapped += () => {
                var ctrl = new IssueMilestonesFilterViewController(_user, _repo, _milestoneHolder != null);

                ctrl.MilestoneSelected = (title, num, val) => {
                    if (title == null && num == null && val == null)
                        _milestoneHolder = null;
                    else
                        _milestoneHolder = new IssuesFilterModel.MilestoneKeyValue { Name = title, Value = val, IsMilestone = num.HasValue };
                    RefreshMilestone();
                    NavigationController.PopViewControllerAnimated(true);
                };
                NavigationController.PushViewController(ctrl, true);
            };

            Root = root;
        }
コード例 #5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var currentModel = _filterController.Filter.Clone();

            //Load the root
            var root = new RootElement(Title) {
                new Section("Order By") {
                    (_orderby = CreateEnumElement("Type", currentModel.OrderBy)),
                    (_ascendingElement = new TrueFalseElement("Ascending", currentModel.Ascending)),
                },
                new Section {
                    new StyledStringElement("Save as Default", () => {
                        _filterController.ApplyFilter(CreateFilterModel(), true);
                        CloseViewController();
                    }, Images.Size) { Accessory = UITableViewCellAccessory.None },
                }
            };

            Root = root;
        }
コード例 #6
0
ファイル: IssueEditView.cs プロジェクト: GirliOS/CodeHub
        public override void ViewDidLoad()
        {
            Title = "Edit Issue";

            base.ViewDidLoad();

            _hud = this.CreateHud();
            var vm = (IssueEditViewModel)ViewModel;

            NavigationItem.RightBarButtonItem = new UIBarButtonItem(Theme.CurrentTheme.SaveButton, UIBarButtonItemStyle.Plain, (s, e) => {
                View.EndEditing(true);
                vm.SaveCommand.Execute(null);
            });

            var title = new InputElement("Title", string.Empty, string.Empty);
            title.Changed += (object sender, EventArgs e) => vm.Title = title.Value;

            var assignedTo = new StyledStringElement("Responsible", "Unassigned", UITableViewCellStyle.Value1);
            assignedTo.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            assignedTo.Tapped += () => vm.GoToAssigneeCommand.Execute(null);

            var milestone = new StyledStringElement("Milestone".t(), "None", UITableViewCellStyle.Value1);
            milestone.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            milestone.Tapped += () => vm.GoToMilestonesCommand.Execute(null);

            var labels = new StyledStringElement("Labels".t(), "None", UITableViewCellStyle.Value1);
            labels.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            labels.Tapped += () => vm.GoToLabelsCommand.Execute(null);

            var content = new MultilinedElement("Description");
            content.Tapped += () =>
            {
                var composer = new Composer { Title = "Issue Description", Text = content.Value, ActionButtonText = "Save" };
                composer.NewComment(this, (text) => {
                    vm.Content = text;
                    composer.CloseComposer();
                });
            };

            var state = new TrueFalseElement("Open", true);
            state.ValueChanged += (sender, e) => vm.IsOpen = state.Value;

            vm.Bind(x => x.Title, x => title.Value = x, true);

            vm.Bind(x => x.Content, x => content.Value = x, true);

            vm.Bind(x => x.AssignedTo, x => {
                assignedTo.Value = x == null ? "Unassigned" : x.Login;
                if (assignedTo.GetImmediateRootElement() != null)
                    Root.Reload(assignedTo, UITableViewRowAnimation.None);
            }, true);

            vm.Bind(x => x.Milestone, x => {
                milestone.Value = x == null ? "None" : x.Title;
                if (assignedTo.GetImmediateRootElement() != null)
                    Root.Reload(milestone, UITableViewRowAnimation.None);
            }, true);

            vm.BindCollection(x => x.Labels, x => {
                labels.Value = vm.Labels.Items.Count == 0 ? "None" : string.Join(", ", vm.Labels.Items.Select(i => i.Name));
                if (assignedTo.GetImmediateRootElement() != null)
                    Root.Reload(labels, UITableViewRowAnimation.None);
            }, true);

            vm.Bind(x => x.IsOpen, x =>
            {
                state.Value = x;
                if (assignedTo.GetImmediateRootElement() != null)
                    Root.Reload(state, UITableViewRowAnimation.None);
            }, true);

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

            Root = new RootElement(Title) { new Section { title, assignedTo, milestone, labels }, new Section { state }, new Section { content } };
        }
コード例 #7
0
            public override void ViewDidLoad()
            {
                base.ViewDidLoad();

                //Load the root
                var root = new RootElement(Title) {
                    new Section("Order By") {
                        (_orderby = CreateEnumElement("Field", (int)_parent._filterModel.OrderBy, typeof(FilterModel.Order))),
                        (_ascendingElement = new TrueFalseElement("Ascending", _parent._filterModel.Ascending)),
                    },
                    new Section() {
                        new StyledElement("Save as Default", () => {
                            Application.Account.RepoFilterObject = CreateFilterModel();
                            this.DismissViewController(true, null);
                            this.ApplyFilter();
                        }, Images.Size) { Accessory = UITableViewCellAccessory.None },
                    }
                };

                Root = root;
            }