public void Setup() { doneTasks = new List <TaskViewModel>() { new TaskViewModel() { TaskNumber = "234234", EquipmentName = "Building elements to sarisy fire", EquipmentLocation = "Throughout", LastServiceDate = new DateTime(2019, 10, 31), ReferenceNumber = "23434", LastTestResult = "Passed", Barcode = "12345678" } }; undoneTasks = new List <TaskViewModel>() { new TaskViewModel() { TaskNumber = "234236", EquipmentName = "Fire indices for materials", EquipmentLocation = "Throughout", LastServiceDate = new DateTime(2019, 10, 31), ReferenceNumber = "23434", LastTestResult = "Passed", Barcode = "123456789", } }; barcodeInputManuallyViewModel = new BarcodeInputManuallyViewModel(undoneTasks, doneTasks); }
public BarcodeInputManuallyPage(BarcodeInputManuallyViewModel viewModel) { InitializeComponent(); viewmodel = viewModel; this.BindingContext = viewmodel; taskListViewModel = viewmodel.TaskListViewModel; //MessagingCenter.Unsubscribe<BarcodeInputManuallyViewModel, string>(this, "NewTask"); Console.WriteLine("Before Subscribe"); MessagingCenter.Subscribe <BarcodeInputManuallyViewModel, string>(this, "NewTask", async(sender, barcode) => { //Device.BeginInvokeOnMainThread(async() => await Navigation.PushAsync(new LoginPage()) ); Console.WriteLine("After Subscribe"); Device.BeginInvokeOnMainThread(async() => //await DisplayAlert("It's a new task, should jump to a new task page", barcode, "OK")); { bool answer = await DisplayAlert("This is new barcode", "Would you like to create a new task?", "Yes", "No"); if (answer) { AddNewTaskPageViewModel addTaskViewModel = new AddNewTaskPageViewModel(barcode, taskListViewModel); await Navigation.PushAsync(new AddNewTaskPage(addTaskViewModel)); } } ); } ); //MessagingCenter.Unsubscribe<BarcodeInputManuallyViewModel, string>(this, "NewTask"); MessagingCenter.Subscribe <BarcodeInputManuallyViewModel, string>(this, "ExistedTask", async(sender, barcode) => { //Device.BeginInvokeOnMainThread(async () => await Navigation.PushAsync(new LoginPage())); Device.BeginInvokeOnMainThread(async() => //await DisplayAlert("It's an existed task, should jump to existed task page", barcode, "OK") await Navigation.PushAsync(new TaskPage(viewModel.ExistedTask)) ); } ); }
private async void Input_Barcode_Manually(object sender, System.EventArgs e) { var viewmodel = new BarcodeInputManuallyViewModel(viewModel.UndoneTasks, viewModel.DoneTasks, taskListViewModel); await Navigation.PushAsync(new BarcodeInputManuallyPage(viewmodel)); }