|
8 | 8 | using CodeFramework.iOS.Utils; |
9 | 9 | using CodeHub.iOS.ViewControllers; |
10 | 10 |
|
11 | | -namespace CodeHub.iOS.Views.Issues |
12 | | -{ |
13 | | - public class IssueEditView : ViewModelDrivenDialogViewController |
| 11 | +namespace CodeHub.iOS.Views.Issues |
| 12 | +{ |
| 13 | + public class IssueEditView : ViewModelDrivenDialogViewController |
14 | 14 | { |
15 | | - private IHud _hud; |
| 15 | + private IHud _hud; |
16 | 16 |
|
17 | | - public override void ViewDidLoad() |
18 | | - { |
19 | | - Title = "Edit Issue"; |
| 17 | + public override void ViewDidLoad() |
| 18 | + { |
| 19 | + Title = "Edit Issue"; |
20 | 20 |
|
21 | | - base.ViewDidLoad(); |
| 21 | + base.ViewDidLoad(); |
22 | 22 |
|
23 | | - _hud = this.CreateHud(); |
24 | | - var vm = (IssueEditViewModel)ViewModel; |
| 23 | + _hud = this.CreateHud(); |
| 24 | + var vm = (IssueEditViewModel)ViewModel; |
25 | 25 |
|
26 | | - NavigationItem.RightBarButtonItem = new UIBarButtonItem(Theme.CurrentTheme.SaveButton, UIBarButtonItemStyle.Plain, (s, e) => { |
27 | | - View.EndEditing(true); |
28 | | - vm.SaveCommand.Execute(null); |
29 | | - }); |
| 26 | + NavigationItem.RightBarButtonItem = new UIBarButtonItem(Theme.CurrentTheme.SaveButton, UIBarButtonItemStyle.Plain, (s, e) => { |
| 27 | + View.EndEditing(true); |
| 28 | + vm.SaveCommand.Execute(null); |
| 29 | + }); |
30 | 30 |
|
31 | | - var title = new InputElement("Title", string.Empty, string.Empty); |
32 | | - title.Changed += (object sender, EventArgs e) => vm.Title = title.Value; |
| 31 | + var title = new InputElement("Title", string.Empty, string.Empty); |
| 32 | + title.Changed += (object sender, EventArgs e) => vm.Title = title.Value; |
33 | 33 |
|
34 | | - var assignedTo = new StyledStringElement("Responsible", "Unassigned", UITableViewCellStyle.Value1); |
35 | | - assignedTo.Accessory = UITableViewCellAccessory.DisclosureIndicator; |
36 | | - assignedTo.Tapped += () => vm.GoToAssigneeCommand.Execute(null); |
| 34 | + var assignedTo = new StyledStringElement("Responsible", "Unassigned", UITableViewCellStyle.Value1); |
| 35 | + assignedTo.Accessory = UITableViewCellAccessory.DisclosureIndicator; |
| 36 | + assignedTo.Tapped += () => vm.GoToAssigneeCommand.Execute(null); |
37 | 37 |
|
38 | | - var milestone = new StyledStringElement("Milestone".t(), "None", UITableViewCellStyle.Value1); |
39 | | - milestone.Accessory = UITableViewCellAccessory.DisclosureIndicator; |
40 | | - milestone.Tapped += () => vm.GoToMilestonesCommand.Execute(null); |
| 38 | + var milestone = new StyledStringElement("Milestone".t(), "None", UITableViewCellStyle.Value1); |
| 39 | + milestone.Accessory = UITableViewCellAccessory.DisclosureIndicator; |
| 40 | + milestone.Tapped += () => vm.GoToMilestonesCommand.Execute(null); |
41 | 41 |
|
42 | | - var labels = new StyledStringElement("Labels".t(), "None", UITableViewCellStyle.Value1); |
43 | | - labels.Accessory = UITableViewCellAccessory.DisclosureIndicator; |
44 | | - labels.Tapped += () => vm.GoToLabelsCommand.Execute(null); |
| 42 | + var labels = new StyledStringElement("Labels".t(), "None", UITableViewCellStyle.Value1); |
| 43 | + labels.Accessory = UITableViewCellAccessory.DisclosureIndicator; |
| 44 | + labels.Tapped += () => vm.GoToLabelsCommand.Execute(null); |
45 | 45 |
|
46 | | - var content = new MultilinedElement("Description"); |
47 | | - content.Tapped += () => |
48 | | - { |
| 46 | + var content = new MultilinedElement("Description"); |
| 47 | + content.Tapped += () => |
| 48 | + { |
49 | 49 | var composer = new MarkdownComposerViewController { Title = "Issue Description", Text = content.Value }; |
50 | | - composer.NewComment(this, (text) => { |
51 | | - vm.Content = text; |
52 | | - composer.CloseComposer(); |
53 | | - }); |
54 | | - }; |
55 | | - |
56 | | - var state = new TrueFalseElement("Open", true); |
57 | | - state.ValueChanged += (sender, e) => vm.IsOpen = state.Value; |
58 | | - |
59 | | - vm.Bind(x => x.Title, x => title.Value = x, true); |
60 | | - |
61 | | - vm.Bind(x => x.Content, x => content.Value = x, true); |
62 | | - |
63 | | - vm.Bind(x => x.AssignedTo, x => { |
64 | | - assignedTo.Value = x == null ? "Unassigned" : x.Login; |
65 | | - if (assignedTo.GetImmediateRootElement() != null) |
66 | | - Root.Reload(assignedTo, UITableViewRowAnimation.None); |
67 | | - }, true); |
68 | | - |
69 | | - vm.Bind(x => x.Milestone, x => { |
70 | | - milestone.Value = x == null ? "None" : x.Title; |
71 | | - if (assignedTo.GetImmediateRootElement() != null) |
72 | | - Root.Reload(milestone, UITableViewRowAnimation.None); |
73 | | - }, true); |
74 | | - |
75 | | - vm.BindCollection(x => x.Labels, x => { |
76 | | - labels.Value = vm.Labels.Items.Count == 0 ? "None" : string.Join(", ", vm.Labels.Items.Select(i => i.Name)); |
77 | | - if (assignedTo.GetImmediateRootElement() != null) |
78 | | - Root.Reload(labels, UITableViewRowAnimation.None); |
79 | | - }, true); |
80 | | - |
81 | | - vm.Bind(x => x.IsOpen, x => |
82 | | - { |
83 | | - state.Value = x; |
84 | | - if (assignedTo.GetImmediateRootElement() != null) |
85 | | - Root.Reload(state, UITableViewRowAnimation.None); |
86 | | - }, true); |
87 | | - |
88 | | - vm.Bind(x => x.IsSaving, x => |
89 | | - { |
90 | | - if (x) |
91 | | - _hud.Show("Updating..."); |
92 | | - else |
93 | | - _hud.Hide(); |
94 | | - }); |
95 | | - |
96 | | - Root = new RootElement(Title) { new Section { title, assignedTo, milestone, labels }, new Section { state }, new Section { content } }; |
97 | | - } |
98 | | - } |
99 | | -} |
100 | | - |
| 50 | + composer.NewComment(this, (text) => { |
| 51 | + vm.Content = text; |
| 52 | + composer.CloseComposer(); |
| 53 | + }); |
| 54 | + }; |
| 55 | + |
| 56 | + var state = new TrueFalseElement("Open", true); |
| 57 | + state.ValueChanged += (sender, e) => vm.IsOpen = state.Value; |
| 58 | + |
| 59 | + vm.Bind(x => x.Title, x => title.Value = x, true); |
| 60 | + |
| 61 | + vm.Bind(x => x.Content, x => content.Value = x, true); |
| 62 | + |
| 63 | + vm.Bind(x => x.AssignedTo, x => { |
| 64 | + assignedTo.Value = x == null ? "Unassigned" : x.Login; |
| 65 | + if (assignedTo.GetImmediateRootElement() != null) |
| 66 | + Root.Reload(assignedTo, UITableViewRowAnimation.None); |
| 67 | + }, true); |
| 68 | + |
| 69 | + vm.Bind(x => x.Milestone, x => { |
| 70 | + milestone.Value = x == null ? "None" : x.Title; |
| 71 | + if (assignedTo.GetImmediateRootElement() != null) |
| 72 | + Root.Reload(milestone, UITableViewRowAnimation.None); |
| 73 | + }, true); |
| 74 | + |
| 75 | + vm.BindCollection(x => x.Labels, x => { |
| 76 | + labels.Value = vm.Labels.Items.Count == 0 ? "None" : string.Join(", ", vm.Labels.Items.Select(i => i.Name)); |
| 77 | + if (assignedTo.GetImmediateRootElement() != null) |
| 78 | + Root.Reload(labels, UITableViewRowAnimation.None); |
| 79 | + }, true); |
| 80 | + |
| 81 | + vm.Bind(x => x.IsOpen, x => |
| 82 | + { |
| 83 | + state.Value = x; |
| 84 | + if (assignedTo.GetImmediateRootElement() != null) |
| 85 | + Root.Reload(state, UITableViewRowAnimation.None); |
| 86 | + }, true); |
| 87 | + |
| 88 | + vm.Bind(x => x.IsSaving, x => |
| 89 | + { |
| 90 | + if (x) |
| 91 | + _hud.Show("Updating..."); |
| 92 | + else |
| 93 | + _hud.Hide(); |
| 94 | + }); |
| 95 | + |
| 96 | + Root = new RootElement(Title) { new Section { title, assignedTo, milestone, labels }, new Section { state }, new Section { content } }; |
| 97 | + } |
| 98 | + } |
| 99 | +} |
| 100 | +
|
0 commit comments