コード例 #1
0
        private void Render(DialogTableViewSource tableViewSource)
        {
            var section = new Section();

            section.Add(_items.Select(CreateElement));
            tableViewSource.Root.Reset(section);
        }
コード例 #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var section = new Section();
            var source  = new DialogTableViewSource(TableView);

            TableView.Source          = source;
            TableView.TableFooterView = new UIView();

            source.Root.Add(new Section {
                _titleElement
            }, section, new Section {
                _descriptionElement
            });

            this.WhenAnyValue(x => x.ViewModel.IsCollaborator)
            .Where(x => x.HasValue && x.Value)
            .Where(_ => _milestoneElement.Section == null)
            .Subscribe(x => section.Add(new [] { _assigneeElement, _milestoneElement, _labelsElement }));

            this.WhenAnyValue(x => x.ViewModel.IsCollaborator)
            .Where(x => !x.HasValue || !x.Value)
            .Subscribe(x => section.Clear());
        }
コード例 #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var source = new DialogTableViewSource(TableView);

            TableView.Source = source;

            NavigationItem.RightBarButtonItem = new UIBarButtonItem(Images.SaveButton, UIBarButtonItemStyle.Plain, (s, e) => {
                View.EndEditing(true);
                ViewModel.SaveCommand.ExecuteIfCan();
            });
            NavigationItem.RightBarButtonItem.EnableIfExecutable(ViewModel.SaveCommand.CanExecuteObservable);

            var title = new InputElement("Title", string.Empty, string.Empty);

            title.Changed += (sender, e) => ViewModel.Subject = title.Value;

            var content = new MultilinedElement("Description");

            content.Tapped += () => ViewModel.GoToDescriptionCommand.ExecuteIfCan();

            ViewModel.WhenAnyValue(x => x.Issue.Title).Subscribe(x => title.Value = x);
            ViewModel.WhenAnyValue(x => x.Content).Subscribe(x => content.Value   = x);

            source.Root.Reset(new Section {
                title
            }, new Section {
                content
            });
        }
コード例 #4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.WhenAnyValue(x => x.ViewModel.SaveCommand)
            .Subscribe(x => {
                NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Save, (s, e) => {
                    ResignFirstResponder();
                    x.ExecuteIfCan();
                });
                NavigationItem.RightBarButtonItem.EnableIfExecutable(x);
            });

            var titleElement = new DummyInputElement("Title");

            this.WhenAnyValue(x => x.ViewModel.Filename).Subscribe(x => titleElement.Value = x);
            titleElement.Changed += (sender, e) => ViewModel.Filename = titleElement.Value;

            var descriptionElement = new ExpandingInputElement("Description");

            this.WhenAnyValue(x => x.ViewModel.Description).Subscribe(x => descriptionElement.Value = x);
            descriptionElement.ValueChanged += (sender, e) => ViewModel.Description = descriptionElement.Value;

            var source = new DialogTableViewSource(TableView);

            source.Root.Add(new Section {
                titleElement, descriptionElement
            });
            TableView.Source          = source;
            TableView.TableFooterView = new UIView();
        }
コード例 #5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _dialogSource = CreateTableViewSource();

            _dialogSource.ScrolledObservable.Where(x => x.Y > 0)
            .Where(_ => NavigationController != null)
            .Subscribe(_ => NavigationController.NavigationBar.ShadowImage = null);
            _dialogSource.ScrolledObservable.Where(x => x.Y <= 0)
            .Where(_ => NavigationController != null)
            .Where(_ => NavigationController.NavigationBar.ShadowImage == null)
            .Subscribe(_ => NavigationController.NavigationBar.ShadowImage = new UIImage());
            _dialogSource.ScrolledObservable.Where(_ => SlideUpTitle != null).Subscribe(x => SlideUpTitle.Offset = 108 + 28f - x.Y);

            TableView.TableHeaderView     = HeaderView;
            TableView.SectionHeaderHeight = 0;
            TableView.Source = _dialogSource;

            var frame = TableView.Bounds;

            frame.Y = -frame.Size.Height;
            var view = new UIView(frame);

            view.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            view.BackgroundColor  = Theme.PrimaryNavigationBarColor;
            view.Layer.ZPosition  = -1f;
            TableView.InsertSubview(view, 0);
        }
