DataBinding Page Jeu
continuous-integration/drone/push Build is failing Details

pull/41/head
Yvan CALATAYUD 2 years ago
parent 4572e6db2b
commit 7da8fccef6

@ -6,17 +6,33 @@ namespace GameAtlas;
public partial class App : Application public partial class App : Application
{ {
public Manager MyManager { get; private set; } = new Manager(new Stub.Stub());//new Manager(new DataContractPersistance.DataContractPers());
public string FileName { get; set; } = "data.xml";
public string FilePath { get; set; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory);
public Manager MyManager { get; private set; } = new Manager(new Stub.Stub());//new Manager(new DataContractPersistance.DataContractPers());
public App() public App()
{ {
MyManager.ChargerDonnees(); InitializeComponent();
InitializeComponent();
if (File.Exists(Path.Combine(FilePath, FileName)))
{
MyManager = new Manager(new DataContractPersistance.DataContractPers());
}
MyManager.Persistance = new DataContractPersistance.DataContractPers();
MyManager.ChargerDonnees();
MainPage = new AppShell(); MainPage = new AppShell();
if (!File.Exists(Path.Combine(FilePath, FileName)))
{
MyManager.Persistance = new DataContractPersistance.DataContractPers();
}
MyManager.SauvegardeDonnees(); MyManager.SauvegardeDonnees();
} }
} }

@ -14,10 +14,12 @@ namespace GameAtlas.Stub
List<Utilisateur> ListUsers = new List<Utilisateur>(); List<Utilisateur> ListUsers = new List<Utilisateur>();
List<Jeu> ListJeu = new List<Jeu>(); List<Jeu> ListJeu = new List<Jeu>();
Utilisateur user1 = new Utilisateur("test@gmail.com", "test", "Test1234"); Utilisateur user1 = new Utilisateur("test@gmail.com", "test", "Test1234");
Jeu TheLastOfUs = new Jeu("The last of Us Part 1", 5, 487, "Ps5", "Aventure", "https://cdn1.epicgames.com/offer/b7b42e2078524ab386a8b2a9856ef557/EGS_SifuDeluxeEditionUpgradeBundle_Sloclap_Bundles_S1_2560x1440-43bae7aa2089289442238bd1e2b55655"); Jeu TheLastOfUs = new Jeu("The last of Us Part 1", 5, 487, "Ps5", "Aventure", "cover_lastofus1.png");
Jeu ForzaHorizon = new Jeu("Forza Horizon 5", 4, 420, "Ps4", "Course", "https://cdn.cloudflare.steamstatic.com/steam/apps/1562430/capsule_616x353.jpg?t=1682587412"); Jeu ForzaHorizon = new Jeu("Forza Horizon 5", 4, 420, "Ps4", "Course", "cover_forzahorizon5.png");
Jeu Test = new Jeu("The Legend of Zelda: Tears of the Kingdom", 5, 250, "Ps4", "Aventure", "cover_zelda.png");
ListJeu.Add(TheLastOfUs); ListJeu.Add(TheLastOfUs);
ListJeu.Add(ForzaHorizon); ListJeu.Add(ForzaHorizon);
ListJeu.Add(Test);
ListUsers.Add(user1); ListUsers.Add(user1);
return (ListJeu,ListUsers); return (ListJeu,ListUsers);
} }

@ -3,7 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:views="clr-namespace:GameAtlas.Views.Composants" xmlns:views="clr-namespace:GameAtlas.Views.Composants"
xmlns:model="clr-namespace:GameAtlas.Models"
x:Class="GameAtlas.Views.PageAcceuil" x:Class="GameAtlas.Views.PageAcceuil"
Title="ACCUEIL"> Title="ACCUEIL">
<!-- WidthRequest="390" HeightRequest="844"> --> <!-- WidthRequest="390" HeightRequest="844"> -->
@ -160,7 +159,7 @@
<VerticalStackLayout Spacing="40" BindableLayout.ItemsSource="{Binding ListJeux}"> <VerticalStackLayout Spacing="40" BindableLayout.ItemsSource="{Binding ListJeux}">
<BindableLayout.ItemTemplate> <BindableLayout.ItemTemplate>
<DataTemplate x:DataType="model:Jeu"> <DataTemplate>
<HorizontalStackLayout Grid.Row="0" Spacing="20"> <HorizontalStackLayout Grid.Row="0" Spacing="20">
<Image Source="{Binding Image}" HeightRequest="60" WidthRequest="100" Margin="25,0,0,0"/> <Image Source="{Binding Image}" HeightRequest="60" WidthRequest="100" Margin="25,0,0,0"/>
<VerticalStackLayout Spacing="15"> <VerticalStackLayout Spacing="15">
@ -190,11 +189,6 @@
</DataTemplate> </DataTemplate>
</BindableLayout.ItemTemplate> </BindableLayout.ItemTemplate>
</VerticalStackLayout> </VerticalStackLayout>
</Grid> </Grid>

