private void InitializeTotals()
        {
            ////////////////// CURRENCY PICKER //////////////////
            currencyPicker = new Picker
            {
                Title             = "Currency",
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.Center
            };

            int favouriteIndex = 0;
            int counter        = 0;

            foreach (Currency c in db.GetCurrencies())
            {
                if (c.code == selectedCurrency.code)
                {
                    favouriteIndex = counter;
                }
                currencyPicker.Items.Add(c.code);
                counter++;
            }
            currencyPicker.SelectedIndex         = favouriteIndex;
            currencyPicker.SelectedIndexChanged += currencyChanged;

            //////////////////////// LABEL ///////////////////
            totalLabel = new Label()
            {
                Text = "Loading...",
                HorizontalTextAlignment = TextAlignment.Center,
                FontSize       = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                FontAttributes = FontAttributes.Bold
            };
            UpdateTotalLabelText();

            var totals = new StackLayout
            {
                Children = { currencyPicker, totalLabel }
            };

            mainGrid.Children.Add(totals, 0, 2);
        }
        public InputValuePage(DatabaseOps db, Wallet w)
        {
            Title = "Add/Remove Money";

            this.db = db;
            wallet  = w;

            favouriteCurrency = Utils.getFavouriteCurrency(db);

            //////////////////// TOOLBAR /////////////////////
            var balancePageButton = new ToolbarItem
            {
                Text    = "Balance",
                Command = new Command(this.ShowBalancePage)
            };

            if (Device.OS == TargetPlatform.Windows)
            {
                balancePageButton.Order = ToolbarItemOrder.Secondary;
            }

            ToolbarItems.Add(balancePageButton);

            var setFavouriteCurrencyButton = new ToolbarItem
            {
                Text    = "Favourite Currency",
                Command = new Command(this.ShowSetFavouriteCurrencyPage)
            };

            setFavouriteCurrencyButton.Order = ToolbarItemOrder.Secondary;
            ToolbarItems.Add(setFavouriteCurrencyButton);

            var showRatesPageButton = new ToolbarItem
            {
                Text    = "Rates",
                Command = new Command(this.ShowRatesPage)
            };

            showRatesPageButton.Order = ToolbarItemOrder.Secondary;
            ToolbarItems.Add(showRatesPageButton);


            var updateCurrenciesButton = new ToolbarItem
            {
                Text    = "Update Currencies",
                Command = new Command(this.UpdateCurrencies)
            };

            updateCurrenciesButton.Order = ToolbarItemOrder.Secondary;
            ToolbarItems.Add(updateCurrenciesButton);

            /////////////////// PROGRESS BAR //////////////////

            progressBar = new ProgressBar
            {
                Progress = 0,
            };


            ////////////////// ACTION PICKER //////////////////
            actionPicker = new Picker
            {
                Title             = "Action",
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            actionPicker.Items.Add("Add");
            actionPicker.Items.Add("Remove");
            actionPicker.SelectedIndex         = 0;
            actionPicker.SelectedIndexChanged += actionChanged;

            ////////////////// VALUE INPUT //////////////////
            entryLabel = new Label()
            {
                Text = "Amount:"
            };
            valueEntry = new Entry()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Placeholder       = "Amount",
                Keyboard          = Keyboard.Numeric
            };

            ////////////////// CURRENCY PICKER //////////////////
            currencyPicker = new Picker
            {
                Title             = "Currency",
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            int favouriteIndex = 0;

            numberOfCurrencies = 0;
            foreach (Currency c in db.GetCurrencies())
            {
                currencyPicker.Items.Add(c.code);
                if (c.code == favouriteCurrency.code)
                {
                    favouriteIndex = numberOfCurrencies;
                }
                numberOfCurrencies++;
            }
            currencyPicker.SelectedIndex         = favouriteIndex;
            selectedCurrency                     = db.GetCurrencies().ElementAt(favouriteIndex);
            currencyPicker.SelectedIndexChanged += currencyChanged;

            ////////////////// CURRENT CURRENCY RATE //////////////////

            currencyRateLabel = new Label();
            updateCurrencyRateLabelText();

            ////////////////// BUTTON //////////////////
            button = new Button()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Text            = "Add",
                BackgroundColor = Utils.addColor
            };
            button.Clicked += OnButtonClicked;

            ////////////////// ERROR LABEL //////////////////
            errorLabel = new Label()
            {
                Text      = "",
                TextColor = Color.Red,
                HorizontalTextAlignment = TextAlignment.Center
            };

            ////////////////// GRID //////////////////
            var grid = new Grid()
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.CenterAndExpand
            };

            grid.ColumnDefinitions = new ColumnDefinitionCollection
            {
                new ColumnDefinition {
                    Width = new GridLength(2, GridUnitType.Star)
                },
                new ColumnDefinition {
                    Width = new GridLength(3, GridUnitType.Star)
                },
                new ColumnDefinition {
                    Width = new GridLength(2, GridUnitType.Star)
                }
            };

            for (int i = 0; i < 7; i++)
            {
                grid.RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });
            }

            grid.Children.Add(errorLabel, 1, 0);
            grid.Children.Add(actionPicker, 1, 1);
            grid.Children.Add(entryLabel, 1, 2);
            grid.Children.Add(valueEntry, 1, 3);
            grid.Children.Add(currencyPicker, 1, 4);
            grid.Children.Add(currencyRateLabel, 1, 5);
            grid.Children.Add(button, 1, 6);

            Content = new StackLayout
            {
                Children = { progressBar, grid }
            };
        }
 private void currencyChanged(object sender, EventArgs e)
 {
     selectedCurrency = db.GetCurrencies().ElementAt(((Picker)sender).SelectedIndex);
     updateCurrencyRateLabelText();
 }