コード例 #6
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _dialogSource = CreateTableViewSource();

            TableView.SectionHeaderHeight = 0;
            TableView.Source = _dialogSource;

            var frame = TableView.Bounds;

            frame.Y = -frame.Size.Height;
            _backgroundHeaderView.Frame            = frame;
            _backgroundHeaderView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            _backgroundHeaderView.Layer.ZPosition  = -1f;
            TableView.InsertSubview(_backgroundHeaderView, 0);

            var scrollingObservable = _dialogSource.ScrolledObservable.Select(x => x.Y).StartWith(TableView.ContentOffset.Y);
            var shadowObs           = scrollingObservable.Where(x => x > 0 && NavigationController != null);
            var shadowImgObs        = scrollingObservable.Where(x => x <= 0).Where(_ => NavigationController != null)
                                      .Where(_ => NavigationController.NavigationBar.ShadowImage == null);
            var slideObs = scrollingObservable.Where(_ => SlideUpTitle != null);

            OnActivation(d => {
                d(shadowObs.Subscribe(_ => NavigationController.NavigationBar.ShadowImage    = null));
                d(shadowImgObs.Subscribe(_ => NavigationController.NavigationBar.ShadowImage = new UIImage()));
                d(slideObs.Subscribe(x => SlideUpTitle.Offset = 108 + 28f - x));
            });
        }
コード例 #7
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var titleElement       = new DummyInputElement("Title");
            var descriptionElement = new ExpandingInputElement("Description");

            var source = new DialogTableViewSource(TableView);

            source.Root.Add(new Section {
                titleElement, descriptionElement
            });
            TableView.Source          = source;
            TableView.TableFooterView = new UIView();

            OnActivation(d => {
                d(this.WhenAnyValue(x => x.ViewModel.Filename).Subscribe(x => titleElement.Value = x));
                d(titleElement.Changed.Subscribe(x => ViewModel.Filename = x));

                d(this.WhenAnyValue(x => x.ViewModel.Description).Subscribe(x => descriptionElement.Value = x));
                d(descriptionElement.Changed.Subscribe(x => ViewModel.Description = x));

                d(this.WhenAnyValue(x => x.ViewModel.SaveCommand)
                  .Do((IReactiveCommand <Unit> _) => ResignFirstResponder())
                  .ToBarButtonItem(UIBarButtonSystemItem.Save, x => NavigationItem.RightBarButtonItem = x));
            });
        }
コード例 #8
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var descriptionElement = new ExpandingInputElement("Description");

            descriptionElement.AccessoryView = x => new MarkdownAccessoryView(x);
            var titleElement = new DummyInputElement("Title");

            var saveButton   = new UIBarButtonItem(UIBarButtonSystemItem.Save);
            var cancelButton = new UIBarButtonItem(UIBarButtonSystemItem.Cancel);

            NavigationItem.LeftBarButtonItem  = cancelButton;
            NavigationItem.RightBarButtonItem = saveButton;

            var source = new DialogTableViewSource(TableView);

            source.Root.Add(new Section {
                titleElement, descriptionElement
            });
            TableView.Source          = source;
            TableView.TableFooterView = new UIView();

            OnActivation(d => {
                d(descriptionElement.Changed
                  .Subscribe(x => ViewModel.Description = x));

                d(this.WhenAnyValue(x => x.ViewModel.Title)
                  .Subscribe(title => Title = title));

                d(this.WhenAnyValue(x => x.ViewModel.Subject)
                  .Subscribe(x => titleElement.Value = x));

                d(this.WhenAnyValue(x => x.ViewModel.Description)
                  .Subscribe(x => descriptionElement.Value = x));

                d(titleElement.Changed.Subscribe(x => ViewModel.Subject = x));

                d(cancelButton.GetClickedObservable()
                  .Select(_ => Unit.Default)
                  .InvokeReactiveCommand(ViewModel.DismissCommand));

                d(this.WhenAnyObservable(x => x.ViewModel.DismissCommand)
                  .Where(x => x)
                  .Subscribe(_ => DismissViewController(true, null)));

                d(saveButton.GetClickedObservable()
                  .Do(x => ResignFirstResponder())
                  .InvokeReactiveCommand(ViewModel.SubmitCommand));

                d(ViewModel.SubmitCommand
                  .Subscribe(_ => DismissViewController(true, null)));

                d(this.WhenAnyObservable(x => x.ViewModel.SubmitCommand.CanExecute)
                  .Subscribe(x => saveButton.Enabled = x));

                d(this.WhenAnyObservable(x => x.ViewModel.SubmitCommand.IsExecuting)
                  .SubscribeStatus("Submitting feedback"));
            });
        }
