Toolkit pour le boutton Animaux

pull/18/head
Leana BESSON 2 years ago
parent 0b474a35d7
commit 7b9a792e08

@ -18,7 +18,7 @@ namespace Model
public Espece Espece { get; set; } public Espece Espece { get; set; }
public Race? Race { get; set; } public Race? Race { get; set; }
public Animal(string nom, string dateNaissance = "", string sexe = "", string dateAdpotion = "", float? taille = null, float? poids = null, string alimentation = "", Race? race = null) public Animal(string nom, string dateNaissance = "Inconnue", string sexe = "Inconnu", string dateAdpotion = "Inconnue", float? taille = null, float? poids = null, string alimentation = "Inconnue", Race? race = null)
{ {
Nom = nom; Nom = nom;
DateNaissance = dateNaissance; DateNaissance = dateNaissance;

@ -29,6 +29,10 @@ namespace Model
listeAnimaux.Add(new("Kiki")); listeAnimaux.Add(new("Kiki"));
listeAnimaux.Add(new("PouetPouet")); listeAnimaux.Add(new("PouetPouet"));
listeAnimaux.Add(new("Chouchou"));
listeAnimaux.Add(new("Pupuce"));
listeAnimaux.Add(new("AucuneIdée"));
listeAnimaux.Add(new("Minou"));
return listeAnimaux; return listeAnimaux;
} }

@ -1,51 +1,58 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentPage x:Class="Views.Animaux"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Views.Animaux" xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
Title="Vos animaux"> Title="Vos animaux">
<VerticalStackLayout> <ScrollView>
<Grid RowDefinitions="Auto, *" <toolkit:DockLayout>
RowSpacing="20" <Button Text="+"
Padding="20">
<ListView ItemsSource="{Binding ListeAnimaux}"
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>
<Button Text="+"
FontSize="Large" FontSize="Large"
Background="{StaticResource Primary}" Background="{StaticResource Primary}"
toolkit:DockLayout.DockPosition="Bottom"
VerticalOptions="End" VerticalOptions="End"
HorizontalOptions="End" HorizontalOptions="End"
Margin="20"/> Margin="20"/>
</VerticalStackLayout> <VerticalStackLayout>
<Grid RowDefinitions="Auto, *"
RowSpacing="20">
<ListView ItemsSource="{Binding ListeAnimaux}"
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"
HeightRequest="60"
WidthRequest="60"
Padding="0"
Margin="10"
BorderColor="{StaticResource Primary}">
<Image Source="{Binding Image}"/>
</Frame>
<VerticalStackLayout Grid.Column="1">
<Label Text="{Binding Nom}"
FontSize="Large"/>
<Label Text="{Binding NomScientifique}"
FontSize="12"/>
</VerticalStackLayout>
</Grid>
</Border>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</VerticalStackLayout>
</toolkit:DockLayout>
</ScrollView>
</ContentPage> </ContentPage>

@ -1,3 +1,4 @@
using CommunityToolkit.Maui.Layouts;
using Model; using Model;
namespace Views; namespace Views;
@ -10,4 +11,11 @@ public partial class Animaux : ContentPage
InitializeComponent(); InitializeComponent();
BindingContext = (App.Current as App).Theque.Zootheque; BindingContext = (App.Current as App).Theque.Zootheque;
} }
public void OnClick(object sender, ItemTappedEventArgs e)
{
(App.Current as App).AnimalSelectionner = e.Item as Animal;
Navigation.PushAsync(new DetailAnimal());
}
} }

@ -7,16 +7,14 @@ namespace Views
public partial class App : Application, INotifyPropertyChanged public partial class App : Application, INotifyPropertyChanged
{ {
public Theque Theque { get; set; } = new Theque(); public Theque Theque { get; set; } = new Theque();
public Animal AnimalSelectionner; public Animal AnimalSelectionner { get; set; }
public Espece EspeceSelectionner; public Espece EspeceSelectionner { get; set; }
public Race RaceSelectionner; public Race RaceSelectionner { get; set; }
public App() public App()
{ {
InitializeComponent(); InitializeComponent();
MainPage = new AppShell(); MainPage = new AppShell();
} }
} }
} }

