using PlantBox.Client.Models;
using PlantBox.Client.Resources;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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

namespace PlantBox.Client.Forms
{
	[XamlCompilation(XamlCompilationOptions.Compile)]
	public partial class AboutPage : ContentPage
	{
		public AboutPage()
		{
			InitializeComponent();

            listView.ItemsSource = new AboutPageItemGroup[]
            {
                new AboutPageItemGroup(Locale.Informations)
                {
                    new AboutPageItem(Locale.Author, "Eveldee"),
                    new AboutPageItem(Locale.Version, GetType().Assembly.GetName().Version.ToString()),
                    new AboutPageItem("GitHub", "https://github.com/eveldee0680/PlantBox", true)
                },
                new AboutPageItemGroup(Locale.Libraries)
                {
                    new AboutPageItem("Microcharts", "https://github.com/aloisdeniel/Microcharts", true),
                    new AboutPageItem("Newtonsoft.Json", "https://github.com/JamesNK/Newtonsoft.Json", true)
                },
                new AboutPageItemGroup(Locale.Media)
                {
                    new AboutPageItem("Android Material Icons", "https://material.io/tools/icons/", true),
                    new AboutPageItem("Android Asset Studio", "https://romannurik.github.io/AndroidAssetStudio/", true)
                }
            };
		}

        private void ListView_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            if (e.Item is AboutPageItem item && item.IsLink == true)
            {
                Device.OpenUri(new Uri(item.Value));
            }
        }
    }
}