コード例 #9
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var source = new DialogTableViewSource(TableView);

            TableView.Source = source;

            OnActivation(d => {
                d(source.SelectedObservable.Cast <StringElement>()
                  .Subscribe(x => ViewModel.SelectedStartupView = x.Caption));

                d(this.WhenAnyValue(x => x.ViewModel.SelectedStartupView).Subscribe(x => {
                    var items = ViewModel.StartupViews.Select(view => {
                        var el = new StringElement(view);
                        el.Clicked.Subscribe(_ => {});
                        el.Accessory = string.Equals(view, ViewModel.SelectedStartupView, StringComparison.OrdinalIgnoreCase)
                            ? UITableViewCellAccessory.Checkmark :  UITableViewCellAccessory.None;
                        return(el);
                    });

                    source.Root.Reset(new Section {
                        items
                    });
                }));
            });
        }
コード例 #10
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var source = new DialogTableViewSource(TableView, true);

            source.Root.Add(new Section {
                _titleElement, _descriptionElement
            });
            TableView.Source          = source;
            TableView.TableFooterView = new UIView();
        }
コード例 #11
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var typeElement  = new StringElement("Type", string.Empty, UITableViewCellStyle.Value1);
            var stateElement = new StringElement("State", string.Empty, UITableViewCellStyle.Value1);
            var fieldElement = new StringElement("Field", string.Empty, UITableViewCellStyle.Value1);
            var ascElement   = new BooleanElement("Ascending");
            var labelElement = new EntryElement("Labels", "bug,ui,@user", string.Empty)
            {
                TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None
            };

            var filterSection = new Section("Filter")
            {
                typeElement, stateElement, labelElement
            };
            var orderSection = new Section("Order By")
            {
                fieldElement, ascElement
            };
            var searchSection = new Section();
            var footerButton  = new TableFooterButton("Search!");

            searchSection.FooterView = footerButton;

            var source = new DialogTableViewSource(TableView);

            TableView.Source = source;
            source.Root.Add(filterSection, orderSection, searchSection);

            OnActivation(d => {
                d(typeElement.Clicked.InvokeCommand(ViewModel.SelectFilterTypeCommand));
                d(stateElement.Clicked.InvokeCommand(ViewModel.SelectStateCommand));
                d(fieldElement.Clicked.InvokeCommand(ViewModel.SelectSortCommand));
                d(footerButton.Clicked.InvokeCommand(ViewModel.SaveCommand));
                d(ascElement.Changed.Subscribe(x => ViewModel.Ascending = x));
                d(labelElement.Changed.Subscribe(x => ViewModel.Labels  = x));

                d(this.WhenAnyValue(x => x.ViewModel.FilterType).Subscribe(x => typeElement.Value = x.Humanize()));
                d(this.WhenAnyValue(x => x.ViewModel.State).Subscribe(x => stateElement.Value     = x.Humanize()));
                d(this.WhenAnyValue(x => x.ViewModel.Labels).Subscribe(x => labelElement.Value    = x));
                d(this.WhenAnyValue(x => x.ViewModel.SortType).Subscribe(x => fieldElement.Value  = x.Humanize()));
                d(this.WhenAnyValue(x => x.ViewModel.Ascending).Subscribe(x => ascElement.Value   = x));

                d(this.WhenAnyValue(x => x.ViewModel.DismissCommand)
                  .ToBarButtonItem(Images.Cancel, x => NavigationItem.LeftBarButtonItem = x));

                d(this.WhenAnyValue(x => x.ViewModel.SaveCommand)
                  .ToBarButtonItem(Images.Search, x => NavigationItem.RightBarButtonItem = x));
            });
        }
コード例 #12
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var source = new DialogTableViewSource(TableView);

            TableView.Source = source;

            this.WhenActivated(d =>
            {
                d(this.WhenAnyValue(x => x.SelectedValue)
                  .Subscribe(_ => Render(source)));
            });
        }
