Barre de recherche effective pour les Fruits du demon
continuous-integration/drone/push Build is passing Details

devGuillaume
Yoan 2 years ago
parent ce24ff2b01
commit bec919bf99

@ -55,5 +55,34 @@ namespace Model
}
return fdd;
}
public List<FruitDuDemon> RechercheFDD(string text,List<FruitDuDemon> listeFDD)
{
if (text == "") {
return listeFDD;
}
foreach(FruitDuDemon f in listeFDD.ToList())
{
bool correspondance = false;
int textPos = 0;
for (int i = 0; i < (f.Nom.Length); i++) {
if (string.Equals(text[textPos].ToString(), f.Nom[i].ToString(), StringComparison.OrdinalIgnoreCase))
{
textPos++;
}
if(textPos == text.Length)
{
correspondance = true;
break;
}
}
if (!correspondance)
{
listeFDD.Remove(f);
}
}
return listeFDD;
}
}
}

@ -34,6 +34,7 @@
<Button Style="{StaticResource buttonMenu}" Text="Équipages" Clicked="Hyperlink_Equip"/>
</VerticalStackLayout>
<VerticalStackLayout Grid.Row="0" Grid.Column="1" Spacing="10">
<Grid BackgroundColor="#72a3b3" Padding="10" ColumnSpacing="50" >
<Grid.RowDefinitions>
<RowDefinition Height="10*"/>
@ -46,7 +47,17 @@
</Grid.ColumnDefinitions>
<SearchBar Placeholder="Rechercher..." BackgroundColor="#bfe5ef" Grid.Column="0" x:Name="searchBar" />
<Button Text="Filtrer" x:Name="Logia" BackgroundColor="#bfe5ef" BorderColor="#bfe5ef" Grid.Column="2"/>
<Frame Grid.Column="2" BackgroundColor="#bfe5ef" BorderColor="#bfe5ef" >
<Label Text="Filtrer" />
<FlyoutBase.ContextFlyout>
<MenuFlyout >
<MenuFlyoutItem x:Name="Logia" Text="Logia" />
</MenuFlyout>
</FlyoutBase.ContextFlyout>
</Frame>
@ -102,4 +113,5 @@
</VerticalStackLayout>
</Grid>
</ContentPage>

@ -17,12 +17,22 @@ public partial class PageFDD : ContentPage
listeFDD.ItemsSource = manager.GetFruits();
void OnTextChanged(object sender, EventArgs e)
{
SearchBar searchBar = (SearchBar)sender;
listeFDD.ItemsSource = manager.RechercheFDD(searchBar.Text,manager.GetFruits());
}
searchBar.TextChanged += OnTextChanged;
FiltrerType = new Command((type) => listeFDD.ItemsSource = manager.FiltrerFDD(type.ToString()));
Logia.Command = FiltrerType;
Logia.CommandParameter = "Logia";
}
private void listeFDD_ScrollToRequested(object sender, ScrollToRequestEventArgs e)
{
@ -58,4 +68,14 @@ public partial class PageFDD : ContentPage
{
await Navigation.PushAsync(new PageIle());
}
private void MenuFlyoutItem_Clicked(object sender, EventArgs e)
{
}
private void Label_Focused(object sender, FocusEventArgs e)
{
}
}
Loading…
Cancel
Save