@ -0,0 +1,66 @@
<?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.DetailAnimal"
Title="{Binding Nom}">
<ScrollView>
<VerticalStackLayout>
<Image Source="{Binding Image}"
MaximumWidthRequest="300"
Margin="20"
HorizontalOptions="Center"/>
<Border Stroke="{StaticResource Secondary}"
StrokeThickness="2"
Margin="20"
Padding="10"
Background="{StaticResource Primary}"
VerticalOptions="Start"
Grid.Column="1">
<Grid RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto, Auto"
ColumnDefinitions="*, *"
RowSpacing="8">
<Label FontAttributes="Bold"
Text="Date de naissance"/>
<Label Grid.Column="1"
HorizontalOptions="End"
Text="{Binding DateNaissance}"/>
<Label Grid.Row="1"
FontAttributes="Bold"
Text="Sexe"/>
<Label Grid.Column="2"
Grid.Row="1"
HorizontalOptions="End"
Text="{Binding Sexe}"/>
<Label Grid.Row="2"
FontAttributes="Bold"
Text="Date d'adoption"/>
<Label Grid.Column="2"
Grid.Row="2"
HorizontalOptions="End"
Text="{Binding DateAdoption}"/>
<Label Grid.Row="3"
FontAttributes="Bold"
Text="Taille"/>
<Label Grid.Column="2"
Grid.Row="3"
HorizontalOptions="End"
Text="{Binding Taille}"/>
<Label Grid.Row="4"
FontAttributes="Bold"
Text="Poids"/>
<Label Grid.Column="2"
Grid.Row="4"
HorizontalOptions="End"
Text="{Binding Poids}"/>
<Label Grid.Row="5"
FontAttributes="Bold"
Text="Alimentation"/>
<Label Grid.Column="2"
Grid.Row="5"
HorizontalOptions="End"
Text="{Binding Alimentation}"/>
</Grid>
</Border>
</VerticalStackLayout>
</ScrollView>
</ContentPage>

@ -0,0 +1,10 @@
namespace Views;
public partial class DetailAnimal : ContentPage
{
public DetailAnimal()
{
InitializeComponent();
BindingContext = (App.Current as App).AnimalSelectionner;
}
}

@ -125,7 +125,7 @@ FontSize="Large"/>
FontSize="Large"/> FontSize="Large"/>
<ListView ItemsSource="{Binding ListeRaces}" <ListView ItemsSource="{Binding ListeRaces}"
Grid.Row="1" Grid.Row="1"
ItemSelected="OnClick"> ItemTapped="OnClick">
<ListView.ItemTemplate> <ListView.ItemTemplate>
<DataTemplate> <DataTemplate>
<ViewCell> <ViewCell>

@ -11,9 +11,9 @@ public partial class DetailEspece : ContentPage
BindingContext = (App.Current as App).EspeceSelectionner; BindingContext = (App.Current as App).EspeceSelectionner;
} }
public async void OnClick(object sender, SelectedItemChangedEventArgs e) public async void OnClick(object sender, ItemTappedEventArgs e)
{ {
(App.Current as App).RaceSelectionner = e.SelectedItem as Race; (App.Current as App).RaceSelectionner = e.Item as Race;
await Navigation.PushAsync(new DetailRace()); await Navigation.PushAsync(new DetailRace());
} }
} }

