Beispiel #1
0
        /// <summary>
        /// Method to handle what occurs when TouchEffect is active
        /// </summary>
        /// <param name="args"></param>
        /// <param name="itemIcon"></param>
        /// <param name="currentStorageName"></param>
        /// <param name="item"></param>
        /// <param name="grid"></param>
        public static void OnScreenTouch(TouchActionEventArgs args, ItemLayout itemIcon, string currentStorageName, Action <string, ItemLayout, int> updateShelf)
        {
            var itemStorage = ContentManager.GetSelectedStorage(currentStorageName);

            itemIcon.TranslationY += args.Location.Y; itemIcon.TranslationX += args.Location.X;
            if (args.Type == TouchActionEventArgs.TouchActionType.Entered)
            {
                // re-adding the item to be at the front layer
                var pUnplacedGrid = GridManager.GetGrid(ContentManager.pUnplacedGridName);
                var index         = pUnplacedGrid.Children.IndexOf(itemIcon);
                GridManager.AddGridItemAtPosition(pUnplacedGrid, new List <View>()
                {
                    itemIcon
                }, new Vector2D <int>(index % 4, (int)(index / 4)));
            }
            if (args.Type == TouchActionEventArgs.TouchActionType.Released)
            {
                itemIcon.TranslationX = 0;
                itemIcon.TranslationY = 0;
            }


            if (args.IsInContact)
            {
                foreach (StorageCell cell in itemStorage.GetGridCells())
                {
                    cell.GetButton().RemoveEffect(typeof(ImageTint));
                }
                args.ContactView[0].AddEffect(new ImageTint()
                {
                    tint = ContentManager.button_tint_color, ImagePath = ContentManager.buttonTintImage
                });
                if (args.Type == TouchActionEventArgs.TouchActionType.Released)
                {
                    args.ContactView[0].RemoveEffect(typeof(ImageTint));

                    itemIcon.SetStoragePointer(ContentManager.GetStorageView);
                    updateShelf(currentStorageName, itemIcon, args.ContactIndex[0]);
                }
            }
            else if (args.ContactView != null)
            {
                args.ContactView[0].ToggleEffects(new ImageTint()
                {
                    tint = Color.FromRgba(100, 30, 30, 70), ImagePath = ContentManager.buttonTintImage
                }, null);
            }
        }
Beispiel #2
0
        // First copy for unplacedGrid, second for metaGrid, third is optional for partial grid
        private void SaveInput(List <ItemLayout> newItemLayouts, List <ItemLayout> newItemLayoutsCopy, List <ItemLayout> newItemLayoutsCopy2 = null)
        {
            foreach (Item _item in newItem)
            {
                ItemLayout itemLayout = new ItemLayout(ContentManager.item_layout_size, ContentManager.item_layout_size, _item)
                                        .AddMainImage()
                                        .AddExpirationMark()
                                        .AddTitle()
                                        .AddInfoIcon();
                Console.WriteLine("AddView 443 item name " + _item.Name);
                ItemLayout itemLayoutCopy = new ItemLayout(ContentManager.item_layout_size, ContentManager.item_layout_size, _item)
                                            .AddMainImage()
                                            .AddExpirationMark()
                                            .AddTitle()
                                            .AddInfoIcon();

                ItemLayout itemLayoutCopy2 = new ItemLayout(ContentManager.item_layout_size, ContentManager.item_layout_size, _item)
                                             .AddMainImage()
                                             .AddExpirationMark()
                                             .AddTitle()
                                             .AddInfoIcon();

                newItemLayouts.Add(itemLayout);
                newItemLayoutsCopy.Add(itemLayoutCopy);
                if (newItemLayoutsCopy2 != null)
                {
                    newItemLayoutsCopy2.Add(itemLayoutCopy2);
                }
                ContentManager.MetaItemBase.Add(_item.ID, itemLayout);
                ContentManager.UnplacedItemBase.Add(_item.ID, itemLayoutCopy);
            }


            GridManager.AddGridItem(GridManager.GetGrid(ContentManager.metaGridName), newItemLayouts, false);
            GridManager.AddGridItem(GridManager.GetGrid(ContentManager.unplacedGridName), newItemLayoutsCopy, false);
            Console.WriteLine("AddView 471 partial unplaced grid children count " + newItemLayoutsCopy2.Count);
        }
