This repository was archived by the owner on Jul 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 610
Expand file tree
/
Copy pathIssueAddView.cs
More file actions
82 lines (67 loc) · 3.14 KB
/
IssueAddView.cs
File metadata and controls
82 lines (67 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System;
using CodeHub.iOS.ViewControllers;
using CodeHub.Core.ViewModels.Issues;
using UIKit;
using System.Linq;
using CodeHub.iOS.Utilities;
using CodeHub.iOS.DialogElements;
namespace CodeHub.iOS.Views.Issues
{
public class IssueAddView : ViewModelDrivenDialogViewController
{
public IssueAddView()
{
Title = "New Issue";
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
TableView.RowHeight = UITableView.AutomaticDimension;
TableView.EstimatedRowHeight = 44f;
var vm = (IssueAddViewModel)ViewModel;
var saveButton = new UIBarButtonItem(UIBarButtonSystemItem.Save);
NavigationItem.RightBarButtonItem = saveButton;
var title = new EntryElement("Title", string.Empty, string.Empty);
var assignedTo = new StringElement("Responsible", "Unassigned", UITableViewCellStyle.Value1);
var milestone = new StringElement("Milestone", "None", UITableViewCellStyle.Value1);
var labels = new StringElement("Labels", "None", UITableViewCellStyle.Value1);
var content = new MultilinedElement("Description");
Root.Reset(new Section { title, assignedTo, milestone, labels }, new Section { content });
OnActivation(d =>
{
d(vm.Bind(x => x.IssueTitle, true).Subscribe(x => title.Value = x));
d(title.Changed.Subscribe(x => vm.IssueTitle = x));
d(vm.Bind(x => x.Content, true).Subscribe(x => content.Details = x));
d(labels.Clicked.Subscribe(_ => vm.GoToLabelsCommand.Execute(null)));
d(milestone.Clicked.Subscribe(_ => vm.GoToMilestonesCommand.Execute(null)));
d(assignedTo.Clicked.Subscribe(_ => vm.GoToAssigneeCommand.Execute(null)));
d(vm.Bind(x => x.IsSaving).SubscribeStatus("Saving..."));
d(vm.Bind(x => x.AssignedTo, true).Subscribe(x => {
assignedTo.Value = x == null ? "Unassigned" : x.Login;
}));
d(vm.Bind(x => x.Milestone, true).Subscribe(x => {
milestone.Value = x == null ? "None" : x.Title;
}));
d(vm.BindCollection(x => x.Labels, true).Subscribe(_ => {
labels.Value = vm.Labels.Items.Count == 0 ? "None" : string.Join(", ", vm.Labels.Items.Select(i => i.Name));
}));
d(saveButton.GetClickedObservable().Subscribe(_ => {
View.EndEditing(true);
vm.SaveCommand.Execute(null);
}));
d(content.Clicked.Subscribe(_ => {
var composer = new MarkdownComposerViewController
{
Title = "Issue Description",
Text = content.Details
};
composer.PresentAsModal(this, text =>
{
vm.Content = text;
this.DismissViewController(true, null);
});
}));
});
}
}
}