@ -6,48 +6,45 @@
<ScrollView> <ScrollView>
<VerticalStackLayout> <VerticalStackLayout>
<Image Source="{Binding Image}" <Image Source="{Binding Image}"
MaximumWidthRequest="300" MaximumWidthRequest="300"
Margin="20" Margin="20"
HorizontalOptions="Center"/> HorizontalOptions="Center"/>
<Border Stroke="{StaticResource Secondary}" <Border Stroke="{StaticResource Secondary}"
StrokeThickness="2" StrokeThickness="2"
Margin="20" Margin="20"
Padding="10" Padding="10"
Background="{StaticResource Primary}" Background="{StaticResource Primary}"
VerticalOptions="Start" VerticalOptions="Start"
Grid.Column="1"> Grid.Column="1">
<Grid RowDefinitions="Auto, *, *, *, *" <Grid RowDefinitions="Auto, Auto, Auto, Auto, Auto"
ColumnDefinitions="*, *" ColumnDefinitions="*, *"
RowSpacing="10"> RowSpacing="8">
<Label FontAttributes="Bold" <Label FontAttributes="Bold"
Text="Nom Scientifique"/> Text="Nom scientifique"/>
<Label Grid.Column="1" <Label Grid.Column="1"
HorizontalOptions="End" HorizontalOptions="End"
Text="{Binding NomScientifique}"/> Text="{Binding NomScientifique}"/>
<Label Grid.Row="1" <Label Grid.Row="1"
FontAttributes="Bold" FontAttributes="Bold"
Text="Espérance de vie"/> Text="Espérance de vie"/>
<Label Grid.Column="2" <Label Grid.Column="2"
Grid.Row="1" Grid.Row="1"
HorizontalOptions="End" HorizontalOptions="End"
Text="{Binding EsperanceVie}"/> Text="{Binding EsperanceVie}"/>
<Label Grid.Row="2" <Label Grid.Row="2"
FontAttributes="Bold" FontAttributes="Bold"
Text="Poids moyen"/> Text="Poids moyen"/>
<Label Grid.Column="2" <Label Grid.Column="2"
Grid.Row="2" Grid.Row="2"
HorizontalOptions="End" HorizontalOptions="End"
Text="{Binding PoidsMoyen}"/> Text="{Binding PoidsMoyen}"/>
<Label Grid.Row="3" <Label Grid.Row="3"
FontAttributes="Bold" FontAttributes="Bold"
Text="Taille moyenne"/> Text="Taille moyenne"/>
<Label Grid.Column="2" <Label Grid.Column="2"
Grid.Row="3" Grid.Row="3"
HorizontalOptions="End" HorizontalOptions="End"
Text="{Binding TailleMoyenne}"/> Text="{Binding TailleMoyenne}"/>
</Grid> </Grid>
</Border> </Border>
@ -55,54 +52,70 @@
Margin="20"> Margin="20">
<Label Text="Comportement" <Label Text="Comportement"
FontSize="Large"/> FontSize="Large"/>
<Label Text="{Binding Comportement}" <Border Stroke="{StaticResource Secondary}"
Padding="10" StrokeThickness="2"
Background="{StaticResource Primary}"/> Padding="10"
Background="{StaticResource Primary}">
<Label Text="{Binding Comportement}"/>
</Border>
</VerticalStackLayout> </VerticalStackLayout>
<VerticalStackLayout <VerticalStackLayout
Margin="20"> Margin="20">
<Label Text="Santé" <Label Text="Santé"
FontSize="Large"/> FontSize="Large"/>
<Label Text="{Binding Sante}" <Border Stroke="{StaticResource Secondary}"
Padding="10" StrokeThickness="2"
Background="{StaticResource Primary}"/> Padding="10"
Background="{StaticResource Primary}">
<Label Text="{Binding Sante}"/>
</Border>
</VerticalStackLayout> </VerticalStackLayout>
<VerticalStackLayout <VerticalStackLayout
Margin="20"> Margin="20">
<Label Text="Education" <Label Text="Education"
FontSize="Large"/> FontSize="Large"/>
<Label Text="{Binding Education}" <Border Stroke="{StaticResource Secondary}"
Padding="10" StrokeThickness="2"
Background="{StaticResource Primary}"/> Padding="10"
Background="{StaticResource Primary}">
<Label Text="{Binding Education}"/>
</Border>
</VerticalStackLayout> </VerticalStackLayout>
<VerticalStackLayout <VerticalStackLayout
Margin="20"> Margin="20">
<Label Text="Entretien" <Label Text="Entretien"
FontSize="Large"/> FontSize="Large"/>
<Label Text="{Binding Entretien}" <Border Stroke="{StaticResource Secondary}"
Padding="10" StrokeThickness="2"
Background="{StaticResource Primary}"/> Padding="10"
Background="{StaticResource Primary}">
<Label Text="{Binding Entretien}"/>
</Border>
</VerticalStackLayout> </VerticalStackLayout>
<VerticalStackLayout <VerticalStackLayout Margin="20">
Margin="20">
<Label Text="Coût potentiel" <Label Text="Coût potentiel"
FontSize="Large"/> FontSize="Large"/>
<Label Text="{Binding Cout}" <Border Stroke="{StaticResource Secondary}"
Padding="10" StrokeThickness="2"
Background="{StaticResource Primary}"/> Padding="10"
Background="{StaticResource Primary}">
<Label Text="{Binding Cout}"/>
</Border>
</VerticalStackLayout> </VerticalStackLayout>
<VerticalStackLayout <VerticalStackLayout Margin="20">
Margin="20">
<Label Text="Conseils" <Label Text="Conseils"
FontSize="Large"/> FontSize="Large"/>
<Label Text="{Binding Conseil}" <Border Stroke="{StaticResource Secondary}"
Padding="10" StrokeThickness="2"
Background="{StaticResource Primary}"/> Padding="10"
Background="{StaticResource Primary}">
<Label Text="{Binding Conseil}"/>
</Border>
</VerticalStackLayout> </VerticalStackLayout>
</VerticalStackLayout> </VerticalStackLayout>
</ScrollView> </ScrollView>

