private async void Tgr_Tapped(object sender, EventArgs e) { SnackDataDTO index = null; foreach (var item in (sender as StackLayout).Children) { if (item is Label) { var snackName = (item as Label).Text; index = result.data.snacks.Single(obj => obj.friendly_name == snackName); break; } } if (index != null) { if (TabletManager.Instance.tablet) { await Navigation.PushPopupAsync(new CodicePopup(index, "mangia", null, null, null, null)); } else { SelectedItemChangedEventArgs test = new SelectedItemChangedEventArgs(index); ListView_ItemSelected(null, test); } } }
private async void Apply_Clicked(object sender, EventArgs e) { bool result = false; if (codiceAndroid.Text != "" || codiceAndroid.Text != null || codiceiOS.Text != "" || codiceiOS.Text != null) { switch (Device.RuntimePlatform) { case Device.Android: result = await ControlloCodice.checkBeforeAction(codiceAndroid.Text); break; case Device.iOS: result = await ControlloCodice.checkBeforeAction(codiceiOS.Text); break; } if (result) { switch (mod) { case "mangia": SnackServiceManager a = new SnackServiceManager(); SnackDataDTO elemento = (SnackDataDTO)index; var scelta = await DisplayAlert("Fondomerende", "Sicuro di voler mangiare " + elemento.friendly_name + "?", "Si", "No"); if (scelta) { var risposta = await a.EatAsync(elemento.id, 1); if (risposta.success) { await DisplayAlert("Fondomerende", "Snack mangiato", "Ok"); } else { await DisplayAlert("Fondomerende", "Snack non mangiato", "Ok"); } await PopupNavigation.Instance.PopAsync(); } else { await PopupNavigation.Instance.PopAsync(); } break; ////////////////////////////////////////////////////////// case "deposita": DepositServiceManager d = new DepositServiceManager(); string app = (string)index; var resultDep = await d.DepositAsync(app); if (resultDep != null) { if (resultDep.success) { await DisplayAlert("Fondomerende", "Soldi depositati con successo", "Ok"); if (Device.RuntimePlatform == Device.iOS) { DependencyService.Get <HapticFeedbackGen>().HapticFeedbackGenSuccessAsync(); } else { Vibration.Vibrate(40); await Task.Delay(100); Vibration.Vibrate(40); } await PopupNavigation.Instance.PopAsync(); } else { await DisplayAlert("Fondomerende", "I soldi non sono stati depositati", "Ok"); }; } else { await PopupNavigation.Instance.PopAsync(); } break; ///////////////////////////////////////////////// case "compra": int id = (int)index; int quantita = (int)aggiunta; bool swap = (bool)aggiunta4; SnackServiceManager x = new SnackServiceManager(); if (!swap) { var risp = await x.BuySnackAsync(id, quantita); if (risp != null) { if (risp.success) { MessagingCenter.Send(new AllSnacksPage() { }, "RefreshGetSnacks"); Vibration.Vibrate(40); await Task.Delay(100); Vibration.Vibrate(40); MessagingCenter.Send(new AllSnacksPage() { }, "RefreshGriglia"); await DisplayAlert("Fondo Merende", "Lo snack è stato comprato", "Ok"); await PopupNavigation.Instance.PopAsync(); } else { await DisplayAlert("Fondo Merende", risp.message, "Ok"); } } } else { string prezzo = (string)aggiunta2; string scadenza = (string)aggiunta3; var risp = await x.BuySnackAsync2(id, quantita, prezzo, scadenza); if (risp != null) { if (risp.success) { MessagingCenter.Send(new AllSnacksPage() { }, "RefreshGetSnacks"); Vibration.Vibrate(40); await Task.Delay(100); Vibration.Vibrate(40); MessagingCenter.Send(new AllSnacksPage() { }, "RefreshGriglia"); await DisplayAlert("Fondo Merende", "Lo snack è stato comprato", "Ok"); await PopupNavigation.Instance.PopAsync(); } else { await DisplayAlert("Fondo Merende", risp.message, "Ok"); } } } break; /////////////////////////////////////////// } } else { await DisplayAlert("Fondomerende", "Codice non presente", "Ok"); } } else { await DisplayAlert("Fondomerende", "Inserire il codice", "Ok"); } ControlloCodice.fineAzioni(); }
private async void Tgr2_Tapped(object sender, EventArgs e) { preferiticambiati = true; SnackDataDTO index = null; foreach (var item in (sender as StackLayout).Children) { if (item is Label) { var snackName = (item as Label).Text; index = result.data.snacks.Single(obj => obj.friendly_name == snackName); break; } } if (index != null) { string preferito = ""; foreach (var app in (sender as StackLayout).Children) { if (app is StackLayout) { foreach (var an in (app as StackLayout).Children) { if (an is Grid) { foreach (var ans in (an as Grid).Children) { if (ans is AnimationView) { AnimationView ap = (AnimationView)ans; if (ap.Animation == "star.json") { if (Check_FavouritesAndSet(index.id)) { ap.IsVisible = true; ap.FadeTo(1); ap.Play(); } } } if (ans is ImageButton) { ImageButton image = (ImageButton)ans; string a = ""; if (Check_Favourites(index.id)) { a = "fondomerende.image.star_fill.png"; } else { a = "fondomerende.image.star_empty.png"; } image.Source = ImageSource.FromResource(a); } } } } } } } }