Team, I have a question. I'm developing a details screen for an order, where there is a button used to take up this request.
To get clearer, this behavior details screen of different shapes for different statuses:
using CoreGraphics;
using MvvmCross.Binding.BindingContext;
using MvvmCross.Core.ViewModels;
using MvvmCross.iOS.Views;
using UIKit;
using Valdemar.Core.ViewModels;
namespace Valdemar.IOs
{
public sealed partial class DetailView : MvxViewController<DetailViewModel>
{
private bool _constructed;
public DetailView() : base("DetailView", null)
{
ViewDidLoad();
}
public override void DidReceiveMemoryWarning()
{
// Releases the view if it doesn't have a superview.
base.DidReceiveMemoryWarning();
// Release any cached data, images, etc that aren't in use.
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
if (ViewModel == null)
{
return;
}
var close = UIButton.FromType(UIButtonType.System);
close.Frame = new CGRect(8, 35, 50, 20);
close.SetTitle("Voltar", UIControlState.Normal);
Add(close);
/*
* Binding
*/
var set = this.CreateBindingSet<DetailView, Core.ViewModels.DetailViewModel>();
set.Bind(lblWhat).To(vm => vm.Item.itemsDes);
set.Bind(lblHowMuch).To(vm => vm.Item.valueDes);
set.Bind(lblWhen).To(vm => vm.Item.limitTime);
set.Bind(lblStatus).To(vm => vm.Item.status);
set.Bind(lblUser).To(vm => vm.Item.usersTOByIdClientUser.personsTO.namePerson);
//set.Bind(lblAdress).To(vm => vm.Item.usersTOByIdClientUser);
set.Bind(lblResponsible).To(vm => vm.Item.valdecoOwner);
set.Bind(lblConfirmed).To(vm => vm.Item.confirmed);
set.Bind(lblCreated).To(vm => vm.Item.created);
set.Bind(close).To(vm => vm.CloseCommand);
set.Bind(close).For("Clicked").To(vm => vm.CloseCommand);
if (lblStatus.Text == "A")
{
btnAction.SetTitle("Assumir Pedido!", UIControlState.Normal);
set.Bind(btnAction).To(vm => vm.BtnAssumeCommand);
lblStatus.Hidden = true;
lblConfirmation.Hidden = true;
lblResponsible.Hidden = true;
}
else if (lblStatus.Text == "V")
{
set.Bind(lblStatus).To(vm => vm.V);
btnAction.SetTitle("Entreguei!", UIControlState.Normal);
set.Bind(btnAction).To(vm => vm.BtnDeliverCommand);
lblConfirmation.Hidden = true;
}
else if (lblStatus.Text == "E")
{
set.Bind(lblStatus).To(vm => vm.E);
lblConfirmation.Hidden = false;
btnAction.Hidden = true;
}
else if (lblStatus.Text == "C")
{
lblConfirmation.Hidden = true;
btnAction.Hidden = true;
lblConfirmed.Hidden = false;
set.Bind(lblStatus).To(vm => vm.C);
}
set.Apply();
}
}
}
When I launch the button command, I will have to change the status of my request, and therefore hide the "Assume" button.
private async Task<bool> assumeOrder()
{
var response = await orderService.assumeResp(getOrder());
if (response == null)
{
messageService.showMessage("Pedido " + Item.id + " assumido com sucesso!");
orderService.deleteAvailableOrder(Item);
RaisePropertyChanged(() => Item);
return false;
}
return true;
}
What is the best way to do it, especially if the button "disappears"? I'm trying through the RaisePropertyChanged (() => Item), it updates the properties but does not re-access the View to change it according to its new Status.