async void FoodList_ItemTapped(object sender, ItemTappedEventArgs e) { FoodItem item = (FoodItem)e.Item; await Navigation.PushAsync(new SingleFoodItemPage(item)); }
public async Task AddFood(FoodItem food) { await this.foodItem.InsertAsync(food); }
public SingleFoodItemPage(FoodItem singleFood) { Title = singleFood.Text; NavigationPage.SetHasBackButton(this, false); toBoxAdd = singleFood; Button buttonBack = new Button { Text = "Back", Margin = new Thickness(5, 0, 5, 5), BackgroundColor = Color.FromHex("#1259CD"), TextColor = Color.White, HorizontalOptions = LayoutOptions.FillAndExpand }; Button buttonOrder = new Button { Text = "Add", BackgroundColor = Color.FromHex("#1259CD"), Margin = new Thickness(5, 0, 5, 5), TextColor = Color.White, HorizontalOptions = LayoutOptions.FillAndExpand }; StackLayout actions = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { buttonBack, buttonOrder } }; StackLayout information = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, Spacing = 20, Children = { new StackLayout { HorizontalOptions = LayoutOptions.FillAndExpand, Children = { new Image { HeightRequest = 200, Source = ImageSource.FromUri(new Uri(singleFood.ImageSource)), Aspect = Aspect.AspectFill } } }, new StackLayout { Padding = new Thickness(10, 0, 10, 0), Children = { new Label { FontSize = 20, FontAttributes = FontAttributes.Bold, Text = singleFood.Text }, new Label { TextColor = Color.Gray, FontSize = 12, Text = "Price: $" + singleFood.Price } } }, new Label { Margin = new Thickness(10, 0, 10, 0), FontSize = 15, Text = singleFood.description } } }; Content = new StackLayout { Children = { information, actions } }; buttonBack.Clicked += ButtonBack_Clicked; buttonOrder.Clicked += ButtonOrder_Clicked; }