Changement page

pull/18/head
Leana BESSON 2 years ago
parent 3cb6d50b7e
commit 445e5b5cab

@ -0,0 +1,45 @@
<?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="Views.Animaux"
Title="Animaux">
<Grid RowDefinitions="Auto, *"
RowSpacing="20"
Padding="20">
<Label Text="Les espèces"
FontSize="Large"/>
<ListView ItemsSource="{Binding ListeAnimal}"
Grid.Row="1">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Margin="0,0,0,4">
<Border Stroke="{StaticResource Secondary}"
StrokeThickness="2"
Margin="10"
Padding="10"
BackgroundColor="{StaticResource Primary}">
<Grid ColumnDefinitions="Auto, *"
RowDefinitions="3*, *, *"
ColumnSpacing="15">
<Frame Grid.RowSpan="3"
WidthRequest="80"
HeightRequest="80"
Padding="0"
Margin="10"
BorderColor="{StaticResource Primary}" >
<Image Source="{Binding Image}"/>
</Frame>
<Label Text="{Binding Nom}"
Grid.Column="1"
Grid.Row="0"
FontSize="Medium"/>
</Grid>
</Border>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</ContentPage>

@ -0,0 +1,13 @@
using Model;
namespace Views;
public partial class Animaux : ContentPage
{
public Zootheque Zootheque { get; set; } = new Zootheque();
public Animaux()
{
InitializeComponent();
BindingContext = Zootheque;
}
}

@ -1,12 +1,24 @@
namespace Views
using Model;
namespace Views
{
public partial class App : Application
{
public Especetheque Especetheque { get; private set; } = new Especetheque();
public Espece EspeceSelectionner {
get => EspeceSelectionner;
set
{
EspeceSelectionner = value;
OnPropertyChanged(nameof(EspeceSelectionner));
}
}
public App()
{
InitializeComponent();
MainPage = new AppShell();
BindingContext = Especetheque;
}
}
}

@ -15,4 +15,13 @@
Title="Les espèces"
ContentTemplate="{DataTemplate local:Especes}"
Route="Especes" />
<ShellContent
Title="Vos animaux"
ContentTemplate="{DataTemplate local:Animaux}"
Route="Animaux"/>
<ShellContent
ContentTemplate="{DataTemplate local:DetailEspece}"
Route="DetailEspece"/>
</Shell>

@ -0,0 +1,11 @@
<?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="Views.DetailEspece"
Title="DetailEspece">
<VerticalStackLayout>
<Label Text="Bienvenue"/>
<Label Text="{Binding Nom}"/>
<Label Text="{Binding NomScientifique}"/>
</VerticalStackLayout>
</ContentPage>

@ -0,0 +1,23 @@
using Model;
namespace Views;
public partial class DetailEspece : ContentPage
{
Especes espece;
public Especes Espece
{
get => espece;
set
{
espece = value;
OnPropertyChanged();
}
}
public DetailEspece()
{
InitializeComponent();
BindingContext = (App.Current as App).EspeceSelectionner;
}
}

@ -3,11 +3,17 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Views.Especes"
Title="Especes">
<Grid RowDefinitions="Auto, *" RowSpacing="20" Padding="20">
<Label Text="Les espèces" FontSize="Large"/>
<CollectionView ItemsSource="{Binding ListeEspeces}" Grid.Row="1">
<CollectionView.ItemTemplate>
<Grid RowDefinitions="Auto, *"
RowSpacing="20"
Padding="20">
<Label Text="Les espèces"
FontSize="Large"/>
<ListView ItemsSource="{Binding ListeEspeces}"
Grid.Row="1"
ItemSelected="OnClick">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Margin="0,0,0,4">
<Border Stroke="{StaticResource Secondary}"
StrokeThickness="2"
@ -15,7 +21,7 @@
Padding="10"
BackgroundColor="{StaticResource Primary}">
<Grid ColumnDefinitions="Auto, *"
RowDefinitions="2*, *, *"
RowDefinitions="3*, *, *"
ColumnSpacing="15">
<Frame Grid.RowSpan="3"
WidthRequest="80"
@ -27,8 +33,8 @@
</Frame>
<Label Text="{Binding Nom}"
Grid.Column="1"
FontSize="Medium"
VerticalTextAlignment="Center"/>
Grid.Row="0"
FontSize="Medium"/>
<Label Text="{Binding NomScientifique}"
Grid.Column="1"
Grid.Row="1"
@ -36,8 +42,9 @@
</Grid>
</Border>
</Grid>
</ViewCell>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</ListView.ItemTemplate>
</ListView>
</Grid>
</ContentPage>

@ -5,10 +5,16 @@ namespace Views;
public partial class Especes : ContentPage
{
public Especetheque Especetheque { get; private set; } = new Especetheque();
public Especes()
{
InitializeComponent();
BindingContext = Especetheque;
BindingContext = (App.Current as App).Especetheque;
}
public async void OnClick(object sender, SelectedItemChangedEventArgs e)
{
(App.Current as App).EspeceSelectionner = e.SelectedItem as Espece;
await Shell.Current.GoToAsync("//DetailEspece");
}
}

@ -60,15 +60,24 @@
<Compile Update="Especes.xaml.cs">
<DependentUpon>Especes.xaml</DependentUpon>
</Compile>
<Compile Update="Animaux.xaml.cs">
<DependentUpon>Animaux.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<MauiXaml Update="DetailEspece.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Espece.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Especes.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Animaux.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>
</Project>

Loading…
Cancel
Save