using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using Xamarin.Essentials;

namespace EcoFootprintCalculator
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class About : ContentPage
    {
        //private Label RefTokLabel;
        //private Label uidLabel;
        public About()
        {
            InitializeComponent();

            Title = "About";

            var layout = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Background = App.bgcolor
            };

            /*uidLabel = new Label()
            {
                Text = "UID: " + App.auth.User.LocalId + "Exp: " + App.auth.FirebaseToken
            };*/

            var urlLabel = new Label
            {
                Text = "https://kdieiroda.wixsite.com/household",
                TextDecorations = TextDecorations.Underline,
                TextColor = Color.CadetBlue
            };
            urlLabel.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() => {
                    Launcher.OpenAsync(new Uri(urlLabel.Text));
                })
            });

            var urlteacherLabel = new Label
            {
                Text = "https://kdieiroda.wixsite.com/household/ecofootprintcalc",
                TextDecorations = TextDecorations.Underline,
                TextColor = Color.CadetBlue
            };
            urlteacherLabel.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() => {
                    Launcher.OpenAsync(new Uri(urlteacherLabel.Text));
                })
            });

            var fbLabel = new Label
            {
                Text = "https://www.facebook.com/groups/440180873537687",
                TextDecorations = TextDecorations.Underline,
                TextColor = Color.CadetBlue
            };
            fbLabel.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() => {
                    Launcher.OpenAsync(new Uri(fbLabel.Text));
                })
            });

            var extLabel = new Label
            {
                Text = "https://www.footprintnetwork.org/",
                TextDecorations = TextDecorations.Underline,
                TextColor = Color.CadetBlue
            };
            extLabel.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() => {
                    Launcher.OpenAsync(new Uri(extLabel.Text));
                })
            });

            /*RefTokLabel = new Label
            {
                Text = "RefTok: " + App.auth.RefreshToken
            };*/

            var image = new Image
            {
                //Erasmus logó
                Source = "logosbeneficaireserasmusleft_en_1.jpg",
                VerticalOptions = LayoutOptions.FillAndExpand,
                Aspect = Aspect.AspectFit,
            };
            image.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() => {
                    Launcher.OpenAsync(new Uri("https://erasmus-plus.ec.europa.eu/"));
                })
            });


            layout.Children.Add(new Label { Text = "This application was created as the intellectual output of the Erasmus+ KA201 project: \"Household without Chemicals\"." });
            layout.Children.Add(new Label { Text = "Project ID: 2019-1-HU01-KA201-061193" });
            layout.Children.Add(new Label { Text = "This application calculates a person's ecological footprint." });
            layout.Children.Add(new Label { Text = "We don't collect any personal data, we only store the answers given to the questionnaire." });
            layout.Children.Add(new Label { Text = "We will use these data to research footprints and attitude around the world." });
            layout.Children.Add(new Label { Text = "So please give honest answers, so we can get the correct picture of the situation." });
            layout.Children.Add(new Label { Text = "We can only save our planet if we are honest!", FontSize = 20, FontAttributes = FontAttributes.Bold });

            layout.Children.Add(new Label { Text = "" });
            layout.Children.Add(new Label { Text = "Further details about our project can be found on our webpage:" });
            layout.Children.Add(urlLabel);
            layout.Children.Add(new Label { Text = "and on our Facebook page" });
            layout.Children.Add(fbLabel);
            layout.Children.Add(new Label { Text = "Materials for teachers:" });
            layout.Children.Add(urlteacherLabel);


            layout.Children.Add(new Label { Text = "" });
            layout.Children.Add(new Label { Text = "Further details about ecological footprint can be found on Global Footprint Network:" });
            layout.Children.Add(extLabel);

            layout.Children.Add(image);

            //layout.Children.Add(uidLabel);
            //layout.Children.Add(new Label { Text = "Exp: " + App.auth.ExpiresIn });
            //layout.Children.Add(RefTokLabel);
            //layout.Children.Add(new Label { Text = "User: " + App.auth.User.ToString() });
            //layout.Children.Add(new Label { Text = "Created: " + App.auth.Created });

            this.Content = layout;
        }

        protected override void OnAppearing()
        {
            base.OnAppearing();

            //RefTokLabel.Text = "RefTok: " + App.auth.RefreshToken;
            //uidLabel.Text = "UID: " + App.auth.User.LocalId;
        }
    }
}