qwen edit
This commit is contained in:
@@ -25,6 +25,16 @@ public partial class BookshelfViewModel : BaseViewModel
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string _searchText = string.Empty;
|
private string _searchText = string.Empty;
|
||||||
|
|
||||||
|
partial void OnSearchTextChanged(string value)
|
||||||
|
{
|
||||||
|
// Автоматически выполняем поиск при изменении текста
|
||||||
|
if (string.IsNullOrWhiteSpace(value))
|
||||||
|
{
|
||||||
|
// Если поле пустое - загружаем все книги
|
||||||
|
LoadBooksCommand.Execute(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public BookshelfViewModel(
|
public BookshelfViewModel(
|
||||||
IDatabaseService databaseService,
|
IDatabaseService databaseService,
|
||||||
IBookParserService bookParserService,
|
IBookParserService bookParserService,
|
||||||
@@ -94,8 +104,17 @@ public partial class BookshelfViewModel : BaseViewModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
public async Task SearchAsync()
|
public async Task SearchAsync(object? parameter)
|
||||||
{
|
{
|
||||||
|
// Если параметр пустой или null, используем текущий SearchText
|
||||||
|
var searchText = parameter?.ToString() ?? SearchText;
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(searchText))
|
||||||
|
{
|
||||||
|
// Очищаем поиск и загружаем все книги
|
||||||
|
SearchText = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
await LoadBooksAsync();
|
await LoadBooksAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,9 @@
|
|||||||
|
|
||||||
<!-- Search Bar -->
|
<!-- Search Bar -->
|
||||||
<SearchBar Grid.Row="0"
|
<SearchBar Grid.Row="0"
|
||||||
Text="{Binding SearchText}"
|
Text="{Binding SearchText, Mode=TwoWay}"
|
||||||
SearchCommand="{Binding SearchCommand}"
|
SearchCommand="{Binding SearchCommand}"
|
||||||
|
SearchCommandParameter="{Binding Text, Source={RelativeSource Self}}"
|
||||||
Placeholder="Search by title or author..."
|
Placeholder="Search by title or author..."
|
||||||
PlaceholderColor="#A1887F"
|
PlaceholderColor="#A1887F"
|
||||||
TextColor="White"
|
TextColor="White"
|
||||||
|
|||||||
Reference in New Issue
Block a user