コード例 #13
0
ファイル: MenuView.cs プロジェクト: zjdgx/CodeHub
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //Add some nice looking colors and effects
            TableView.TableFooterView = new UIView(new CGRect(0, 0, View.Bounds.Width, 0));
            TableView.BackgroundColor = Themes.Theme.Current.MenuBackgroundColor;
            TableView.ScrollsToTop    = false;
            TableView.SeparatorColor  = Themes.Theme.Current.PrimaryNavigationBarColor;
            TableView.Source          = _dialogSource = new MenuTableViewSource(this);
            TableView.RowHeight       = 54f;

            ViewModel.WhenAnyValue(x => x.Organizations).Subscribe(x => CreateMenuRoot());
            ViewModel.WhenAnyValue(x => x.PinnedRepositories).Subscribe(x => CreateMenuRoot());
        }
コード例 #14
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var typeElement = new StringElement("Type", () => ViewModel.SelectFilterTypeCommand.ExecuteIfCan());

            typeElement.Style = UITableViewCellStyle.Value1;

            var stateElement = new StringElement("State", () => ViewModel.SelectStateCommand.ExecuteIfCan());

            stateElement.Style = UITableViewCellStyle.Value1;

            var labelElement = new EntryElement("Labels", "bug,ui,@user", string.Empty)
            {
                TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None
            };

            labelElement.Changed += (sender, e) => ViewModel.Labels = labelElement.Value;

            var fieldElement = new StringElement("Field", () => ViewModel.SelectSortCommand.ExecuteIfCan());

            fieldElement.Style = UITableViewCellStyle.Value1;

            var ascElement = new BooleanElement("Ascending", false, x => ViewModel.Ascending = x.Value);

            var filterSection = new Section("Filter")
            {
                typeElement, stateElement, labelElement
            };
            var orderSection = new Section("Order By")
            {
                fieldElement, ascElement
            };
            var searchSection = new Section();

            searchSection.FooterView = new TableFooterButton("Search!", () => ViewModel.SaveCommand.ExecuteIfCan());

            var source = new DialogTableViewSource(TableView);

            TableView.Source = source;
            source.Root.Add(filterSection, orderSection, searchSection);

            this.WhenAnyValue(x => x.ViewModel.FilterType).Subscribe(x => typeElement.Value = x.Humanize());
            this.WhenAnyValue(x => x.ViewModel.State).Subscribe(x => stateElement.Value     = x.Humanize());
            this.WhenAnyValue(x => x.ViewModel.Labels).Subscribe(x => labelElement.Value    = x);
            this.WhenAnyValue(x => x.ViewModel.SortType).Subscribe(x => fieldElement.Value  = x.Humanize());
            this.WhenAnyValue(x => x.ViewModel.Ascending).Subscribe(x => ascElement.Value   = x);
        }
コード例 #15
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var descriptionElement = new ExpandingInputElement("Description");

            descriptionElement.AccessoryView = x => new MarkdownAccessoryView(x);
            var titleElement = new DummyInputElement("Title");

            var saveButton   = new UIBarButtonItem(UIBarButtonSystemItem.Save);
            var cancelButton = new UIBarButtonItem {
                Image = Images.Cancel
            };

            NavigationItem.LeftBarButtonItem  = cancelButton;
            NavigationItem.RightBarButtonItem = saveButton;

            var source = new DialogTableViewSource(TableView);

            source.Root.Add(new Section {
                titleElement, descriptionElement
            });
            TableView.Source          = source;
            TableView.TableFooterView = new UIView();

            OnActivation(d => {
                d(descriptionElement.Changed.Subscribe(x => ViewModel.Description = x));
                d(this.WhenAnyValue(x => x.ViewModel.Subject).Subscribe(x => titleElement.Value           = x));
                d(this.WhenAnyValue(x => x.ViewModel.Description).Subscribe(x => descriptionElement.Value = x));
                d(titleElement.Changed.Subscribe(x => ViewModel.Subject = x));
                d(this.WhenAnyValue(x => x.ViewModel.DismissCommand)
                  .ToBarButtonItem(Images.Cancel, x => NavigationItem.LeftBarButtonItem = x));

                d(saveButton.GetClickedObservable()
                  .Do <Unit>(x => ResignFirstResponder())
                  .InvokeCommand(ViewModel.SubmitCommand));

                d(this.WhenAnyObservable(x => x.ViewModel.SubmitCommand.CanExecuteObservable)
                  .Subscribe(x => saveButton.Enabled = x));
            });
        }
