Added search feature
This commit is contained in:
@@ -48,6 +48,7 @@ public partial class DocumentItem : UserControl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Fix on android. Theres some special Uri permission/intent needed
|
||||||
private async void ViewButtonOnClick(object? sender, RoutedEventArgs e)
|
private async void ViewButtonOnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (_document is null) return;
|
if (_document is null) return;
|
||||||
|
|||||||
@@ -9,9 +9,10 @@ namespace CritterFolio.Controls;
|
|||||||
|
|
||||||
public partial class ProfileButton : UserControl
|
public partial class ProfileButton : UserControl
|
||||||
{
|
{
|
||||||
|
|
||||||
public event EventHandler? Clicked;
|
public event EventHandler? Clicked;
|
||||||
|
|
||||||
|
public Critter? Critter { get; private set; }
|
||||||
|
|
||||||
public ProfileButton()
|
public ProfileButton()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -21,6 +22,8 @@ public partial class ProfileButton : UserControl
|
|||||||
|
|
||||||
public void Init(Critter critter)
|
public void Init(Critter critter)
|
||||||
{
|
{
|
||||||
|
Critter = critter;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var pfp = new Bitmap(critter.ProfileImagePath);
|
var pfp = new Bitmap(critter.ProfileImagePath);
|
||||||
|
|||||||
@@ -6,10 +6,14 @@
|
|||||||
x:Class="CritterFolio.Pages.HomePage">
|
x:Class="CritterFolio.Pages.HomePage">
|
||||||
<ScrollViewer HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
<ScrollViewer HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||||
<StackPanel Spacing="10">
|
<StackPanel Spacing="10">
|
||||||
<Label Classes="heading1">Critters</Label>
|
|
||||||
<StackPanel x:Name="CritterStack" HorizontalAlignment="Stretch" Spacing="10">
|
<Grid HorizontalAlignment="Stretch" ColumnDefinitions="Auto, *, Auto" ColumnSpacing="20">
|
||||||
|
<Label Classes="heading1" VerticalAlignment="Center">Critters</Label>
|
||||||
</StackPanel>
|
<TextBox Grid.Column="1" x:Name="SearchBox" Watermark="Search..." VerticalContentAlignment="Center"/>
|
||||||
|
<Button x:Name="SearchButton" Classes="icon" Grid.Column="2" Content="" VerticalAlignment="Center" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<StackPanel x:Name="CritterStack" HorizontalAlignment="Stretch" Spacing="10" />
|
||||||
<Button x:Name="AddButton" Classes="icon" HorizontalAlignment="Stretch"></Button>
|
<Button x:Name="AddButton" Classes="icon" HorizontalAlignment="Stretch"></Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
@@ -31,10 +32,34 @@ public partial class HomePage : Page
|
|||||||
CreateHeaderButtons();
|
CreateHeaderButtons();
|
||||||
|
|
||||||
AddButton.Click += AddButtonClicked;
|
AddButton.Click += AddButtonClicked;
|
||||||
|
SearchButton.Click += SearchClicked;
|
||||||
|
|
||||||
RefreshProfileButtons();
|
RefreshProfileButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SearchClicked(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(SearchBox.Text))
|
||||||
|
{
|
||||||
|
foreach (var child in CritterStack.Children)
|
||||||
|
{
|
||||||
|
if (child is ProfileButton profileButton)
|
||||||
|
{
|
||||||
|
profileButton.IsVisible = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var child in CritterStack.Children)
|
||||||
|
{
|
||||||
|
if (child is not ProfileButton profileButton) continue;
|
||||||
|
if (profileButton.Critter is null) continue;
|
||||||
|
if (!profileButton.Critter.Name.Contains(SearchBox.Text, StringComparison.CurrentCultureIgnoreCase)) profileButton.IsVisible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void CreateHeaderButtons()
|
private void CreateHeaderButtons()
|
||||||
{
|
{
|
||||||
var settingsBttn = new Button()
|
var settingsBttn = new Button()
|
||||||
|
|||||||
Reference in New Issue
Block a user