Beispiel #3
0
        public UnplacedPage(Action <Item> localUnplacedEvent, Action <Item> baseUnplaceEvent, Action <Item> deleteItemLocal, Action <Item> deleteItemBase)
        {
            var titleGrid    = new TopPage("Items", useReturnButton: false).GetGrid();
            var addNewButton = new ImageButton()
            {
                Source = ContentManager.addIcon, BackgroundColor = Color.Transparent, Margin = new Thickness(side_margin, between_margin)
            };

            // Renewing contents in meta grid
            metaGrid = GridManager.GetGrid(ContentManager.metaGridName);
            GridManager.AddGridItem(metaGrid, ContentManager.MetaItemBase.Values, true);

            var addView = new AddView(localUnplacedEvent, baseUnplaceEvent, "", false);

            searchAllBar = new SearchBar()
            {
                Margin = new Thickness(side_margin, 0)
            };
            searchAllBar.Text       = ContentManager.defaultSearchAllBarText;
            searchAllBar.TextColor  = Color.Black;
            searchAllBar.Focused   += (obj, args) => searchAllBar.Text = "";
            searchAllBar.Unfocused += (obj, args) => { if (searchAllBar.Text.Length == 0)
                                                       {
                                                           searchAllBar.Text = ContentManager.defaultSearchAllBarText;
                                                       }
            };
            searchAllBar.Unfocused += (obj, args) => GridManager.FilterItemGrid(ContentManager.MetaItemBase.Values, metaGrid, searchAllBar.Text);
            addNewButton.Clicked   += (obj, args) => { addView.ResetForm(); ContentManager.pageController.ToAddView(addView); };

            var sortSelectorIcon = new Image()
            {
                Source = ContentManager.sortIcon
            };
            var sortSelector = new Picker()
            {
                Margin      = new Thickness(side_margin, between_margin),
                ItemsSource = new List <string>()
                {
                    expIndicatorString, alphaIndicatorString
                },
            };

            sortSelector.SelectedIndexChanged += (obj, args) =>
            {
                switch (sortSelector.SelectedItem)
                {
                case expIndicatorString: GridOrganizer.SortItemGrid(metaGrid, GridOrganizer.ItemSortingMode.Expiration_Close); break;

                case alphaIndicatorString: GridOrganizer.SortItemGrid(metaGrid, GridOrganizer.ItemSortingMode.A_Z); break;
                }
            };


            gridScroll = new ScrollView()
            {
                Margin = new Thickness(side_margin),
                VerticalScrollBarVisibility = ScrollBarVisibility.Always,
                HeightRequest = Height * 0.8,
                Content       = metaGrid
            };

            AbsoluteLayout.SetLayoutBounds(titleGrid, new Rectangle(0, 0, 1, TopPage.top_bar_height_proportional));
            AbsoluteLayout.SetLayoutFlags(titleGrid, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(searchAllBar, new Rectangle(0, 0.13, 0.8, .1));
            AbsoluteLayout.SetLayoutFlags(searchAllBar, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(addNewButton, new Rectangle(0, .25, 100, 100));
            AbsoluteLayout.SetLayoutFlags(addNewButton, AbsoluteLayoutFlags.PositionProportional);
            AbsoluteLayout.SetLayoutBounds(sortSelector, new Rectangle(1, 0.13, .2, .1));
            AbsoluteLayout.SetLayoutFlags(sortSelector, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(sortSelectorIcon, AbsoluteLayout.GetLayoutBounds(sortSelector));
            AbsoluteLayout.SetLayoutFlags(sortSelectorIcon, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(gridScroll, new Rectangle(0, 1, 1, .625));
            AbsoluteLayout.SetLayoutFlags(gridScroll, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(addView, new Rectangle(0, 0, 1, 1));
            AbsoluteLayout.SetLayoutFlags(addView, AbsoluteLayoutFlags.All);
            content = new AbsoluteLayout()
            {
                Children =
                {
                    titleGrid,
                    searchAllBar,
                    addNewButton,
                    sortSelectorIcon,
                    sortSelector,
                    gridScroll
                }
            };

            Content = content;
        }
Beispiel #4
0
 public void UpdateLayout()
 {
     metaGrid = GridManager.GetGrid(ContentManager.metaGridName);
     GridManager.AddGridItem(metaGrid, ContentManager.MetaItemBase.Values, true);
 }
Beispiel #5
0
        // DirectGridFootIndex: when page loads, partial grids directly goes to the set of items with the first item being this index.
        public CabinetAddPage(string _storageName, int directGridFootIndex = 0)
        {
            storageName = _storageName;

            storageView = ContentManager.GetStorageView(storageName);
            storageView.WidthRequest    = ContentManager.screenWidth;
            storageView.HeightRequest   = ContentManager.screenHeight * .75;
            storageView.VerticalOptions = LayoutOptions.EndAndExpand;
            animateStorage();

            async void animateStorage()
            {
                await storageView.LinearInterpolator(animation_offestX, 200, (d) => { storageView.TranslationY = animation_offestX - d; });
            }

            //-- set up unplaced grid
            unplacedGrid               = GridManager.GetGrid(ContentManager.unplacedGridName);
            partialUnplacedGrid        = GridManager.InitializeGrid(ContentManager.pUnplacedGridName, 2, 4, GridLength.Star, GridLength.Star);
            partialUnplacedGrid.Margin = new Thickness(grid_margin, 0);
            // add listener to set TouchEffect for each new item added. If grid already exist
            partialUnplacedGrid.ChildAdded += (o, v) =>
            {
                EffectManager.UpdateScreenTouchBounds(v.Element as ItemLayout, storageName, UpdateShelf);
            };
            // Add listener to remove partial unplaced grid child
            unplacedGrid.ChildRemoved += (o, a) =>
            {
                foreach (ItemLayout child in partialUnplacedGrid.Children)
                {
                    if ((a.Element as ItemLayout).ItemData.ID == child.ItemData.ID)
                    {
                        partialUnplacedGrid = GridManager.ConstrainGrid(unplacedGrid, gridFootIndex, gridFootIndex + 7, partialUnplacedGrid, itemLayoutCopier, true);
                        break;
                    }
                }
            };
            Console.WriteLine("CabinetAddPage 42 Unplaced children length " + unplacedGrid.Children.Count);
            // initialize grid by constraining UnplacedGrid and Converter
            itemLayoutCopier = (v) =>
            {
                return(new ItemLayout(50, 50, (v as ItemLayout).ItemData)
                       .AddMainImage()
                       .AddExpirationMark()
                       .AddTitle()
                       .AddInfoIcon());
            };
            partialUnplacedGrid = GridManager.ConstrainGrid(GridManager.GetGrid(ContentManager.unplacedGridName), directGridFootIndex, directGridFootIndex + 7, partialUnplacedGrid, itemLayoutCopier, true);
            addView             = new AddView(LocalStorageController.AddItem, FireBaseController.SaveItem, storageName, true, partialUnplacedGrid);

            // title grid
            var titleGrid = new TopPage(_storageName, () =>
            {
                foreach (ItemLayout child in partialUnplacedGrid.Children)
                {
                    child.iconImage.RemoveEffect(typeof(ScreenTouch));
                }
                foreach (StorageCell child in ContentManager.GetSelectedStorage(storageName).GetGridCells())
                {
                    child.GetButton().RemoveEffect(typeof(ImageTint));
                }
                GridManager.RemoveGrid(ContentManager.pUnplacedGridName);
            }).GetGrid();


            gridFootIndex = directGridFootIndex;
            var gridPageSelectGrid = new Grid()
            {
                Margin            = new Thickness(grid_margin, 0),
                ColumnDefinitions =
                {
                    new ColumnDefinition()
                    {
                        Width = 50
                    },
                    new ColumnDefinition()
                    {
                        Width = 30
                    },
                    new ColumnDefinition()
                    {
                        Width = 30
                    },
                    new ColumnDefinition()
                    {
                        Width = GridLength.Auto
                    }
                }
            };
            var nextPage = new ImageButton()
            {
                Source = ContentManager.countIcon
            };

            nextPage.Clicked += (obj, args) =>
            {
                Console.WriteLine("CabinetAddPage grid foot index " + gridFootIndex);
                gridFootIndex      += 7;
                partialUnplacedGrid = GridManager.ConstrainGrid(unplacedGrid, gridFootIndex, gridFootIndex + 7, partialUnplacedGrid, itemLayoutCopier, true);
            };
            var lastPage = new ImageButton()
            {
                Source = ContentManager.countIcon, Rotation = 180
            };

            lastPage.Clicked += (obj, args) =>
            {
                Console.WriteLine("CabinetAddPage grid foot index " + gridFootIndex);
                gridFootIndex       = gridFootIndex - 7 < 0 ? 0 : gridFootIndex - 7;
                partialUnplacedGrid = GridManager.ConstrainGrid(unplacedGrid, gridFootIndex, gridFootIndex + 7, partialUnplacedGrid, itemLayoutCopier, true);
            };
            var addNewButton = new ImageButton()
            {
                Source = ContentManager.addIcon, BackgroundColor = Color.Transparent
            };

            addNewButton.Clicked += (obj, args) => { addView.ResetForm(); ContentManager.pageController.ToAddView(addView); };
            var searchBar = new SearchBar()
            {
                Text = ContentManager.defaultSearchAllBarText, MinimumWidthRequest = 300
            };

            searchBar.Focused   += (obj, args) => searchBar.Text = "";
            searchBar.Unfocused += (obj, args) =>
            {
                if (searchBar.Text.Length == 0)
                {
                    searchBar.Text = ContentManager.defaultSearchAllBarText;
                }
                GridManager.FilterItemGrid(ContentManager.UnplacedItemBase.Values, partialUnplacedGrid, searchBar.Text);
            };

            gridPageSelectGrid.Children.Add(lastPage, 1, 0);
            gridPageSelectGrid.Children.Add(nextPage, 2, 0);
            gridPageSelectGrid.Children.Add(addNewButton, 0, 0);
            gridPageSelectGrid.Children.Add(searchBar, 3, 0);

            pageContainer = new AbsoluteLayout();
            pageContainer.BackgroundColor = ContentManager.ThemeColor;
            ContentManager.AddOnBackgroundChangeListener(c => pageContainer.BackgroundColor = c);
            pageContainer.Children.Add(titleGrid, new Rectangle(0, 0, 1, TopPage.top_bar_height_proportional), AbsoluteLayoutFlags.All);
            pageContainer.Children.Add(storageView, new Rectangle(1, 1, 1, .5), AbsoluteLayoutFlags.All);
            pageContainer.Children.Add(gridPageSelectGrid, new Rectangle(0, .12, 1, .09), AbsoluteLayoutFlags.All);
            pageContainer.Children.Add(partialUnplacedGrid, new Rectangle(0, .28, 1, .3), AbsoluteLayoutFlags.All);

            Content = new AbsoluteLayout()
            {
                Children =
                {
                    pageContainer
                }
            };
            AbsoluteLayout.SetLayoutBounds(pageContainer, new Rectangle(0, 0, 1, 1));
            AbsoluteLayout.SetLayoutFlags(pageContainer, AbsoluteLayoutFlags.All);
        }
Beispiel #6
0
        public InfoView(Item item)
        {
            // Calculating sizes
            button_width = ContentManager.screenWidth * info_view_width_proportional / 3;
            Grid mainGrid = new Grid()
            {
                HeightRequest  = ContentManager.screenHeight * info_view_height_proportional * 0.75,
                Margin         = new Thickness(side_margin, 0),
                RowDefinitions =
                {
                    new RowDefinition()
                    {
                        Height = GridLength.Star
                    },
                    new RowDefinition()
                    {
                        Height = 1
                    },
                    new RowDefinition()
                    {
                        Height = GridLength.Star
                    },
                    new RowDefinition()
                    {
                        Height = 1
                    },
                    new RowDefinition()
                    {
                        Height = GridLength.Star
                    },
                    new RowDefinition()
                    {
                        Height = 1
                    },
                    new RowDefinition()
                    {
                        Height = GridLength.Star
                    },
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition()
                    {
                        Width = GridLength.Star
                    },
                    new ColumnDefinition()
                    {
                        Width = GridLength.Star
                    },
                }
            };

            var closeButton = new Button()
            {
                BackgroundColor   = Color.Gray, Text = "X", TextColor = Color.Black,
                HorizontalOptions = LayoutOptions.End, WidthRequest = close_button_size, HeightRequest = close_button_size, CornerRadius = 0, Padding = 0
            };

            closeButton.Clicked += (o, a) => ContentManager.pageController.RemoveInfoView(this);
            var itemName = new Label()
            {
                Text = item.Name, TextColor = Color.Black, FontSize = 25, HorizontalTextAlignment = TextAlignment.Center
            };
            var itemNameDivider = new BoxView()
            {
                HeightRequest = 1, WidthRequest = ContentManager.screenWidth * 0.5, Color = Color.Gray
            };
            var itemImage = new Image()
            {
                Source = item.Icon.Substring(6), WidthRequest = 120, HeightRequest = 120, Aspect = Aspect.Fill, HorizontalOptions = LayoutOptions.Center
            };

            var expirationDateTitle = new Label()
            {
                Text = "Expiration Date:", TextColor = Color.Black, FontSize = grid_font_size
            };
            var expDateText         = item.daysUntilExp < 0 ? "?" : item.expMonth + "/" + item.expDay + "/" + item.expYear;
            var expirationDateLabel = new Label()
            {
                Text = expDateText, TextColor = Color.Black, FontSize = grid_font_size, HorizontalTextAlignment = TextAlignment.End
            };
            var expirationDateDivider = new BoxView()
            {
                HeightRequest = 1, WidthRequest = ContentManager.screenWidth * 0.5, Color = Color.Gray
            };

            var daysToExpString       = item.daysUntilExp < 0 ? "?" : item.daysUntilExp.ToString();
            var daysToExpirationTitle = new Label()
            {
                Text = "Days Until Expiration:", TextColor = Color.Black, FontSize = grid_font_size
            };
            var daysToExpirationLabel = new Label()
            {
                Text = daysToExpString, TextColor = Color.Black, FontSize = grid_font_size, HorizontalTextAlignment = TextAlignment.End
            };
            var expirationDayDivider = new BoxView()
            {
                HeightRequest = 1, WidthRequest = ContentManager.screenWidth * 0.5, Color = Color.Gray
            };

            var amountTitle = new Label()
            {
                Text = "Amount: ", TextColor = Color.Black, FontSize = grid_font_size
            };
            var amountLabel = new Label()
            {
                Text = item.Amount.ToString(), TextColor = Color.Black, FontSize = grid_font_size, WidthRequest = 30, HorizontalTextAlignment = TextAlignment.End
            };
            var amountDivider = new BoxView()
            {
                HeightRequest = 1, WidthRequest = ContentManager.screenWidth * 0.5, Color = Color.Gray
            };

            var locationTitle = new Label()
            {
                Text = "Location:", TextColor = Color.Black, FontSize = grid_font_size
            };
            var locationLabel = new Label()
            {
                TextColor = Color.Black, FontSize = grid_font_size, HorizontalTextAlignment = TextAlignment.End
            };

            locationLabel.Text = item.Stored ? item.StorageName : "Not Placed";

            mainGrid.Children.Add(expirationDateTitle, 0, 0);
            mainGrid.Children.Add(expirationDateLabel, 1, 0);
            mainGrid.Children.Add(expirationDateDivider, 0, 1);
            Grid.SetColumnSpan(expirationDateDivider, 2);
            mainGrid.Children.Add(daysToExpirationTitle, 0, 2);
            mainGrid.Children.Add(daysToExpirationLabel, 1, 2);
            mainGrid.Children.Add(expirationDayDivider, 0, 3);
            Grid.SetColumnSpan(expirationDayDivider, 2);
            mainGrid.Children.Add(amountTitle, 0, 4);
            mainGrid.Children.Add(amountLabel, 1, 4);
            mainGrid.Children.Add(amountDivider, 0, 5);
            Grid.SetColumnSpan(amountDivider, 2);
            mainGrid.Children.Add(locationTitle, 0, 6);
            mainGrid.Children.Add(locationLabel, 1, 6);

            var toStorageViewButton = new Button()
            {
                BackgroundColor   = Color.FromRgba(0, 100, 20, 80), Text = "View In Storage", TextColor = Color.Black,
                HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.EndAndExpand, Margin = new Thickness(0, vertical_margin)
            };
            var addButton = new Button()
            {
                BackgroundColor   = Color.FromRgba(0, 100, 0, 80),
                Text              = "Add",
                WidthRequest      = button_width,
                TextColor         = Color.Black,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.EndAndExpand,
                Margin            = new Thickness(0, 0, 0, vertical_margin)
            };
            var consumeButton = new Button()
            {
                BackgroundColor   = Color.FromRgba(100, 20, 0, 80),
                Text              = "Consume",
                WidthRequest      = button_width,
                TextColor         = Color.Black,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.EndAndExpand,
                Margin            = new Thickness(0, 0, 0, vertical_margin)
            };

            toStorageViewButton.BackgroundColor = item.Stored ? Color.FromRgba(0, 100, 20, 80) : Color.Gray;
            toStorageViewButton.Clicked        += (obj, args) =>
            {
                if (item.Stored)
                {
                    ContentManager.pageController.RemoveInfoView(this);
                    if (!ContentManager.pageController.IsOnPage <CabinetViewPage>())
                    {
                        ContentManager.pageController.ToViewItemPage(item.StorageName, item.StorageCellIndex, item.StorageType);
                    }
                }
            };

            var gradientLineBrush = new LinearGradientBrush(new GradientStopCollection()
            {
                new GradientStop(Color.Transparent, 0.1f),
                new GradientStop(Color.FromRgba(0, 255, 0, 80), 0.5f),
                new GradientStop(Color.Transparent, 1)
            }, new Point(0, 0), new Point(0, 1));
            var gradientLine = new BoxView()
            {
                Background    = gradientLineBrush,
                HeightRequest = 200,
            };



            void animateAmountChange(bool add)
            {
                // Get x, y, w, h in proprotional terms.
                var dhGradientLine = ContentManager.screenHeight - gradientLine.HeightRequest;
                var y = ContentManager.screenHeight * info_view_height_proportional / 2 + ContentManager.screenHeight / 2 - gradientLine.HeightRequest;

                y /= dhGradientLine;
                var h             = gradientLine.HeightRequest / ContentManager.screenHeight;
                var gradientLineY = add ? y : 0;

                ContentManager.pageController.OverlayAnimation(gradientLine, new Rect(0.5, gradientLineY, info_view_width_proportional, h),
                                                               ViewExtensions.LinearInterpolator(gradientLine, ContentManager.screenHeight * info_view_height_proportional - gradientLine.HeightRequest, 500, t => gradientLine.TranslationY = add ? -t : t, Easing.CubicInOut));

                var amountLabelBounds = amountLabel.Bounds;
                var amountChangeLabel = new Label()
                {
                    TextColor = Color.Gray, FontSize = 40, FontAttributes = FontAttributes.Bold, WidthRequest = 50, HeightRequest = 50, HorizontalTextAlignment = TextAlignment.End
                };

                amountChangeLabel.Text = add ? "+1" : "-1";
                var dwAmount = ContentManager.screenWidth - amountChangeLabel.WidthRequest;
                var dhAmount = ContentManager.screenHeight - amountChangeLabel.HeightRequest;

                ContentManager.pageController.OverlayAnimation(amountChangeLabel,
                                                               new Rect(amountLabel.GetAbsolutePosition().X / dwAmount, amountLabel.GetAbsolutePosition().Y / dhAmount, amountChangeLabel.WidthRequest / ContentManager.screenWidth, amountChangeLabel.HeightRequest / ContentManager.screenHeight),
                                                               amountChangeLabel.LinearInterpolator(80, 2000, t => { amountChangeLabel.TranslationY = -t; amountChangeLabel.Opacity = 1 - t / 100; }, Easing.CubicOut),
                                                               () => { amountChangeLabel.TranslationY = 0; });
            }

            addButton.Clicked += (obj, args) =>
            {
                // add amount
                item.Amount++;
                // animate
                animateAmountChange(true);
                amountLabel.Text = item.Amount.ToString();

                // Save data locally or to cloud
                if (ContentManager.isLocal)
                {
                    LocalStorageController.UpdateItem(item);
                }
                else
                {
                    FireBaseController.SaveItem(item);
                }
            };
            consumeButton.Clicked += (obj, args) =>
            {
                // Subtract amount
                item.Amount--;
                // If not fully consumed, keep track of it
                if (item.Amount > 0)
                {
                    animateAmountChange(false);
                    amountLabel.Text = item.Amount.ToString();
                    // Save data locally or to cloud
                    if (ContentManager.isLocal)
                    {
                        LocalStorageController.UpdateItem(item);
                    }
                    else
                    {
                        FireBaseController.SaveItem(item);
                    }
                }
                // If fully consumed, remove it.
                else
                {
                    // If item not stored, remove it from unplaced grid
                    if (!item.Stored)
                    {
                        var itemLayoutUnplaced = ContentManager.UnplacedItemBase[item.ID];
                        var unplacedGrid       = GridManager.GetGrid(ContentManager.unplacedGridName);
                        if (unplacedGrid.Children.Contains(itemLayoutUnplaced))
                        {
                            unplacedGrid.Children.Remove(itemLayoutUnplaced);
                        }
                    }
                    ContentManager.UnplacedItemBase.Remove(item.ID);

                    // Remove item from meta grid
                    var itemLayoutMeta = ContentManager.MetaItemBase[item.ID];
                    var metaGrid       = GridManager.GetGrid(ContentManager.metaGridName);
                    ContentManager.MetaItemBase.Remove(item.ID);
                    GridManager.AddGridItem(metaGrid, ContentManager.MetaItemBase.Values, true);

                    // Exit out of infoView
                    ContentManager.pageController.RemoveInfoView(this);

                    // Save data locally and to cloud
                    if (ContentManager.isLocal)
                    {
                        LocalStorageController.DeleteItem(item);
                    }
                    else
                    {
                        FireBaseController.DeleteItem(item);
                    }

                    // If item is stored, delete it from storage
                    if (item.Stored)
                    {
                        // Delete item from storage cell
                        var gridCell = item.StorageType == ContentManager.fridgeStorageType ? ContentManager.FridgeMetaBase[item.StorageName].GetGridCell(item.StorageCellIndex) :
                                       ContentManager.CabinetMetaBase[item.StorageName].GetGridCell(item.StorageCellIndex);
                        var         cellGrid  = gridCell.GetItemGrid();
                        List <View> childList = cellGrid.Children.ToList();
                        foreach (ItemLayout child in cellGrid.Children)
                        {
                            if (item.ID == child.ItemData.ID)
                            {
                                gridCell.RemoveItem(child);
                                break;
                            }
                        }
                        //Update storage cell children
                        //gridCell.AddItem(childList);
                    }
                }
            };

            pageContainer = new StackLayout()
            {
                BackgroundColor = Color.Beige,
                Children        = { closeButton, itemName, itemNameDivider, itemImage, mainGrid, toStorageViewButton, addButton,
                                    new StackLayout()
                                    {
                                        Orientation = StackOrientation.Horizontal,
                                        Children    = { addButton, consumeButton }
                                    } }
            };
        }