コード例 #16
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var titleElement = new DummyInputElement("Name");

            titleElement.SpellChecking = false;

            var descriptionElement = new ExpandingInputElement("Content");

            descriptionElement.Font          = UIFont.FromName("Courier", UIFont.PreferredBody.PointSize);
            descriptionElement.SpellChecking = false;

            this.WhenAnyValue(x => x.ViewModel.Name)
            .Subscribe(x => titleElement.Value = x);
            titleElement.Changed += (sender, e) => ViewModel.Name = titleElement.Value;

            this.WhenAnyValue(x => x.ViewModel.Content)
            .Subscribe(x => descriptionElement.Value = x);
            descriptionElement.ValueChanged         += (sender, e) => ViewModel.Content = descriptionElement.Value;

            NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Save, (s, e) => {
                ResignFirstResponder();
                NavigationController.PushViewController(_messageViewController.Value, true);
            });
            this.WhenAnyValue(x => x.ViewModel.CanCommit)
            .Subscribe(x => NavigationItem.RightBarButtonItem.Enabled = x);

            this.WhenAnyValue(x => x.ViewModel.DismissCommand)
            .Select(x => x.ToBarButtonItem(Images.Cancel))
            .Subscribe(x => NavigationItem.LeftBarButtonItem = x);

            var source = new DialogTableViewSource(TableView);

            source.Root.Add(new Section {
                titleElement, descriptionElement
            });
            TableView.Source          = source;
            TableView.TableFooterView = new UIView();
        }
コード例 #17
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.WhenAnyValue(x => x.ViewModel.SaveCommand)
            .Select(x => x.ToBarButtonItem(UIBarButtonSystemItem.Save))
            .Subscribe(x => NavigationItem.RightBarButtonItem = x);

            this.WhenAnyValue(x => x.ViewModel.DismissCommand)
            .Select(x => x.ToBarButtonItem(Images.Cancel))
            .Subscribe(x => NavigationItem.LeftBarButtonItem = x);

            this.WhenAnyValue(x => x.ViewModel.Files)
            .Select(x => x.Changed.Select(_ => Unit.Default).StartWith(Unit.Default))
            .Switch()
            .Select(_ => ViewModel.Files.Select(x => new FileElement(x)))
            .Subscribe(x => _fileSection.Reset(x));

            var addFileElement = new StringElement("Add File");

            addFileElement.Image  = Octicon.Plus.ToImage();
            addFileElement.Tapped = () => ViewModel.AddGistFileCommand.ExecuteIfCan();

            var descriptionElement = new ExpandingInputElement("Description (Optional)");

            this.WhenAnyValue(x => x.ViewModel.Description).Subscribe(x => descriptionElement.Value = x);
            descriptionElement.ValueChanged += (sender, e) => ViewModel.Description = descriptionElement.Value;

            Source = new EditSource(this);
            Source.Root.Add(_fileSection, new Section {
                addFileElement
            }, new Section("Details")
            {
                descriptionElement
            });

            TableView.Source          = Source;
            TableView.TableFooterView = new UIView();
        }
コード例 #18
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var source = new DialogTableViewSource(TableView);

            TableView.Source = source;

            ViewModel.WhenAnyValue(x => x.SelectedStartupView).Subscribe(x =>
            {
                var items = ViewModel.StartupViews.Select(view =>
                {
                    var el       = new StringElement(view, () => ViewModel.SelectedStartupView = view);
                    el.Accessory = string.Equals(view, ViewModel.SelectedStartupView, StringComparison.OrdinalIgnoreCase)
                        ? UITableViewCellAccessory.Checkmark :  UITableViewCellAccessory.None;
                    return(el);
                });

                source.Root.Reset(new Section {
                    items
                });
            });
        }