@ -4,7 +4,7 @@
x:Class="GameAtlas.Views.PageJeu" x:Class="GameAtlas.Views.PageJeu"
Title="PageJeu"> Title="PageJeu">
<Grid x:Name="outerGrid" BindingContext="{Binding JeuManager}"> <Grid x:Name="outerGrid">
<Grid.Background> <Grid.Background>
<LinearGradientBrush EndPoint="1,0"> <LinearGradientBrush EndPoint="1,0">
@ -29,13 +29,13 @@
<Shadow Brush="Black" Offset="0,4" Radius="4" Opacity="0.4" /> <Shadow Brush="Black" Offset="0,4" Radius="4" Opacity="0.4" />
</Border.Shadow> </Border.Shadow>
<Frame HasShadow="False" CornerRadius="5" IsClippedToBounds="True"> <Frame HasShadow="False" CornerRadius="5" IsClippedToBounds="True">
<Image Source="{Binding JeuManager}" Aspect="AspectFill"/> <Image Source="{Binding JeuModel.Image}" Aspect="AspectFill"/>
</Frame> </Frame>
</Border> </Border>
<VerticalStackLayout Grid.Row="1" Grid.ColumnSpan="3" Padding="20" Spacing="8"> <VerticalStackLayout Grid.Row="1" Grid.ColumnSpan="3" Padding="20" Spacing="8">
<Label Text="{Binding JeuManager}" FontFamily="PTSansCBold" FontSize="14" TextColor="{StaticResource Black}"/> <Label Text="{Binding JeuModel.Nom}" FontFamily="PTSansCBold" FontSize="14" TextColor="{StaticResource Black}"/>
<Label Text="10 février 2023" FontFamily="RobotoRegular" FontSize="11" TextColor="{StaticResource Gray500}"/> <Label Text="10 février 2023" FontFamily="RobotoRegular" FontSize="11" TextColor="{StaticResource Gray500}"/>

@ -5,8 +5,7 @@ namespace GameAtlas.Views;
public partial class PageJeu : ContentPage public partial class PageJeu : ContentPage
{ {
public Jeu JeuModel { get; set; }
public Jeu jeuModel { get; set; }
public Manager JeuManager { get; set; } = new Manager(); public Manager JeuManager { get; set; } = new Manager();
@ -14,7 +13,19 @@ public partial class PageJeu : ContentPage
{ {
InitializeComponent(); InitializeComponent();
BindingContext = this; BindingContext = JeuManager;
}
public PageJeu(Jeu jeu)
{
JeuModel = jeu;
InitializeComponent();
this.BindingContext = this;
} }
async void Back_Tapped(System.Object sender, Microsoft.Maui.Controls.TappedEventArgs e) async void Back_Tapped(System.Object sender, Microsoft.Maui.Controls.TappedEventArgs e)

@ -2,7 +2,6 @@
<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:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:model="clr-namespace:GameAtlas.Models"
x:Class="GameAtlas.Views.PageParcourir" x:Class="GameAtlas.Views.PageParcourir"
Title="ECRAN DE CONNEXION" WidthRequest="390" HeightRequest="844"> Title="ECRAN DE CONNEXION" WidthRequest="390" HeightRequest="844">
@ -43,17 +42,15 @@
<Grid> <Grid>
<CollectionView ItemsSource="{Binding ListJeux}" Margin="0,10,0,0" VerticalScrollBarVisibility="Never"> <CollectionView ItemsSource="{Binding ListJeux}" Margin="0,10,0,0" VerticalScrollBarVisibility="Never">
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate x:DataType="model:Jeu"> <DataTemplate>
<Border HeightRequest="97.5" StrokeShape="RoundRectangle 5" VerticalOptions="Start" HorizontalOptions="Center"> <Border HeightRequest="97.5" StrokeShape="RoundRectangle 5" VerticalOptions="Start" HorizontalOptions="Center">
<Border.Shadow> <Border.Shadow>
<Shadow Brush="Black" Offset="0,4" Radius="4" Opacity="0.4" /> <Shadow Brush="Black" Offset="0,4" Radius="4" Opacity="0.4" />
</Border.Shadow> </Border.Shadow>
<Frame HasShadow="False" HeightRequest="97.5" CornerRadius="5" IsClippedToBounds="True"> <Frame HasShadow="False" HeightRequest="97.5" CornerRadius="5" IsClippedToBounds="True">
<Image HeightRequest="97.5" Source="{Binding Image}" Aspect="AspectFill"/> <ImageButton HeightRequest="97.5" Source="{Binding Image}" Aspect="AspectFill" Clicked="OnGame_Tapped"/>
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="OnGame_Tapped"/>
</Frame.GestureRecognizers>
</Frame> </Frame>
</Border> </Border>
</DataTemplate> </DataTemplate>

@ -12,9 +12,15 @@ public partial class PageParcourir : ContentPage
BindingContext = ParcourirManager; BindingContext = ParcourirManager;
} }
async void OnGame_Tapped(System.Object sender, Microsoft.Maui.Controls.TappedEventArgs e) async void OnGame_Tapped(System.Object sender, EventArgs e)
{ {
await Shell.Current.GoToAsync(nameof(PageJeu)); var selectedjeu = (sender as ImageButton)?.BindingContext as Jeu;
if (selectedjeu != null)
{
//await Shell.Current.GoToAsync(nameof(PageJeu(selectedjeu)); ---- Ne marche pas ----
await Navigation.PushAsync(new PageJeu(selectedjeu));
}
} }
async void Back_Tapped(System.Object sender, Microsoft.Maui.Controls.TappedEventArgs e) async void Back_Tapped(System.Object sender, Microsoft.Maui.Controls.TappedEventArgs e)

Loading…
Cancel
Save