Debut de la fonctionnalité ajouté favoris
continuous-integration/drone/push Build is passing Details

pull/15/head
Yoan BRUGIÈRE 2 years ago
parent 185db847cf
commit 6ea4177079

@ -14,11 +14,24 @@ namespace Model
{
public IDataManager DataManager { get; set; }
public ObservableCollection<Bateau> Bateaux { get; private set; }
public ObservableCollection<Bateau> Bateaux { get; set; }
public ObservableCollection<Personnage> Personnages { get; set; }
public ObservableCollection<FruitDuDemon> Fruits { get; set; }
public ObservableCollection<Ile> Iles { get; set; }
public ObservableCollection<Bestiaire> Bestiaire { get; set; }
public ObservableCollection<Equipage> Equipages { get; set; }
public ObjetOhara? SelectedItem { get; set; } = null;
public Manager() {
Bateaux = new ObservableCollection<Bateau>();
DataManager = new StubManager();
Bateaux = new ObservableCollection<Bateau>(DataManager.GetBateaux());
Personnages = new ObservableCollection<Personnage>(DataManager.GetPersonnages());
Fruits = new ObservableCollection<FruitDuDemon>(DataManager.GetFruits());
Iles = new ObservableCollection<Ile>(DataManager.GetIles());
Bestiaire = new ObservableCollection<Bestiaire>(DataManager.GetBestiaires());
Equipages = new ObservableCollection<Equipage>(DataManager.GetEquipages());
}
public List<Personnage> GetPersonnages()
@ -120,15 +133,15 @@ namespace Model
public List<ObjetOhara> GetFavoris()
{
List<ObjetOhara> listeFavoris = new List<ObjetOhara>();
listeFavoris.AddRange(GetBateaux());
listeFavoris.AddRange(GetIles());
listeFavoris.AddRange(Bateaux);
listeFavoris.AddRange(Equipages);
listeFavoris.AddRange(GetEquipages());
listeFavoris.AddRange(GetFruits());
listeFavoris.AddRange(GetBestiaires());
listeFavoris.AddRange(GetPersonnages());
foreach(ObjetOhara obj in listeFavoris.ToList())
{
if (obj.EstFavori == true)
if (obj.EstFavori == false)
{
listeFavoris.Remove(obj);
}
@ -136,9 +149,64 @@ namespace Model
return listeFavoris;
}
public void AddBateauFavoris(Bateau bateau)
public void AddFavoris(ObjetOhara obj)
{
bateau.EstFavori = true;
Type t = obj.GetType();
if (t.Equals(typeof(Bateau)))
foreach(Bateau b in Bateaux)
{
if (b.Equals(obj))
{
b.EstFavori = true;
}
}
else if (t.Equals(typeof(Equipage)))
foreach (Equipage b in Equipages)
{
if (b.Equals(obj))
{
b.EstFavori = true;
}
}
else if (t.Equals(typeof(Personnage)))
foreach (Personnage b in Personnages)
{
if (b.Equals(obj))
{
b.EstFavori = true;
}
}
else if (t.Equals(typeof(Ile)))
foreach (Ile b in Iles)
{
if (b.Equals(obj))
{
b.EstFavori = true;
}
}
else if (t.Equals(typeof(FruitDuDemon)))
foreach (FruitDuDemon b in Fruits)
{
if (b.Equals(obj))
{
b.EstFavori = true;
}
}
else if (t.Equals(typeof(Bestiaire)))
foreach (Bestiaire b in Bestiaire)
{
if (b.Equals(obj))
{
b.EstFavori = true;
}
}
}
}
}

@ -23,6 +23,17 @@ namespace Model
Image = image;
EstFavori = estFavori;
}
public override bool Equals(object? obj)
{
if (obj == null) return false;
else
{
ObjetOhara o = (ObjetOhara)obj;
return o.Nom == Nom;
}
}
}
}

@ -16,6 +16,9 @@ namespace Model.Stub
new Bateau("Sunny", "Sauzando Sani-go", 435, 321, "Le Thousand Sunny est...", "Ce bateau a pour particularités ...", "sunny.png"),
new Bateau("Vogue Merry", "Goingu Merri-go", 41, 17, "Le Vogue Merry est...", "Ce bateau a pour particularités ...", "vogue_merry.png"),
new Bateau("Moby Dick", "Mobi Dikku-go", 234, 151, "Le Moby Dick est...", "Ce bateau a pour particularités ...", "moby_dick.png"),
new Bateau("Test", "Mobi Dikku-go", 234, 151, "Le Moby Dick est...", "Ce bateau a pour particularités ...", "moby_dick.png"),
new Bateau("Test2", "Mobi Dikku-go", 234, 151, "Le Moby Dick est...", "Ce bateau a pour particularités ...", "moby_dick.png"),
};
return bateau;
}

@ -21,14 +21,14 @@
<Frame CornerRadius="20" BackgroundColor="#bfe5ef" BorderColor="#bfe5ef" Grid.Column="2">
<Label Text="Filtrer" HorizontalTextAlignment="Center" />
</Frame>
<Frame CornerRadius="20" BackgroundColor="#bfe5ef" BorderColor="#bfe5ef" Grid.Column="3">
<Label Text="Trier" HorizontalTextAlignment="Center" />
</Frame>
</Grid>
<ScrollView Orientation="Horizontal" HorizontalScrollBarVisibility="Always">
<CollectionView x:Name="listeBateau" ItemsLayout="HorizontalList" EmptyView="Aucun résultat trouvé." SelectionMode="Single" SelectionChanged="listeBateau_SelectionChanged">
<CollectionView x:Name="listeBateau" ItemsLayout="HorizontalList" EmptyView="Aucun résultat trouvé." SelectionMode="Single" SelectionChanged="listeBateau_SelectionChanged" ItemsSource="{Binding Bateaux}" >
<CollectionView.ItemTemplate>
<DataTemplate>

@ -11,12 +11,18 @@ public partial class PageBateau : ContentPage
public PageBateau()
{
InitializeComponent();
listeBateau.ItemsSource = manager.GetBateaux();
BindingContext = manager;
}
async void listeBateau_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
await Navigation.PushAsync(new PageInfoBateau((Bateau)listeBateau.SelectedItem));
manager.SelectedItem = (Bateau)listeBateau.SelectedItem;
await Navigation.PushAsync(new PageInfoBateau());
}
private void Button_Clicked(object sender, EventArgs e)
{
}
}

@ -1,20 +1,20 @@
<?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="Ohara.PageFDD"
Title="PageFDD"
BackgroundColor="#e2edf1">
<CollectionView x:Name="listeFDD" EmptyView="Aucun résultat trouvé." SelectionMode="Single" SelectionChanged="listeFDD_SelectionChanged" >
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Vertical" Span="4" HorizontalItemSpacing="15" VerticalItemSpacing="15"/>
</CollectionView.ItemsLayout>
<?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="Ohara.PageFDD"
Title="PageFDD"
BackgroundColor="#e2edf1">
<CollectionView x:Name="listeFDD" EmptyView="Aucun résultat trouvé." SelectionMode="Single" SelectionChanged="listeFDD_SelectionChanged" >
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Vertical" Span="4" HorizontalItemSpacing="15" VerticalItemSpacing="15"/>
</CollectionView.ItemsLayout>
<CollectionView.Header>
<Grid ColumnDefinitions="200,*,100,10,100" BackgroundColor="#72a3b3" Padding="10">
<SearchBar x:Name="searchBar" Placeholder="Rechercher..." BackgroundColor="#bfe5ef" Grid.Column="0"/>
<Frame CornerRadius="20" BackgroundColor="#bfe5ef" BorderColor="#bfe5ef" Grid.Column="2">
<Frame x:Name="Logia" CornerRadius="20" BackgroundColor="#bfe5ef" BorderColor="#bfe5ef" Grid.Column="2">
<Label Text="Filtrer" HorizontalTextAlignment="Center" />
</Frame>
@ -23,37 +23,37 @@
</Frame>
</Grid>
</CollectionView.Header>
<CollectionView.ItemTemplate >
<DataTemplate >
<Frame Style="{StaticResource frameObjet}">
<StackLayout Orientation="Vertical" Padding="5">
<Image
Source="{Binding Image}"
HeightRequest="280"
WidthRequest="280" />
<Label
HorizontalOptions="Center"
VerticalOptions="Start"
HorizontalTextAlignment="Center"
Text="{Binding Nom}"
FontSize="19"
TextColor="#72a3b3"
FontAttributes="Bold" />
<Label
VerticalOptions="Center"
HorizontalOptions="Center"
Text="{Binding Type}"
FontAttributes="Italic"
TextColor="#72a3b3"/>
</StackLayout>
</Frame>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</CollectionView.Header>
<CollectionView.ItemTemplate >
<DataTemplate >
<Frame Style="{StaticResource frameObjet}">
<StackLayout Orientation="Vertical" Padding="5">
<Image
Source="{Binding Image}"
HeightRequest="280"
WidthRequest="280" />
<Label
HorizontalOptions="Center"
VerticalOptions="Start"
HorizontalTextAlignment="Center"
Text="{Binding Nom}"
FontSize="19"
TextColor="#72a3b3"
FontAttributes="Bold" />
<Label
VerticalOptions="Center"
HorizontalOptions="Center"
Text="{Binding Type}"
FontAttributes="Italic"
TextColor="#72a3b3"/>
</StackLayout>
</Frame>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</ContentPage>