コード例 #19
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.AddTableView(TableView);
            var source = new DialogTableViewSource(Root);

            TableView.Source              = source;
            TableView.TableHeaderView     = HeaderView;
            TableView.SectionHeaderHeight = 0;

            var frame = TableView.Bounds;

            frame.Y = -frame.Size.Height;
            _backgroundHeaderView.Frame            = frame;
            _backgroundHeaderView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            _backgroundHeaderView.Layer.ZPosition  = -1f;
            TableView.InsertSubview(_backgroundHeaderView, 0);

            OnActivation(disposable =>
            {
                source
                .DidScrolled
                .Where(_ => NavigationController != null)
                .Subscribe(p =>
                {
                    if (p.Y > 0)
                    {
                        NavigationController.NavigationBar.ShadowImage = null;
                    }
                    if (p.Y <= 0 && NavigationController.NavigationBar.ShadowImage == null)
                    {
                        NavigationController.NavigationBar.ShadowImage = new UIImage();
                    }
                    SlideUpTitle.Offset = 108 + 28 - p.Y;
                })
                .AddTo(disposable);
            });
        }
コード例 #20
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var titleElement = new DummyInputElement("Name")
            {
                SpellChecking = false
            };
            var descriptionElement = new ExpandingInputElement("Content")
            {
                SpellChecking = false,
                Font          = UIFont.FromName("Courier", UIFont.PreferredBody.PointSize)
            };

            var source = new DialogTableViewSource(TableView);

            source.Root.Add(new Section {
                titleElement, descriptionElement
            });
            TableView.Source          = source;
            TableView.TableFooterView = new UIView();

            OnActivation(d => {
                d(this.WhenAnyValue(x => x.ViewModel.Name).Subscribe(x => titleElement.Value          = x));
                d(this.WhenAnyValue(x => x.ViewModel.Content).Subscribe(x => descriptionElement.Value = x));

                d(titleElement.Changed.Subscribe(x => ViewModel.Name          = x));
                d(descriptionElement.Changed.Subscribe(x => ViewModel.Content = x));

                d(this.WhenAnyValue(x => x.ViewModel.GoToCommitMessageCommand)
                  .ToBarButtonItem(UIBarButtonSystemItem.Save, x => NavigationItem.RightBarButtonItem = x));

                d(this.WhenAnyObservable(x => x.ViewModel.GoToCommitMessageCommand).Subscribe(_ => GoToMessage()));

                d(this.WhenAnyValue(x => x.ViewModel.DismissCommand)
                  .ToBarButtonItem(Images.Cancel, x => NavigationItem.LeftBarButtonItem = x));
            });
        }
コード例 #21
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var descriptionElement = new ExpandingInputElement("Description");

            descriptionElement.AccessoryView = x => new MarkdownAccessoryView(x);

            var titleElement = new DummyInputElement("Title");

            this.WhenAnyValue(x => x.ViewModel.Subject).Subscribe(x => titleElement.Value = x);
            titleElement.Changed += (sender, e) => ViewModel.Subject = titleElement.Value;

            this.WhenAnyValue(x => x.ViewModel.Description).Subscribe(x => descriptionElement.Value = x);
            descriptionElement.ValueChanged += (sender, e) => ViewModel.Description = descriptionElement.Value;

            this.WhenAnyValue(x => x.ViewModel.SubmitCommand).Subscribe(x => {
                NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Save, (s, e) => {
                    ResignFirstResponder();
                    x.ExecuteIfCan();
                });

                x.CanExecuteObservable.Subscribe(y => NavigationItem.RightBarButtonItem.Enabled = y);
            });

            this.WhenAnyValue(x => x.ViewModel.DismissCommand)
            .Select(x => x.ToBarButtonItem(Images.Cancel))
            .Subscribe(x => NavigationItem.LeftBarButtonItem = x);

            var source = new DialogTableViewSource(TableView);

            source.Root.Add(new Section {
                titleElement, descriptionElement
            });
            TableView.Source          = source;
            TableView.TableFooterView = new UIView();
        }
