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