public IBUAddHopPage(bool nativeCheck) { _nativeCheck = nativeCheck; //Set the title on the navigation bar to the selected hop Title = "Add Hops"; //Set the StyleId for Xamarin Test Cloud StyleId = "AddHopsPage"; //Create generic views from "Views" folder StackLayout hopHeader = new HopListHeader(); hopList = new HopListView { StyleId = "hopListView" }; search = new SearchBar { StyleId = "searchBar", Placeholder = "Search Hops", HorizontalOptions = LayoutOptions.FillAndExpand }; cancel = new HopThemedButton() { StyleId = "cancelButton", Text = "Cancel", WidthRequest = (double)(App.ScreenWidth), BorderColor = Color.Transparent, BorderRadius = 0, HeightRequest = 50, Font = Font.SystemFontOfSize(NamedSize.Large) }; Content = new StackLayout { Spacing = 0, Children = { search, hopHeader, hopList, cancel } }; }
public StartPage () { //Set the title on the navigation bar to the selected hop Title = "Pick UI View"; //Set the StyleId for Xamarin Test Cloud StyleId = "PickUIViewPage"; //Create page to separate XAML and Programmatic parts of application programmatic = new HopThemedButton { StyleId = "programmaticButton", Text = "Programmatic", HeightRequest = (double)(App.ScreenHeight * 0.1), WidthRequest = (double)(App.ScreenWidth * 0.8) }; xaml = new HopThemedButton { StyleId = "xamlButton", Text = "XAML", HeightRequest = (double)(App.ScreenHeight * 0.1), WidthRequest = (double)(App.ScreenWidth * 0.8) }; customRenderedUITableView = new HopThemedButton { StyleId = "UITableViewControllerButton", Text = "UITableViewController example", HeightRequest = (double)(App.ScreenHeight * 0.1), WidthRequest = (double)(App.ScreenWidth * 0.8) }; Content = new StackLayout { HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, Children = { programmatic, xaml, customRenderedUITableView } }; }
// ContentView_IBUCalcTableView table; public UITableViewController_IBUCalculatorPage() { //Set the title on the navigation bar to the selected hop Title = "IBU Calculator"; //Set the StyleId for Xamarin Test Cloud StyleId = "IBUCalculatorPage"; ContentView_IBUCalcTableView table = new ContentView_IBUCalcTableView { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Transparent, }; //Add hop button HopThemedButton addEntry = new HopThemedButton { Text = "Add Hop", WidthRequest = Device.OnPlatform(200, 250, 250), }; //Create hop gravity and volume controls HopThemedNumberEntry boilGravityEntry = new HopThemedNumberEntry { Text = "1.050" }; HopThemedNumberEntry boilVolumeEntry = new HopThemedNumberEntry { Text = "0" }; //Create gravity and volume steppers GreenStepper gravityStepper = new GreenStepper { Minimum = 1.000, Maximum = 1.120, Increment = .001, Value = Convert.ToDouble(boilGravityEntry.Text), }; GreenStepper volumeStepper = new GreenStepper { Minimum = 0, Maximum = 1000, Increment = 1, Value = Convert.ToDouble(boilVolumeEntry.Text), }; //Create grid to add all of the hop gravity and volume controls Grid VolumeAndGravityGrid = new Grid { ColumnDefinitions = { new ColumnDefinition { Width = 120 }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) } }, }; //Boil Gravity Grid Row VolumeAndGravityGrid.Children.Add( new Label() { Text = "Boil Gravity", TextColor = Color.White }, 0, 0 ); VolumeAndGravityGrid.Children.Add(boilGravityEntry, 1, 0); VolumeAndGravityGrid.Children.Add(gravityStepper, 2, 0); //Volume Grid Row VolumeAndGravityGrid.Children.Add( new Label() { Text = "Boil Volume", TextColor = Color.White }, 0, 1 ); VolumeAndGravityGrid.Children.Add(boilVolumeEntry, 1, 1); VolumeAndGravityGrid.Children.Add(volumeStepper, 2, 1); VolumeAndGravityGrid.Padding = new Thickness(0, 0, 10, 0); //Create calculated IBU stack HopThemedButton calculateIBUButton = new HopThemedButton { Text = "Calculate IBU", WidthRequest = Device.OnPlatform(200, 250, 250), }; ThemedLabel IBU = new ThemedLabel { Text = "Calculated IBU:", }; ThemedLabel calculatedIBULabel = new ThemedLabel { Text = "0", }; StackLayout IBULabels = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { IBU, calculatedIBULabel } }; //Create calculated stacklayout StackLayout calculatedStackLayout = new StackLayout { BackgroundColor = Device.OnPlatform <Color>(Color.Default, Color.Black, Color.Default), VerticalOptions = LayoutOptions.End, Children = { calculateIBUButton, IBULabels }, }; //Stack the contents of the page StackLayout pageContents = new StackLayout { Padding = new Thickness(5, 5, 5, 0), Children = { table, addEntry, VolumeAndGravityGrid, calculatedStackLayout }, }; //Wrap the content in a scrollview Content = new ScrollView { Content = pageContents }; //Stepper Controls // Connects Gravity Stepper Changes to Entry gravityStepper.ValueChanged += (sender, e) => { boilGravityEntry.Text = gravityStepper.Value.ToString(); }; // Connects Volume Steppper Changes to Entry volumeStepper.ValueChanged += (sender, e) => { boilVolumeEntry.Text = volumeStepper.Value.ToString(); }; // Connects Gravity Entry to Stepper Value boilGravityEntry.TextChanged += (sender, e) => { if (boilGravityEntry.Text != "") { gravityStepper.Value = Convert.ToDouble(boilGravityEntry.Text); } }; boilGravityEntry.Focused += (object sender, FocusEventArgs e) => { placeholder = boilGravityEntry.Text; boilGravityEntry.Text = ""; }; boilGravityEntry.Unfocused += (object sender, FocusEventArgs e) => { if (boilGravityEntry.Text == "") { boilGravityEntry.Text = placeholder; } }; //Connects Volume Entry to Stepper boilVolumeEntry.TextChanged += (sender, e) => { if (boilVolumeEntry.Text != "") { volumeStepper.Value = Convert.ToDouble(boilVolumeEntry.Text); } }; boilVolumeEntry.Focused += (object sender, FocusEventArgs e) => { placeholder = boilVolumeEntry.Text; boilVolumeEntry.Text = ""; }; boilVolumeEntry.Unfocused += (object sender, FocusEventArgs e) => { if (boilVolumeEntry.Text == "") { boilVolumeEntry.Text = placeholder; } }; //Connects Add Entry to Adding a hop page to TableView addEntry.Clicked += (sender, e) => { Navigation.PushAsync(new IBUAddHopPage(true)); }; //Calculate IBU button calculateIBUButton.Clicked += (sender, e) => { //Create HopsToBeCalculated model to pass into calculator HopsToBeCalculated hopsToCalculate = new HopsToBeCalculated { BoilGravity = boilGravityEntry, BoilVolume = boilVolumeEntry, CalculatedIBU = calculatedIBULabel }; //Pass in the HopsToBeCalculated model and send to the native UITableView MessagingCenter.Send <UITableViewController_IBUCalculatorPage, HopsToBeCalculated> (this, "CalculateIBU", hopsToCalculate); }; }
public BeerStyleDetailScrollPage(BeerStyle selected) { _selected = selected; //Set the title on the navigation bar to the selected hop Title = selected.Style; //Set the StyleId for Xamarin Test Cloud StyleId = selected.Style + "Page"; //Create button to navigate to commercial beers of beer style commercialBeers = new HopThemedButton { StyleId = "commercialBeersOfThisStyleButton", Text = "Commercial Beers of this style", WidthRequest = Device.OnPlatform( (double)(App.ScreenWidth), (double)(App.ScreenWidth), (double)(App.ScreenWidth * 0.8)), BorderColor = Color.Transparent, BorderRadius = Device.OnPlatform(0, 0, 0), HeightRequest = 50, Font = Font.SystemFontOfSize(NamedSize.Large) }; //Create Aroma labels and details CenteredBoldWhiteTextColorLabel aromaLabel = new CenteredBoldWhiteTextColorLabel { Text = "Aroma" }; WhiteTextColorLabel aroma = new WhiteTextColorLabel { Text = selected.Aroma }; //Create Appearance labels and details CenteredBoldWhiteTextColorLabel appearanceLabel = new CenteredBoldWhiteTextColorLabel { Text = "Appearance" }; WhiteTextColorLabel appearance = new WhiteTextColorLabel { Text = selected.Appearance }; //Create Flavor labels and details CenteredBoldWhiteTextColorLabel flavorLabel = new CenteredBoldWhiteTextColorLabel { Text = "Flavor" }; WhiteTextColorLabel flavor = new WhiteTextColorLabel { Text = selected.Flavor }; //Create Ingredients labels and details CenteredBoldWhiteTextColorLabel ingredientsLabel = new CenteredBoldWhiteTextColorLabel { Text = "Ingredients" }; WhiteTextColorLabel ingredients = new WhiteTextColorLabel { Text = selected.Ingredients }; //Create Comments labels and details CenteredBoldWhiteTextColorLabel commentsLabel = new CenteredBoldWhiteTextColorLabel { Text = "Comments" }; WhiteTextColorLabel comments = new WhiteTextColorLabel { Text = selected.Comments }; //Create srm Label CenteredBoldWhiteTextColorLabel srmColorLabel = new CenteredBoldWhiteTextColorLabel { Text = "Beer Color Range" }; //Stack all of the labels in a StackLayout StackLayout description = new StackLayout { Orientation = StackOrientation.Vertical, Children = { aromaLabel, aroma, appearanceLabel, appearance, flavorLabel, flavor, ingredientsLabel, ingredients, commentsLabel, comments, srmColorLabel } }; //Create Labels to label beer style specifications WhiteTextColorLabel ibuLabel = new WhiteTextColorLabel { Text = "IBU:", HorizontalOptions = LayoutOptions.End }; WhiteTextColorLabel ogLabel = new WhiteTextColorLabel { Text = "Original Gravity:", HorizontalOptions = LayoutOptions.End }; WhiteTextColorLabel fgLabel = new WhiteTextColorLabel { Text = "Final Gravity:", HorizontalOptions = LayoutOptions.End }; WhiteTextColorLabel abvLabel = new WhiteTextColorLabel { Text = "Alcohol Percent:", HorizontalOptions = LayoutOptions.End }; //Stack all of the labels vertically to create a left half StackLayout StackLayout labels = new StackLayout { Orientation = StackOrientation.Vertical, Children = { ibuLabel, ogLabel, fgLabel, abvLabel } }; //Create labels to hold the beer style specifications WhiteTextColorLabel ibu = new WhiteTextColorLabel { Text = selected.IBUs }; WhiteTextColorLabel og = new WhiteTextColorLabel { Text = selected.OG }; WhiteTextColorLabel fg = new WhiteTextColorLabel { Text = selected.FG }; WhiteTextColorLabel abv = new WhiteTextColorLabel { Text = selected.ABV + " %" }; //Stack all of the specs vertically to create a right half StackLayout StackLayout values = new StackLayout { Orientation = StackOrientation.Vertical, Children = { ibu, og, fg, abv } }; //Stack the two vertical layouts together to align the labels to the specifications StackLayout specs = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.CenterAndExpand, Children = { labels, values } }; //split the srm range (ex. 10 - 24) to create a low SRM and High SRM. //The SRM calculator will use this string to change the background color of the low/high SRM labels string[] srmRange = selected.SRM.Split('-'); //Low SRM label created to pass into SRMColorCalculator WhiteTextColorLabel srmLow = new WhiteTextColorLabel { StyleId = "lowSRMLabel", Text = "Low SRM : " + srmRange [0], HorizontalOptions = LayoutOptions.CenterAndExpand, HeightRequest = 30, WidthRequest = 150, YAlign = TextAlignment.Center, XAlign = TextAlignment.Center }; //High SRM label created to pass into SRMColorCalculator WhiteTextColorLabel srmHigh = new WhiteTextColorLabel { StyleId = "highSRMLabel", Text = "High SRM : " + srmRange [1], HorizontalOptions = LayoutOptions.CenterAndExpand, HeightRequest = 30, WidthRequest = 150, YAlign = TextAlignment.Center, XAlign = TextAlignment.Center }; //Pass both the low and high SRM labels into the calculator //The calculator will change the background color of the labels. srmCalculator.SRMColorCalculator(srmLow, srmHigh); //Put the colored srm labels next to each other StackLayout srmLabels = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { srmLow, srmHigh } }; //Put all of the elements together to create the fullStack StackLayout halfStack = new StackLayout { Orientation = StackOrientation.Vertical, Padding = new Thickness(10, 10, 10, 10), Children = { description, srmLabels, specs, } }; StackLayout fullStack = new StackLayout { Children = { commercialBeers, halfStack, } }; //Wrap the fullStack in a scrollview Content = new ScrollView { Content = fullStack }; }
public IBUCalculatorPage() { //Set the title on the navigation bar to the selected hop Title = "IBU Calculator"; //Set the StyleId for Xamarin Test Cloud StyleId = "IBUCalculatorPage"; table = new IBUListView { StyleId = "ibuListView", BackgroundColor = Color.Transparent, HeightRequest = (double)(App.ScreenHeight * 0.2), HasUnevenRows = true }; //Add hop button addButton = new HopThemedButton { StyleId = "addHopButton", Text = "Add Hop", WidthRequest = (double)(App.ScreenWidth * 0.8), HeightRequest = (double)(App.ScreenHeight * 0.07) }; //Create hop gravity and volume controls boilGravityEntry = new HopThemedNumberEntry { StyleId = "boilGravityEntry", Text = "1.050", WidthRequest = (double)(App.ScreenWidth * 0.3) }; boilVolumeEntry = new HopThemedNumberEntry { StyleId = "boilVolumeEntry", Text = "0", WidthRequest = (double)(App.ScreenWidth * 0.3) }; //Create gravity and volume steppers gravityStepper = new GreenStepper { StyleId = "gravityStepper", Minimum = 1.000, Maximum = 1.120, Increment = .001, Value = Convert.ToDouble(boilGravityEntry.Text), WidthRequest = (double)(App.ScreenWidth * 0.35) }; volumeStepper = new GreenStepper { StyleId = "volumeStepper", Minimum = 0, Maximum = 1000, Increment = 1, Value = Convert.ToDouble(boilVolumeEntry.Text), WidthRequest = (double)(App.ScreenWidth * 0.35) }; //Create grid to add all of the hop gravity and volume controls Grid VolumeAndGravityGrid = new Grid { ColumnDefinitions = { new ColumnDefinition { Width = Device.OnPlatform( (double)(App.ScreenWidth * 0.33), (double)(App.ScreenWidth * 0.3), (double)(App.ScreenWidth * 0.3) ) }, new ColumnDefinition { Width = (double)(App.ScreenWidth * 0.3) }, new ColumnDefinition { Width = (double)(App.ScreenWidth * 0.35) } }, }; //Boil Gravity Grid Row VolumeAndGravityGrid.Children.Add( new Label() { Text = "Boil Gravity", TextColor = Color.White, YAlign = TextAlignment.Center }, 0, 0 ); VolumeAndGravityGrid.Children.Add(boilGravityEntry, 1, 0); VolumeAndGravityGrid.Children.Add(gravityStepper, 2, 0); //Volume Grid Row VolumeAndGravityGrid.Children.Add( new Label() { Text = "Boil Volume", TextColor = Color.White, YAlign = TextAlignment.Center }, 0, 1 ); VolumeAndGravityGrid.Children.Add(boilVolumeEntry, 1, 1); VolumeAndGravityGrid.Children.Add(volumeStepper, 2, 1); //Create calculated IBU stack calculateIBUButton = new HopThemedButton { StyleId = "calculateIBUButton", Text = "Calculate IBU", WidthRequest = (double)(App.ScreenWidth * 0.8), HeightRequest = (double)(App.ScreenHeight * 0.07) }; ThemedLabel IBU = new ThemedLabel { Text = "Calculated IBU:", }; calculatedIBULabel = new ThemedLabel { Text = "0", }; StackLayout IBULabels = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { IBU, calculatedIBULabel } }; //Create calculated stacklayout StackLayout calculatedStackLayout = new StackLayout { Children = { calculateIBUButton, IBULabels }, Spacing = Device.OnPlatform( 5, 0, 5 ) }; StackLayout stack = new StackLayout { Padding = 5, Children = { new IBUListViewHeader(), table, addButton, VolumeAndGravityGrid, calculatedStackLayout } }; //Wrap the content in a scrollview Content = new ScrollView { HeightRequest = (double)(App.ScreenHeight), Content = stack, }; }
public MissionControlPage() { //Set the title on the navigation bar to the selected hop Title = "BrewMate Toolbelt"; //Set the StyleId for Xamarin Test Cloud StyleId = "BrewMateToolbelt"; //Create the buttons to navigate to application functions ibuCalculator = new HopThemedButton { StyleId = "ibuCalculatorButton", Text = "IBU Caluclator", HeightRequest = (double)(App.ScreenHeight * 0.1), WidthRequest = (double)(App.ScreenWidth * 0.8) }; SRMCalculator = new HopThemedButton { StyleId = "mashCalculatorButton", Text = "Mash Calculator", HeightRequest = (double)(App.ScreenHeight * 0.1), WidthRequest = (double)(App.ScreenWidth * 0.8) }; aaPercentageCalculator = new HopThemedButton { StyleId = "alcoholPercentageCalculatorButton", Text = "Alcohol Percentage Calculator", HeightRequest = (double)(App.ScreenHeight * 0.1), WidthRequest = (double)(App.ScreenWidth * 0.8) }; grainDescriptions = new HopThemedButton { StyleId = "grainDescriptionsButton", Text = "Grain Descriptions", HeightRequest = (double)(App.ScreenHeight * 0.1), WidthRequest = (double)(App.ScreenWidth * 0.8) }; hopDescriptions = new HopThemedButton { StyleId = "hopGuideButton", Text = "Hop Guide", HeightRequest = (double)(App.ScreenHeight * 0.1), WidthRequest = (double)(App.ScreenWidth * 0.8) }; beerStyles = new HopThemedButton { StyleId = "beerStylesButton", Text = "Beer Styles", HeightRequest = (double)(App.ScreenHeight * 0.1), WidthRequest = (double)(App.ScreenWidth * 0.8) }; haveBeer = new WhiteTextColorLabel { Text = "Don't worry, I'm here to help!\nGo ahead and have another beer...", XAlign = TextAlignment.Center, VerticalOptions = LayoutOptions.End, }; //Add all buttons to a stacklayout buttonCollection = new StackLayout { HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.Center, Spacing = 10, Opacity = 0, Children = { beerStyles, ibuCalculator, SRMCalculator, aaPercentageCalculator, grainDescriptions, hopDescriptions, } }; }
public CalculateAlcoholPercentPage() { //Set the title on the navigation bar to the selected hop Title = "Alcohol % Calculator"; //Set the StyleId for Xamarin Test Cloud StyleId = "AlcoholPercentCalculatorPage"; //Create original gravity elements ogEntry = new HopThemedNumberEntry { StyleId = "ogEntry", Text = "1.050", HorizontalOptions = LayoutOptions.FillAndExpand }; ThemedLabel ogLabel = new ThemedLabel { Text = "Original Gravity", WidthRequest = 120, HorizontalOptions = LayoutOptions.Start, }; ogStepper = new GreenStepper { StyleId = "ogStepper", Minimum = 0, Maximum = 1.12, Increment = .001, HorizontalOptions = LayoutOptions.End, Value = Convert.ToDouble(ogEntry.Text) }; //stack original gravity elements together in a horizontal block StackLayout ogStackLayout = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { ogLabel, ogEntry, ogStepper } }; //Create final gravity elements fgEntry = new HopThemedNumberEntry { StyleId = "fgEntry", Text = "1.012", HorizontalOptions = LayoutOptions.FillAndExpand }; ThemedLabel fgLabel = new ThemedLabel { Text = "Final Gravity", HorizontalOptions = LayoutOptions.Start, WidthRequest = 120, }; fgStepper = new GreenStepper { StyleId = "fgStepper", Minimum = 0, Maximum = 1.12, Increment = .001, HorizontalOptions = LayoutOptions.End, Value = Convert.ToDouble(fgEntry.Text) }; //stack final gravity elements together in a horizontal block StackLayout fgStackLayout = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { fgLabel, fgEntry, fgStepper } }; //Create alchol percentage Labels ThemedLabel AlcoholPercentLabel = new ThemedLabel { Text = "Calculated Alcohol %:", HorizontalOptions = LayoutOptions.FillAndExpand, }; AlcoholPercentCalculated = new ThemedLabel { StyleId = "calculatedAlcoholPercent", Text = "0.0%", HorizontalOptions = LayoutOptions.FillAndExpand }; //Create Alcohol % Stack StackLayout AlcoholPercentStackLayout = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { AlcoholPercentLabel, AlcoholPercentCalculated } }; //Create button to calculate alcohol percent calculateAlcoholPercent = new HopThemedButton { StyleId = "calculateAlcoholPercentButton", Text = "Calculate Alcohol Percent", BorderWidth = 1, TextColor = Color.Green, WidthRequest = (double)(App.ScreenWidth * 0.8), }; //Set content page properties. Stack elements for content Content = new StackLayout { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.CenterAndExpand, Spacing = 25, Padding = 5, Children = { ogStackLayout, fgStackLayout, AlcoholPercentStackLayout, calculateAlcoholPercent } }; }