コード例 #22
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var addFileElement     = new StringElement("Add File", Octicon.Plus.ToImage());
            var descriptionElement = new ExpandingInputElement("Description (Optional)");

            Source = new EditSource(this);
            Source.Root.Add(_fileSection, new Section {
                addFileElement
            }, new Section("Details")
            {
                descriptionElement
            });

            TableView.Source          = Source;
            TableView.TableFooterView = new UIView();

            OnActivation(d => {
                d(addFileElement.Clicked.InvokeCommand(ViewModel.AddGistFileCommand));

                d(this.WhenAnyValue(x => x.ViewModel.Description).Subscribe(x => descriptionElement.Value = x));
                d(descriptionElement.Changed.Subscribe(x => ViewModel.Description = x));

                d(this.WhenAnyValue(x => x.ViewModel.SaveCommand)
                  .ToBarButtonItem(Images.SaveButton, x => NavigationItem.RightBarButtonItem = x));

                d(this.WhenAnyValue(x => x.ViewModel.DismissCommand)
                  .ToBarButtonItem(Images.Cancel, x => NavigationItem.LeftBarButtonItem = x));

                d(this.WhenAnyValue(x => x.ViewModel.Files)
                  .Select(x => x.Changed.Select(_ => Unit.Default).StartWith(Unit.Default))
                  .Switch()
                  .Select(_ => ViewModel.Files.Select(x => new FileElement(x)))
                  .Subscribe(x => _fileSection.Reset(x)));
            });
        }
コード例 #23
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var source = new DialogTableViewSource(TableView);

            TableView.Source = source;

            var stateElement = new StringElement("State", () => ViewModel.SelectStateCommand.ExecuteIfCan());

            stateElement.Style = UITableViewCellStyle.Value1;

            var cmd          = ViewModel.SelectLabelsCommand;
            var labelElement = new StringElement("Labels", () => cmd.ExecuteIfCan());

            labelElement.Style = UITableViewCellStyle.Value1;

            var mentionedElement = new EntryElement("Mentioned", "username", string.Empty)
            {
                TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None
            };

            mentionedElement.Changed += (sender, e) => ViewModel.Mentioned = mentionedElement.Value;

            var creatorElement = new EntryElement("Creator", "username", string.Empty)
            {
                TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None
            };

            creatorElement.Changed += (sender, e) => ViewModel.Creator = creatorElement.Value;

            var assigneeElement = new StringElement("Assignee", () => ViewModel.SelectAssigneeCommand.ExecuteIfCan());

            assigneeElement.Style = UITableViewCellStyle.Value1;

            var milestoneElement = new StringElement("Milestone", () => ViewModel.SelectMilestoneCommand.ExecuteIfCan());

            milestoneElement.Style = UITableViewCellStyle.Value1;

            var fieldElement = new StringElement("Field", () => ViewModel.SelectSortCommand.ExecuteIfCan());

            fieldElement.Style = UITableViewCellStyle.Value1;

            var ascElement = new BooleanElement("Ascending", false, x => ViewModel.Ascending = x.Value);

            var filterSection = new Section("Filter")
            {
                stateElement, mentionedElement, creatorElement, labelElement, assigneeElement, milestoneElement
            };
            var orderSection = new Section("Order By")
            {
                fieldElement, ascElement
            };
            var searchSection = new Section();

            searchSection.FooterView = new TableFooterButton("Search!", () => ViewModel.SaveCommand.ExecuteIfCan());
            source.Root.Add(filterSection, orderSection, searchSection);

            this.WhenAnyObservable(x => x.ViewModel.SelectAssigneeCommand)
            .Subscribe(_ => IssueAssigneeViewController.Show(this, ViewModel.CreateAssigneeViewModel()));

            this.WhenAnyObservable(x => x.ViewModel.SelectMilestoneCommand)
            .Subscribe(_ => IssueMilestonesViewController.Show(this, ViewModel.CreateMilestonesViewModel()));

            this.WhenAnyObservable(x => x.ViewModel.SelectLabelsCommand)
            .Subscribe(_ => IssueLabelsViewController.Show(this, ViewModel.CreateLabelsViewModel()));

            this.WhenAnyValue(x => x.ViewModel.State).Subscribe(x => stateElement.Value               = x.Humanize());
            this.WhenAnyValue(x => x.ViewModel.LabelsString).Subscribe(x => labelElement.Value        = x);
            this.WhenAnyValue(x => x.ViewModel.Mentioned).Subscribe(x => mentionedElement.Value       = x);
            this.WhenAnyValue(x => x.ViewModel.Creator).Subscribe(x => creatorElement.Value           = x);
            this.WhenAnyValue(x => x.ViewModel.AssigneeString).Subscribe(x => assigneeElement.Value   = x);
            this.WhenAnyValue(x => x.ViewModel.MilestoneString).Subscribe(x => milestoneElement.Value = x);
            this.WhenAnyValue(x => x.ViewModel.SortType).Subscribe(x => fieldElement.Value            = x.Humanize());
            this.WhenAnyValue(x => x.ViewModel.Ascending).Subscribe(x => ascElement.Value             = x);
        }
