parent
09ecd24355
commit
45387d3faa
@ -0,0 +1,14 @@ |
|||||||
|
namespace FlyoutTabSearch.Pages; |
||||||
|
|
||||||
|
public partial class AstronomicalBodiesPage : ContentPage |
||||||
|
{ |
||||||
|
public AstronomicalBodiesPage() |
||||||
|
{ |
||||||
|
InitializeComponent(); |
||||||
|
|
||||||
|
btnComet.Clicked += async (s, e) => await Shell.Current.GoToAsync("astronomicalbodydetails?astroName=comet"); |
||||||
|
btnEarth.Clicked += async (s, e) => await Shell.Current.GoToAsync("astronomicalbodydetails?astroName=earth"); |
||||||
|
btnMoon.Clicked += async (s, e) => await Shell.Current.GoToAsync("astronomicalbodydetails?astroName=moon"); |
||||||
|
btnSun.Clicked += async (s, e) => await Shell.Current.GoToAsync("astronomicalbodydetails?astroName=sun"); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,47 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8" ?> |
||||||
|
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" |
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" |
||||||
|
x:Class="FlyoutTabSearch.Pages.AstronomicalBodyPage" |
||||||
|
Title="Astronomical Data"> |
||||||
|
<ContentPage.Resources> |
||||||
|
<ResourceDictionary> |
||||||
|
<Color x:Key="textColor">White</Color> |
||||||
|
<Style TargetType="Label"> |
||||||
|
<Setter Property="TextColor" Value="{StaticResource textColor}" /> |
||||||
|
</Style> |
||||||
|
</ResourceDictionary> |
||||||
|
</ContentPage.Resources> |
||||||
|
|
||||||
|
<Shell.BackButtonBehavior> |
||||||
|
<BackButtonBehavior IconOverride="comet.png"/> |
||||||
|
</Shell.BackButtonBehavior> |
||||||
|
|
||||||
|
<Grid RowSpacing="10" ColumnSpacing="10"> |
||||||
|
<Grid.ColumnDefinitions> |
||||||
|
<ColumnDefinition Width="*" /> |
||||||
|
<ColumnDefinition Width="*" /> |
||||||
|
</Grid.ColumnDefinitions> |
||||||
|
|
||||||
|
<Grid.RowDefinitions> |
||||||
|
<RowDefinition Height="auto" /> |
||||||
|
<RowDefinition Height="auto" /> |
||||||
|
<RowDefinition Height="auto" /> |
||||||
|
<RowDefinition Height="auto" /> |
||||||
|
<RowDefinition Height="auto" /> |
||||||
|
<RowDefinition Height="*" /> |
||||||
|
</Grid.RowDefinitions> |
||||||
|
|
||||||
|
<Image Aspect="AspectFill" Grid.RowSpan="6" Grid.ColumnSpan="2" Source="starfield.png" /> |
||||||
|
|
||||||
|
<Label x:Name="lblIcon" FontSize="96" Grid.Row="0" Grid.ColumnSpan="2" HorizontalOptions="Center" /> |
||||||
|
<Label x:Name="lblName" FontSize="Medium" FontAttributes="Bold" Grid.Row="1" Grid.ColumnSpan="2" HorizontalOptions="Center" /> |
||||||
|
|
||||||
|
<Label FontSize="Medium" FontAttributes="Bold" Grid.Row="2" HorizontalOptions="End" Text="Mass:" /> |
||||||
|
<Label FontSize="Medium" FontAttributes="Bold" Grid.Row="3" HorizontalOptions="End" Text="Circumference:" /> |
||||||
|
<Label FontSize="Medium" FontAttributes="Bold" Grid.Row="4" HorizontalOptions="End" Text="Age:" /> |
||||||
|
|
||||||
|
<Label x:Name="lblMass" FontSize="Medium" Grid.Row="2" Grid.Column="1" /> |
||||||
|
<Label x:Name="lblCircumference" FontSize="Medium" Grid.Row="3" Grid.Column="1" /> |
||||||
|
<Label x:Name="lblAge" FontSize="Medium" Grid.Row="4" Grid.Column="1" /> |
||||||
|
</Grid> |
||||||
|
</ContentPage> |
@ -0,0 +1,48 @@ |
|||||||
|
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() |
||||||
|
}; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue