private void Load(MinionContract minion) { // bit of a hack, ideally I'd have IEditableObject var isNew = minion == null; this.minion = new MinionContract { Id = !isNew ? minion.Id : Guid.NewGuid(), MinionName = !isNew ? minion.MinionName : "New Minion", WeeklyAllowance = !isNew ? minion.WeeklyAllowance : 0, }; var section1 = new TableViewSection(this.Source); section1.Header = "Name"; section1.Add(new TextInputElement(this.minion, null, new Binding("MinionName")) { Placeholder = "Name", }); var section2 = new TableViewSection(this.Source); section2.Header = "Allowance"; section2.Add(new DecimalInputElement(this.minion, null, new Binding("WeeklyAllowance"))); if (!isNew) { var section3 = new TableViewSection(this.Source); section3.Header = "Deeds"; section3.Add(new DisclosureElement("Deeds to Perform") { Command = this.EditDeeds }); } }
public MinionEditController(MinionContext context, MinionContract minion) : base(UITableViewStyle.Grouped) { this.lifetime = new CompositeDisposable(); this.NavigationItem.Title = minion != null ? "Edit Details" : "Hire Minion"; this.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Cancel); this.NavigationItem.LeftBarButtonItem.Clicked += CancelClicked; this.NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done); this.NavigationItem.RightBarButtonItem.Clicked += DoneClicked; this.context = context; //this.commandExecutor = commandExecutor; this.Load(minion); }
public MinionController(MinionContext context, MinionContract minion) : base() { this.context = context; this.minion = minion; this.lifetime = new CompositeDisposable(); this.Load(minion); this.AddController(new TodayDeedsViewController(), 0); // todo: have an event to show navigated to in order to hook this up later to improve animation speed this.AddController(new MinionCashController(), 0); this.AddController(new MinionDeedsController(), 0); }
public void Load(MinionContract minion) { this.minion = minion; this.NavigationItem.Title = minion.MinionName ?? "New Minion"; var section1 = new TableViewSection(this.Source); section1.Header = "Minion Name"; section1.BeginUpdate(); section1.Add(new TextInputElement(minion, null, new Binding("MinionName")) { Placeholder = "Name", CanEdit = (_) => false }); section1.EndUpdate(); var section2 = new TableViewSection(this.Source); section2.Header = "Weekly Allowance"; section2.BeginUpdate(); section2.Add(new DecimalInputElement(minion, null, new Binding("WeeklyAllowance")) { CanEdit = (_) => true }); section2.EndUpdate(); }
private void MinionUpdated(MinionContract minion) { var section1 = ((TableViewSection)this.Source.SectionAt(0)); // could be added, changed or deleted var element = section1.FirstOrDefault(x => ((MinionContract)x.Data).Id == minion.Id); // because we're using a snapshot based aggregate over an event sourced one // we will get a read model event when we delete the minion. // in the table where the minion was deleted it will already have been deleted // but in other tables it will exist and needs to be removed. if (minion.Deleted) { if (element != null) { section1.Remove(element); } return; } // now update or insert the minion if (element != null) { // todo: rearrange based on minion name element.Data = minion; } else { // todo: better merging of new minions // the minion is a new one // also Version == 1 var minionElement = this.LoadMinion(minion); section1.Insert(0, minionElement); //this.navigateToMinion = minionElement; } }
protected Element LoadMinion(MinionContract minion) { if (this.allowDelete) { return new StringElement(minion, new Binding("MinionName")) { Edit = this.DeleteMinion, CanEdit = x => true, }; } else { return new StringElement(minion, new Binding("MinionName")) { Command = this.NavigateToMinion, }; } }
private void NavigateToMinion(MinionContract minion) { var editor = new RecipientEditViewController(this.commandExecutor); editor.Load(minion); this.NavigationController.PushViewController(editor, true); }
private void MinionUpdated(MinionContract minion) { if (minion.Deleted) { return; } var section1 = ((TableViewSection)this.Source.SectionAt(0)); // could be added, changed or deleted var element = section1.FirstOrDefault(x => ((MinionContract)x.Data).Id == minion.Id); if (element != null) { element.Data = minion; } else { // the minion is a new one // also Version == 1 section1.Insert(0, new DisclosureElement(minion, new Binding("MinionName")) { Command = this.NavigateToMinion, Edit = this.DeleteMinion }); this.NavigateToMinion(minion); } }
private void Load(MinionContract minion) { this.Title = minion.MinionName; }
private void MinionUpdated(MinionContract minion) { bool found = false; for (int i = 0; i < this.minions.Count; i++) { if (this.minions[i].Id == minion.Id) { if (minion.Deleted) { this.minions.RemoveAt(i); this.pagedView.ReloadPages(); } else { this.minions[i] = minion; } found = true; break; } } if (!found) { this.minions.Add(minion); this.pagedView.ReloadPages(); } }
private void NavigateToFireController() { var minion = new MinionContract { MinionName = "Minion", }; var nav = new UINavigationController(new AllMinionsViewController(this.context, "Fire Minions", true)); this.PresentModalViewController(nav, true); // this.Present(new FireController(this.context)); // todo: set menu for firing }
private void NavigateToHireController() { var minion = new MinionContract { MinionName = "Minion", }; var nav = new UINavigationController(new MinionEditController(this.context, null)); this.PresentModalViewController(nav, true); }
private void MinionUpdated(MinionContract minion) { if (minion.Id == this.Minion.Id) { // by-pass property, bit of a hack this.minion = minion; this.minionNameLabel.Text = minion.MinionName; this.transactionButton.SetTitle(string.Format("{0}", minion.CashBalance), UIControlState.Normal); } }