コード例 #24
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var source = new DialogTableViewSource(TableView);

            TableView.Source = source;

            var mentionedElement = new EntryElement("Mentioned", "username", string.Empty)
            {
                TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None
            };

            var creatorElement = new EntryElement("Creator", "username", string.Empty)
            {
                TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None
            };

            var stateElement     = new ButtonElement("State");
            var labelElement     = new ButtonElement("Labels");
            var assigneeElement  = new ButtonElement("Assignee");
            var milestoneElement = new ButtonElement("Milestone");
            var fieldElement     = new ButtonElement("Field");
            var ascElement       = new BooleanElement("Ascending");

            var filterSection = new Section("Filter")
            {
                stateElement, mentionedElement, creatorElement, labelElement, assigneeElement, milestoneElement
            };
            var orderSection = new Section("Order By")
            {
                fieldElement, ascElement
            };
            var searchSection = new Section();
            var footerButton  = new TableFooterButton("Search!");

            searchSection.FooterView = footerButton;
            source.Root.Add(filterSection, orderSection, searchSection);

            OnActivation(d => {
                d(assigneeElement.Clicked.InvokeCommand(ViewModel.SelectAssigneeCommand));
                d(milestoneElement.Clicked.InvokeCommand(ViewModel.SelectMilestoneCommand));
                d(fieldElement.Clicked.InvokeCommand(ViewModel.SelectSortCommand));
                d(stateElement.Clicked.InvokeCommand(ViewModel.SelectStateCommand));
                d(labelElement.Clicked.InvokeCommand(ViewModel.SelectLabelsCommand));
                d(footerButton.Clicked.InvokeCommand(ViewModel.SaveCommand));
                d(ascElement.Changed.Subscribe(x => ViewModel.Ascending       = x));
                d(mentionedElement.Changed.Subscribe(x => ViewModel.Mentioned = x));
                d(creatorElement.Changed.Subscribe(x => ViewModel.Creator     = x));

                d(this.WhenAnyValue(x => x.ViewModel.DismissCommand)
                  .ToBarButtonItem(Images.Cancel, x => NavigationItem.LeftBarButtonItem = x));

                d(this.WhenAnyValue(x => x.ViewModel.SaveCommand)
                  .ToBarButtonItem(Images.Search, x => NavigationItem.RightBarButtonItem = x));

                d(this.WhenAnyValue(x => x.ViewModel.State).Subscribe(x => stateElement.Value               = x.Humanize()));
                d(this.WhenAnyValue(x => x.ViewModel.LabelsString).Subscribe(x => labelElement.Value        = x));
                d(this.WhenAnyValue(x => x.ViewModel.Mentioned).Subscribe(x => mentionedElement.Value       = x));
                d(this.WhenAnyValue(x => x.ViewModel.Creator).Subscribe(x => creatorElement.Value           = x));
                d(this.WhenAnyValue(x => x.ViewModel.AssigneeString).Subscribe(x => assigneeElement.Value   = x));
                d(this.WhenAnyValue(x => x.ViewModel.MilestoneString).Subscribe(x => milestoneElement.Value = x));
                d(this.WhenAnyValue(x => x.ViewModel.SortType).Subscribe(x => fieldElement.Value            = x.Humanize()));
                d(this.WhenAnyValue(x => x.ViewModel.Ascending).Subscribe(x => ascElement.Value             = x));

                d(this.WhenAnyObservable(x => x.ViewModel.SelectAssigneeCommand)
                  .Subscribe(_ => IssueAssigneeViewController.Show(this, ViewModel.CreateAssigneeViewModel())));

                d(this.WhenAnyObservable(x => x.ViewModel.SelectMilestoneCommand)
                  .Subscribe(_ => IssueMilestonesViewController.Show(this, ViewModel.CreateMilestonesViewModel())));

                d(this.WhenAnyObservable(x => x.ViewModel.SelectLabelsCommand)
                  .Subscribe(_ => IssueLabelsViewController.Show(this, ViewModel.CreateLabelsViewModel())));
            });
        }