private void Button_Clicked(object sender, EventArgs e) { OnDialogClosed?.Invoke(this, new DialogResult { ProductName = productEntry.Text, ExpirationDate = datePicker.Date }); App.Current.MainPage.Navigation.PopPopupAsync(true); }
// // Public Methods // public void Show(Dictionary <string, float> targetValues, Typology typology, OnDialogClosed callback) { this.targetValues = targetValues; this.callback = callback; int childIndex = 0; foreach (var pair in typology.values) { var item = Instantiate(atributeItemPrefab, contentPanel); var toggle = item.GetComponentInChildren <Toggle>(); bool hasTarget = targetValues.ContainsKey(pair.Key); toggle.isOn = hasTarget; toggle.onValueChanged.AddListener((isOn) => OnToggleChange(toggle)); item.GetChild(1).gameObject.SetActive(hasTarget); if (itemToKey.Count != typology.values.Count) { itemToKey.Add(item, pair.Key); } if (Typology.info.TryGetValue(pair.Key, out TypologyInfo info)) { toggle.GetComponentInChildren <Text>().text = pair.Key + " (" + info.units + ")"; } else { toggle.GetComponentInChildren <Text>().text = pair.Key; } if (hasTarget) { var input = item.GetComponentInChildren <InputField>(); input.text = targetValues[pair.Key].ToString(); } if (contentPanel.childCount == typology.values.Count) { ++childIndex; } } gameObject.SetActive(true); }