//Opens a new window when a search item is clicked. public async void itemTapped(object sender, ItemTappedEventArgs e) { if (e.Item == null) { return; //ItemSelected is called on deselection, which results in SelectedItem being set to null } //navigate to NutrFacts page, passing in the event arguments nutrFacts = new NutrFacts(this, (NumoNameSearch)e.Item); await Navigation.PushAsync(nutrFacts); selectedResult = (NumoNameSearch)e.Item; }
//Retrieve custom quantifiers from database and add to searchItem public void addCustomQuantifiers(NumoNameSearch item) { string data_num = item.food_no.ToString(); if (data_num.Length == 4) { data_num = "0" + data_num; } var convertItems = getCustomQuantifiers(item.food_no); item.convertions.AddRange(convertItems); }
public NutrFacts(AddItemPage aip, NumoNameSearch search) { InitializeComponent(); //save reference to food item selectedResult = search; //so the saveButtonClicked method can be used by the classes inheritting from AddItemPage this.aip = aip; //establish the save button on the top right ToolbarItem save = new ToolbarItem(); save.Text = "Save"; save.Clicked += saveButtonClicked; ToolbarItems.Add(save); //establish description view descrView.Text = search.ToString(); descrView.FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)); descrView.VerticalOptions = LayoutOptions.Start; descrView.HorizontalOptions = LayoutOptions.Start; //set default units in picker //add any custom picker units from selected item updateUnitPickerWithCustomOptions(); //set default input values Quantity = "1"; UnitsPicker.SelectedIndex = 0; UnitPickerText = UnitsPicker.SelectedItem.ToString(); //so that it is not called incorrectly //get nutrient info on food item displayNutrInfo(); }