@ -8,7 +8,7 @@
Padding="20"> Padding="20">
<ListView ItemsSource="{Binding ListeEspeces}" <ListView ItemsSource="{Binding ListeEspeces}"
Grid.Row="1" Grid.Row="1"
ItemSelected="OnClick"> ItemTapped="OnClick">
<ListView.ItemTemplate> <ListView.ItemTemplate>
<DataTemplate> <DataTemplate>
<ViewCell> <ViewCell>

@ -12,9 +12,9 @@ public partial class Especes : ContentPage
BindingContext = (App.Current as App).Theque.Especetheque; BindingContext = (App.Current as App).Theque.Especetheque;
} }
public void OnClick(object sender, SelectedItemChangedEventArgs e) public void OnClick(object sender, ItemTappedEventArgs e)
{ {
(App.Current as App).EspeceSelectionner = e.SelectedItem as Espece; (App.Current as App).EspeceSelectionner = e.Item as Espece;
Navigation.PushAsync(new DetailEspece()); Navigation.PushAsync(new DetailEspece());
} }
} }

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Views" xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="Views.MainPage"> xmlns:local="clr-namespace:Views"
x:Class="Views.MainPage">
</ContentPage> </ContentPage>

@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using CommunityToolkit.Maui;
namespace Views namespace Views
{ {
@ -9,6 +10,7 @@ namespace Views
var builder = MauiApp.CreateBuilder(); var builder = MauiApp.CreateBuilder();
builder builder
.UseMauiApp<App>() .UseMauiApp<App>()
.UseMauiCommunityToolkit()
.ConfigureFonts(fonts => .ConfigureFonts(fonts =>
{ {
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");

@ -49,6 +49,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="5.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
</ItemGroup> </ItemGroup>
@ -66,6 +67,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<MauiXaml Update="DetailAnimal.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="DetailEspece.xaml"> <MauiXaml Update="DetailEspece.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</MauiXaml> </MauiXaml>

Loading…
Cancel
Save