@ -22,8 +22,8 @@ public partial class PageFDD : ContentPage
}
searchBar.TextChanged += OnTextChanged;
FiltrerType = new Command((type) => listeFDD.ItemsSource = manager.FiltrerFDD(type.ToString()));
Logia.Command = FiltrerType;
Logia.CommandParameter = "Logia";
//Logia.Command = FiltrerType;
//Logia.CommandParameter = "Logia";
}

@ -5,18 +5,19 @@
Title="PageFavoris"
BackgroundColor="#e2edf1">
<CollectionView x:Name="listeFavs" SelectionMode="Single" SelectionChanged="listeFavs_SelectionChanged">
<CollectionView x:Name="listeFavs" SelectionMode="Single" SelectionChanged="listeFavs_SelectionChanged" EmptyView="Aucun résultat trouvé.">
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Vertical" Span="4" HorizontalItemSpacing="15" VerticalItemSpacing="15"/>
</CollectionView.ItemsLayout>
<CollectionView.Header>
<Grid ColumnDefinitions="200,*,100,10,100" BackgroundColor="#72a3b3" Padding="10">
<Grid ColumnDefinitions="200,*,100,100,10,100" BackgroundColor="#72a3b3" Padding="10">
<SearchBar x:Name="searchBar" Placeholder="Rechercher..." BackgroundColor="#bfe5ef" Grid.Column="0"/>
<Frame CornerRadius="20" BackgroundColor="#bfe5ef" BorderColor="#bfe5ef" Grid.Column="2">
<Button Text="Actualiser" Clicked="Button_Clicked" Grid.Column="2" CornerRadius="20" BackgroundColor="#bfe5ef" BorderColor="#bfe5ef"/>
<Frame CornerRadius="20" BackgroundColor="#bfe5ef" BorderColor="#bfe5ef" Grid.Column="3">
<Label Text="Filtrer" HorizontalTextAlignment="Center" />
</Frame>
<Frame CornerRadius="20" BackgroundColor="#bfe5ef" BorderColor="#bfe5ef" Grid.Column="4">
<Frame CornerRadius="20" BackgroundColor="#bfe5ef" BorderColor="#bfe5ef" Grid.Column="5">
<Label Text="Trier" HorizontalTextAlignment="Center" />
</Frame>

@ -1,40 +1,45 @@
using Model;
using Plugin.Maui.Audio;
namespace Ohara;
public partial class PageFavoris : ContentPage
{
public Manager manager => (App.Current as App).manager;
public PageFavoris()
{
InitializeComponent();
using Model;
using Plugin.Maui.Audio;
namespace Ohara;
public partial class PageFavoris : ContentPage
{
public Manager manager => (App.Current as App).manager;
public PageFavoris()
{
InitializeComponent();
listeFavs.ItemsSource = manager.GetFavoris();
void OnTextChanged(object sender, EventArgs e)
{
SearchBar searchBar = (SearchBar)sender;
listeFavs.ItemsSource = manager.RechercheObjetOhara(searchBar.Text, manager.GetFavoris());
}
searchBar.TextChanged += OnTextChanged;
}
async void listeFavs_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Type t = listeFavs.SelectedItem.GetType();
Console.WriteLine(t);
if (t.Equals(typeof(Bateau)))
await Navigation.PushAsync(new PageInfoBateau((Bateau)listeFavs.SelectedItem));
else if (t.Equals(typeof(Equipage)))
await Navigation.PushAsync(new PageInfoEquipage((Equipage)listeFavs.SelectedItem));
else if (t.Equals(typeof(Personnage)))
await Navigation.PushAsync(new PageInfoPersonnage((Personnage)listeFavs.SelectedItem));
else if (t.Equals(typeof(Ile)))
await Navigation.PushAsync(new PageInfoIle((Ile)listeFavs.SelectedItem));
else if (t.Equals(typeof(FruitDuDemon)))
await Navigation.PushAsync(new PageInfoFdd((FruitDuDemon)listeFavs.SelectedItem));
else if (t.Equals(typeof(Bestiaire)))
await Navigation.PushAsync(new PageInfoBestiaire((Bestiaire)listeFavs.SelectedItem));
}
void OnTextChanged(object sender, EventArgs e)
{
SearchBar searchBar = (SearchBar)sender;
listeFavs.ItemsSource = manager.RechercheObjetOhara(searchBar.Text, manager.GetFavoris());
}
searchBar.TextChanged += OnTextChanged;
}
async void listeFavs_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Type t = listeFavs.SelectedItem.GetType();
Console.WriteLine(t);
if (t.Equals(typeof(Bateau)))
await Navigation.PushAsync(new PageInfoBateau());
else if (t.Equals(typeof(Equipage)))
await Navigation.PushAsync(new PageInfoEquipage((Equipage)listeFavs.SelectedItem));
else if (t.Equals(typeof(Personnage)))
await Navigation.PushAsync(new PageInfoPersonnage((Personnage)listeFavs.SelectedItem));
else if (t.Equals(typeof(Ile)))
await Navigation.PushAsync(new PageInfoIle((Ile)listeFavs.SelectedItem));
else if (t.Equals(typeof(FruitDuDemon)))
await Navigation.PushAsync(new PageInfoFdd((FruitDuDemon)listeFavs.SelectedItem));
else if (t.Equals(typeof(Bestiaire)))
await Navigation.PushAsync(new PageInfoBestiaire((Bestiaire)listeFavs.SelectedItem));
}
private void Button_Clicked(object sender, EventArgs e)
{
listeFavs.ItemsSource = manager.GetBateaux();
}
}

