You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.1 KiB
48 lines
1.1 KiB
using FlyoutTabSearch.Data;
|
|
|
|
namespace FlyoutTabSearch.Pages;
|
|
|
|
[QueryProperty(nameof(AstroName), "astroName")]
|
|
public partial class AstronomicalBodyPage : ContentPage
|
|
{
|
|
private string _astroName;
|
|
public string AstroName
|
|
{
|
|
get { return _astroName; }
|
|
set
|
|
{
|
|
_astroName = value;
|
|
UpdateAstroBodyUI(_astroName);
|
|
}
|
|
}
|
|
|
|
public AstronomicalBodyPage()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
void UpdateAstroBodyUI(string astroName)
|
|
{
|
|
AstronomicalBody body = FindAstroData(astroName);
|
|
|
|
Title = body.Name;
|
|
|
|
lblIcon.Text = body.EmojiIcon;
|
|
lblName.Text = body.Name;
|
|
lblMass.Text = body.Mass;
|
|
lblCircumference.Text = body.Circumference;
|
|
lblAge.Text = body.Age;
|
|
}
|
|
|
|
AstronomicalBody FindAstroData(string astronomicalBodyName)
|
|
{
|
|
return astronomicalBodyName switch
|
|
{
|
|
"comet" => SolarSystemData.HalleysComet,
|
|
"earth" => SolarSystemData.Earth,
|
|
"moon" => SolarSystemData.Moon,
|
|
"sun" => SolarSystemData.Sun,
|
|
_ => throw new ArgumentException()
|
|
};
|
|
}
|
|
} |