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 } } } }; }
public static async void InitializeApp() { item_layout_size = screenWidth / 4; // Initialize ID Groups IDGenerator.InitializeIDGroup(itemStorageIdGenerator); IDGenerator.InitializeIDGroup(cabinetEditIdGenerator); IDGenerator.InitializeIDGroup(fridgeEditIdGenerator); IDGenerator.InitializeIDGroup(storageCellIdGenerator); IDGenerator.InitializeIDGroup(IOSNotificationIdGenerator); LocalStorageController.ResetDatabase(); // WARNING: FOR TESTING PURPOSES ONLY LocalStorageController.InitializeLocalDataBase(); // Initialize Important Grids GridManager.InitializeGrid(metaGridName, 9, 4, GridLength.Auto, GridLength.Star); GridManager.InitializeGrid(unplacedGridName, 0, 4, GridLength.Star, GridLength.Star); Console.WriteLine("ContentManger 75 is user new -=================================================================== " + ContentManager.isUserNew + ContentManager.isLocal); // Load saved data if (!isUserNew) { List <Cabinet> localCabinets = await LocalStorageController.GetTableListAsync <Cabinet>(); List <Fridge> localFridges = await LocalStorageController.GetTableListAsync <Fridge>(); List <StorageCell> localStorageCells = await LocalStorageController.GetTableListAsync <StorageCell>(); List <Item> localItems = await LocalStorageController.GetTableListAsync <Item>(); List <Cabinet> baseCabinets = new List <Cabinet>(); List <Fridge> baseFridges = new List <Fridge>(); List <StorageCell> baseStorageCells = new List <StorageCell>(); List <Item> baseItems = new List <Item>(); if (!isLocal) { // Populating list with firebase baseCabinets = (await FireBaseController.GetCabinets()).ToList().ConvertAll(o => o.Object); baseFridges = (await FireBaseController.GetFridges()).ToList().ConvertAll(o => o.Object); baseItems = (await FireBaseController.GetItems()).ToList().ConvertAll(o => o.Object); baseStorageCells = (await FireBaseController.GetStorageCells()); // Load with cloud data ContentLoader.LoadItems(baseItems); ContentLoader.LoadCabinets(baseCabinets, baseStorageCells, baseItems); ContentLoader.LoadFridges(baseFridges, baseStorageCells, baseItems); } else { // Load with local data ContentLoader.LoadItems(localItems); ContentLoader.LoadCabinets(localCabinets, localStorageCells, localItems); ContentLoader.LoadFridges(localFridges, localStorageCells, localItems); } } if (Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.Internet) { Console.WriteLine("Contentmanager 135 User Has Internet :)"); } else { Console.WriteLine("Contentmanager 138 User Has No Internet :<("); } // start UI sequence pageController.InitializePageSequence(); }
// If directSelectIndex is > -1, then the cell with this index will be displayed immediately after user enters the view. public CabinetViewPage(string name, Action <Item> deleteItemLocal, Action <Item> deleteItemBase, Action <Item> updateItemLocal, Action <Item> updateItemBase, ContentManager.StorageSelection storageSelection, int directSelectIndex = -1) { updateItemLocalEvent = updateItemLocal; updateItemBaseEvent = updateItemBase; deleteItemBaseEvent = deleteItemBase; deleteItemLocalEvent = deleteItemLocal; var titleGrid = new TopPage(name, extraReturnAction: () => { foreach (var cell in storage.GetGridCells()) { cell.GetButton().RemoveEffect(typeof(ImageTint)); } }).GetGrid(); titleGrid.HeightRequest = ContentManager.screenHeight * TopPage.top_bar_height_proportional; var backgroundImage = storageSelection == ContentManager.StorageSelection.fridge ? ContentManager.fridgeIcon : ContentManager.cabinetCellIcon; Image backgroundCell = new Image() { Source = backgroundImage, Aspect = Aspect.Fill, WidthRequest = ContentManager.screenWidth - (layout_margin * 2) }; ImageButton backButton = new ImageButton() { Source = ContentManager.backButton, BackgroundColor = Color.Transparent, WidthRequest = 100, HeightRequest = 100 }; backButton.Clicked += (obj, args) => { viewOverlay.IsVisible = false; }; // searching and sorting var sortSelectorIcon = new ImageButton() { Source = ContentManager.sortIcon, BackgroundColor = Color.Transparent }; var sortSelector = new Picker() { Margin = new Thickness(layout_margin), ItemsSource = new List <string>() { expIndicatorString, alphaIndicatorString }, Title = "Sort Order", }; var searchBar = new SearchBar() { Margin = new Thickness(layout_margin), Placeholder = "Search" }; var toolGrid = new Grid() { Margin = new Thickness(layout_margin, 0), RowDefinitions = { new RowDefinition() { Height = ContentManager.screenHeight * tool_grid_height_proportional } }, ColumnDefinitions = { new ColumnDefinition() { Width = new GridLength(5, GridUnitType.Star) }, new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) } } }; toolGrid.Children.Add(searchBar, 0, 0); toolGrid.Children.Add(sortSelectorIcon, 1, 0); toolGrid.Children.Add(sortSelector, 1, 0); viewOverlay = new AbsoluteLayout() { IsVisible = false, BackgroundColor = ContentManager.ThemeColor, WidthRequest = ContentManager.screenWidth - (layout_margin * 2), HeightRequest = ContentManager.screenHeight * 0.4, Margin = new Thickness(layout_margin, 0, layout_margin, layout_margin), Children = { backgroundCell } }; ContentManager.AddOnBackgroundChangeListener(c => viewOverlay.BackgroundColor = c); ScrollView gridContainer = new ScrollView() { WidthRequest = ContentManager.screenWidth }; gridContainer.Scrolled += (o, a) => Console.WriteLine("CabinetView 74 gridcontainer scrolled"); viewOverlay.Children.Add(gridContainer, AbsoluteLayout.GetLayoutBounds(backgroundCell), AbsoluteLayout.GetLayoutFlags(backgroundCell)); sortSelector.SelectedIndexChanged += (obj, args) => { if (currentGrid != null) { switch (sortSelector.SelectedItem) { case expIndicatorString: GridOrganizer.SortItemGrid(currentGrid, GridOrganizer.ItemSortingMode.Expiration_Close); break; case alphaIndicatorString: GridOrganizer.SortItemGrid(currentGrid, GridOrganizer.ItemSortingMode.A_Z); break; } } }; searchBar.Unfocused += (o, a) => { var currentGridChildren = currentGrid.Children.Cast <ItemLayout>(); Grid filteredGrid = GridManager.InitializeGrid(1, 4, new GridLength(ContentManager.item_layout_size, GridUnitType.Absolute), GridLength.Star); GridManager.FilterItemGrid(currentGridChildren, filteredGrid, searchBar.Text); gridContainer.Content = filteredGrid; }; // storage model var storageView = ContentManager.GetStorageView(storageSelection, name); storageView.HeightRequest = ContentManager.screenHeight * storage_height_proportional; storage = ContentManager.GetSelectedStorage(storageSelection, name); var storageViewWidth = storageSelection == ContentManager.StorageSelection.cabinet ? storage_width_proportional_cabinet : storage_width_proportional_fridge; // expiration info grid var totalItemIcon = new ImageButton() { Source = ContentManager.allItemIcon, BackgroundColor = Color.Transparent }; var totalItemLabel = new Label() { TextColor = Color.Black, FontFamily = "oswald_regular", VerticalTextAlignment = TextAlignment.Center, FontSize = main_font_size }; var expiredIcon = new ImageButton() { Source = ContentManager.expWarningIcon, BackgroundColor = Color.Transparent }; var expiredAmountLabel = new Label() { TextColor = Color.Black, FontFamily = "oswald_regular", VerticalTextAlignment = TextAlignment.Center, FontSize = main_font_size }; var almostExpiredIcon = new ImageButton() { Source = ContentManager.expWarningIcon, BackgroundColor = Color.Transparent }; var almostExpiredAmountLabel = new Label() { TextColor = Color.Black, FontFamily = "oswald_regular", VerticalTextAlignment = TextAlignment.Center, FontSize = main_font_size }; var expInfoGrid = new Grid() { RowDefinitions = { new RowDefinition(), new RowDefinition(), new RowDefinition() }, ColumnDefinitions = { new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition() { Width = new GridLength(2, GridUnitType.Star) } } }; GridManager.AddGridItem(expInfoGrid, new List <View>() { totalItemIcon, totalItemLabel, expiredIcon, expiredAmountLabel, almostExpiredIcon, almostExpiredAmountLabel }, true); var storageViewAndExpGrid = GridManager.InitializeGrid(1, 2, GridLength.Star, GridLength.Star); storageViewAndExpGrid.HeightRequest = ContentManager.screenHeight * storage_height_proportional; GridManager.AddGridItem(storageViewAndExpGrid, new List <View>() { storageView, expInfoGrid }, true); // sets the text info for all item amount, expired item amount, and almost expired item amount void calculateExpirationAmount(Grid itemLayoutGrid) { int expiredItemCount = 0; int almostExpiredItemCount = 0; foreach (ItemLayout item in itemLayoutGrid.Children) { if (item.ItemData.daysUntilExp == 0) { expiredItemCount++; } else if (item.ItemData.daysUntilExp <= 7 && item.ItemData.daysUntilExp > 0) { almostExpiredItemCount++; } } totalItemLabel.Text = "Items: " + itemLayoutGrid.Children.Count; expiredAmountLabel.Text = "Expired: " + expiredItemCount; almostExpiredAmountLabel.Text = "Almost Expired: " + almostExpiredItemCount; } foreach (var cell in storage.GetGridCells()) { // Set up listener to show overlay ImageButton button = cell.GetButton(); var grid = cell.GetItemGrid(); currentGrid = grid; grid.ChildRemoved += (o, a) => { calculateExpirationAmount(grid); }; grid.WidthRequest = WidthRequest = ContentManager.screenWidth - (layout_margin * 2); grid.Margin = new Thickness(layout_margin, 0); button.Clicked += async(obj, args) => { viewOverlay.IsVisible = true; gridContainer.Content = grid; var viewOverlayXOffset = ContentManager.screenWidth * 0.75; await viewOverlay.LinearInterpolator(viewOverlayXOffset, 200, t => viewOverlay.TranslationX = viewOverlayXOffset - t); calculateExpirationAmount(grid); grid.IsVisible = true; }; foreach (var child in grid.Children) { child.IsVisible = true; } } Console.WriteLine("Cabinet View 136 " + directSelectIndex); // Set direct view of cell if (directSelectIndex >= 0) { Console.WriteLine("CabinetView 140 View item grid children: overlayed"); viewOverlay.IsVisible = true; var cell = storage.GetGridCell(directSelectIndex); var grid = cell.GetItemGrid(); gridContainer.Content = grid; grid.IsVisible = true; cell.GetButton().AddEffect(new ImageTint() { tint = ContentManager.button_tint_color }); } Content = new StackLayout() { HeightRequest = ContentManager.screenHeight, WidthRequest = ContentManager.screenWidth, Children = { titleGrid, storageViewAndExpGrid, toolGrid, viewOverlay } }; }
public PreferencePage() { // Register background change listener BackgroundColor = ContentManager.ThemeColor; ContentManager.AddOnBackgroundChangeListener(c => BackgroundColor = c); // Title section var titleGrid = GridManager.InitializeGrid(1, 3, 50, GridLength.Star); var returnButton = new ImageButton() { Source = ContentManager.backButton, BackgroundColor = Color.Transparent }; var pageTitleLabel = new Label() { Text = "Setting", FontFamily = title_font, FontSize = 30, TextColor = Color.Black, HorizontalTextAlignment = TextAlignment.Center }; GridManager.AddGridItem(titleGrid, new List <View> { returnButton, pageTitleLabel }, false); returnButton.Clicked += (o, a) => ContentManager.pageController.ReturnToPrevious(); // User profile section var user = ContentManager.sessionUserProfile; var userProfileSection = new Grid() { RowDefinitions = { new RowDefinition() { Height = icon_size + 10 } }, ColumnDefinitions = { new ColumnDefinition() { Width = icon_size + 10 }, new ColumnDefinition() } }; userIcon = new ImageButton() { Source = user.IconImage, WidthRequest = icon_size, HeightRequest = icon_size, BackgroundColor = Color.Transparent, CornerRadius = icon_size / 2, Margin = new Thickness(5) }; ContentManager.sessionUserProfile.AddOnProfileChangedListener(u => userIcon.Source = u.IconImage); usernameLabel = new Label() { Text = user.Name, FontFamily = main_font, FontSize = 30, TextColor = Color.Black, Margin = new Thickness(0, 30, 0, 0) }; ContentManager.sessionUserProfile.AddOnProfileChangedListener(u => usernameLabel.Text = u.Name); userEmailLabel = new Label() { FontFamily = main_font, FontSize = small_font_size, TextColor = Color.Black }; ContentManager.sessionUserProfile.AddOnProfileChangedListener(u => userEmailLabel.Text = u.Email == null || u.Email.Equals("") ? "Local Account" : u.Email); userEmailLabel.Text = user.Email == null || user.Email.Equals("") ? "Local Account" : user.Email; var editProfileButton = new Button() { Text = "Edit Profile", FontFamily = main_font, FontSize = 15, CornerRadius = 2, Margin = new Thickness(0, 0, 0, 30) }; var profileDivider = new Button() { BackgroundColor = Color.Gray, HeightRequest = divider_height, Margin = new Thickness(side_margin, 0) }; editProfileButton.Clicked += (o, a) => { ContentManager.pageController.SetViewOverlay(GetEditUserView(), .75, .75, 0.5, 0.5); ScrollToImageIcon(); }; userProfileSection.Children.Add(userIcon, 0, 0); userProfileSection.Children.Add(new StackLayout() { Spacing = 0, HeightRequest = icon_size, Children = { usernameLabel, userEmailLabel, editProfileButton } }, 1, 0); // Preference section var preferenceSection = new Grid() { RowDefinitions = { new RowDefinition() { Height = standard_height }, new RowDefinition() { Height = standard_height } }, ColumnDefinitions = { new ColumnDefinition(), new ColumnDefinition() } }; var preferenceLabel = new Label() { Text = "Preferences", FontSize = title_font_size, FontFamily = title_font, TextColor = Color.Black, Margin = new Thickness(side_margin, 0) }; var themeLabel = new Label() { Text = "Background Theme", FontFamily = main_font, FontSize = main_font_size, TextColor = Color.Black, Margin = new Thickness(side_margin, 0) }; var themeCarousel = new CarouselView() { HeightRequest = theme_square_size + 70, PeekAreaInsets = new Thickness(30, 0), Margin = new Thickness(0, 0, side_margin, 0), Loop = false }; themeCarousel.ItemTemplate = new DataTemplate(() => { ImageButton image = new ImageButton() { IsEnabled = false, WidthRequest = theme_square_size, HeightRequest = theme_square_size, BorderColor = Color.Black, BorderWidth = 2, CornerRadius = theme_square_size / 2, Margin = new Thickness(20) }; image.SetBinding(Image.SourceProperty, "Image"); image.SetBinding(Image.BackgroundColorProperty, "Color"); return(image); }); List <ThemeIcon> themeList = new List <ThemeIcon>() { new ThemeIcon() { Color = Color.Wheat, Source = ContentManager.transIcon }, new ThemeIcon() { Color = Color.PapayaWhip, Source = ContentManager.transIcon }, new ThemeIcon() { Color = Color.BurlyWood, Source = ContentManager.transIcon }, new ThemeIcon() { Color = Color.LemonChiffon, Source = ContentManager.transIcon } }; themeCarousel.ItemsSource = themeList; int currentThemeIndex = 0; themeCarousel.Scrolled += (o, a) => { if (a.CenterItemIndex != currentThemeIndex) { currentThemeIndex = a.CenterItemIndex; ContentManager.ThemeColor = themeList[currentThemeIndex].Color; } }; var notifLabel = new Label() { Text = "Notification", FontFamily = main_font, FontSize = main_font_size, TextColor = Color.Black, Margin = new Thickness(side_margin, 0) }; var notifGrid = GridManager.InitializeGrid(3, 2, 50, GridLength.Star); notifGrid.Margin = new Thickness(0, 0, side_margin, 0); var oneDayNotif = new Switch() { IsToggled = true, WidthRequest = 80, OnColor = Color.Goldenrod }; var threeDayNotif = new Switch() { IsToggled = true, WidthRequest = 80, OnColor = Color.Goldenrod }; var oneWeekNotif = new Switch() { IsToggled = true, WidthRequest = 80, OnColor = Color.Goldenrod }; var oneDayLabel = new Label() { Text = "1 day", FontSize = small_font_size, FontFamily = main_font, TextColor = Color.Black, VerticalTextAlignment = TextAlignment.Center }; var threeDayLabel = new Label() { Text = "3 days", FontSize = small_font_size, FontFamily = main_font, TextColor = Color.Black, VerticalTextAlignment = TextAlignment.Center }; var oneWeekLabel = new Label() { Text = "1 week", FontSize = small_font_size, FontFamily = main_font, TextColor = Color.Black, VerticalTextAlignment = TextAlignment.Center }; oneDayNotif.Toggled += (o, a) => { ContentManager.sessionUserProfile.enableOneDayWarning = a.Value; updateUser(); }; threeDayNotif.Toggled += (o, a) => { ContentManager.sessionUserProfile.enableThreeDayWarning = a.Value; updateUser(); }; oneWeekNotif.Toggled += (o, a) => { ContentManager.sessionUserProfile.enableOneWeekWarning = a.Value; updateUser(); }; GridManager.AddGridItem(notifGrid, new List <View>() { oneDayLabel, oneDayNotif, threeDayLabel, threeDayNotif, oneWeekLabel, oneWeekNotif }, true, Utility.GridOrganizer.OrganizeMode.HorizontalRight); async void updateUser() { if (ContentManager.isLocal) { LocalStorageController.UpdateUser(ContentManager.sessionUserProfile); } else { await FireBaseController.UpdateUser(ContentManager.sessionUserProfile); } } preferenceSection.Children.Add(preferenceLabel, 0, 0); Grid.SetColumnSpan(preferenceLabel, 2); preferenceSection.Children.Add(themeLabel, 0, 1); preferenceSection.Children.Add(themeCarousel, 1, 1); preferenceSection.Children.Add(notifLabel, 0, 2); preferenceSection.Children.Add(notifGrid, 1, 2); Grid.SetRowSpan(notifGrid, 3); content = new ScrollView() { Content = new StackLayout() { HeightRequest = ContentManager.screenHeight, Spacing = 5, Children = { titleGrid, userProfileSection, profileDivider, preferenceSection } } }; Content = content; }