@ -15,7 +15,7 @@
<ColumnDefinition Width="40*"/>
</Grid.ColumnDefinitions>
<VerticalStackLayout Grid.Column="0" Spacing="4">
<Button x:Name="ButtonFav" Text="Ajouter aux favoris" Style="{StaticResource buttonFavsInfo}"/>
<Button x:Name="bouttonFav" Text="Ajouter aux favoris" Style="{StaticResource buttonFavsInfo}" Clicked="AjouterFav_Clicked" />
<Frame Style="{StaticResource frameInfo}">
<Label Text="Sommaire" Style="{StaticResource titreInfo}"/>
</Frame>

@ -6,15 +6,24 @@ namespace Ohara;
public partial class PageInfoBateau : ContentPage
{
public Manager manager => (App.Current as App).manager;
public ICommand AjouterFavs { get; private set; }
public PageInfoBateau(Bateau bateau)
public PageInfoBateau()
{
InitializeComponent();
if(manager.SelectedItem.EstFavori==true)
{
bouttonFav.IsEnabled = false;
bouttonFav.Text = "Ajouté au favoris";
}
BindingContext=manager.SelectedItem;
BindingContext=bateau;
AjouterFavs = new Command(() => bateau.EstFavori = true);
ButtonFav.Command = AjouterFavs;
}
private void AjouterFav_Clicked(object sender, EventArgs e)
{
manager.AddFavoris(manager.SelectedItem);
bouttonFav.IsEnabled = false;
bouttonFav.Text = "Ajouté au favoris";
}
}

@ -671,6 +671,15 @@
<Setter Property="Padding" Value="17"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="Grey"/>
<Setter Property="TextColor" Value="White"/>
<Setter Property="FontSize" Value="20"/>
<Setter Property="Padding" Value="17"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>

@ -7,20 +7,14 @@ var manager = new Manager();
var xml = new XML_Serializer();
Bestiaire luffy = new Bestiaire("test", "", "", "");
/*
xml.SetPersonnage(manager.GetPersonnages().ToList());
xml.SetFDD(manager.GetFruits().ToList());
xml.SetBateau(manager.GetBateaux().ToList());
xml.SetBestiaire(manager.GetBestiaires().ToList());
xml.SetEquipage(manager.GetEquipages().ToList());
xml.SetIle(manager.GetIles().ToList());
*/
Bateau luffy = new Bateau("Sunny", "", 15, 15,"","");
ObjetOhara b = luffy;
Console.WriteLine(luffy.EstFavori);
manager.AddFavoris(b);
Type t = luffy.GetType();
if (t.Equals(typeof(Bestiaire)))
Console.WriteLine(luffy.Nom);
Console.WriteLine(t.Equals(typeof(Bestiaire)));
foreach(Bateau s in manager.Bateaux)
{
Console.WriteLine(s.Nom);
Console.WriteLine(s.EstFavori);
}
Loading…
Cancel
Save