using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Moshaverino.Models;
using Moshaverino.ViewModels;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace Moshaverino.Views.SignUp
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class SelectSex : ContentView
    {
        public SelectSex()
        {
            InitializeComponent();
        }

        private Frame selectedSex = null;

        private void SexFrame_OnTapped(object sender, EventArgs e)
        {
            var baseFrame = sender as Frame;
            if (selectedSex != null)
            {
                var dLael = selectedSex.Content as Label;
                selectedSex.BackgroundColor = Color.FromHex("#eee");
                dLael.TextColor = Color.FromHex("#785284");
            }

            var sFrame = (baseFrame.Content as Grid).Children[0] as Frame;
            var sLabel = sFrame.Content as Label;
            sFrame.BackgroundColor = Color.FromHex("#785284");
            sLabel.TextColor = Color.White;
            selectedSex = sFrame;

        }

        private void SubmitButton_OnClicked(object sender, EventArgs e)
        {
            var student = new Student();
            if (selectedSex.ClassId == "femail")
                student.HumenSex = HumenSex.Female;
            else
                student.HumenSex = HumenSex.Male;
            (BindingContext as SignUpPageViewModel)?.SubmitSexButtonCommand.Execute(student);
        }
    }
}