Created
November 21, 2017 11:47
-
-
Save Kikimora/c2dcdd388549b4ec4032370a1e04e43f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface IPersonRouter | |
{ | |
void EditPersonAddress(Address address); | |
} | |
public class PersonRouter : IPersonRouter | |
{ | |
private QodenController _root; | |
PersonRouter(QodenController root) { _root = root; } | |
public void EditPersonAddress(Address address) | |
{ | |
var addressEditor = new AddressController(); | |
addressEditor.Address = address; | |
_root.Push(addressEditor); | |
} | |
} | |
public class PersonController : QodenController | |
{ | |
PersonViewModel model; | |
protected override void ViewDidLoad() | |
{ | |
model = this.GetViewModelStore().GetViewModel<PersonViewModel>(); | |
model.Router = new PersonRouter(this); | |
//... | |
} | |
} | |
public class PersonViewModel : DataContext | |
{ | |
public PersonViewModel() | |
{ | |
EditCommand = new AsyncCommand(EditPersonAddress); | |
} | |
public IPersonRouter Router { get; set; } | |
private async Task EditPersonAddress(object arg, CancellationToken token) | |
{ | |
var newAddress = await _router.EditPersonAddress(this.Address); | |
if (newAddress != null) | |
{ | |
this.Address = newAddress; | |
UpdatePersonAddress(); | |
} | |
} | |
} | |
public class AddressController : QodenController | |
{ | |
AddressViewModel model; | |
protected override void ViewDidLoad() | |
{ | |
model = this.GetViewModelStore().GetViewModel<AddressViewModel>(); | |
//... | |
} | |
public PersonAddress Address | |
{ | |
get => model.Address; | |
set => model.Address = value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment