qwen edit
This commit is contained in:
@@ -19,9 +19,6 @@ public partial class BookshelfViewModel : BaseViewModel
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool _isEmpty;
|
private bool _isEmpty;
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
private bool _isRefreshing;
|
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string _searchText = string.Empty;
|
private string _searchText = string.Empty;
|
||||||
|
|
||||||
@@ -53,7 +50,6 @@ public partial class BookshelfViewModel : BaseViewModel
|
|||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
public async Task LoadBooksAsync()
|
public async Task LoadBooksAsync()
|
||||||
{
|
{
|
||||||
if (IsBusy) return;
|
|
||||||
IsBusy = true;
|
IsBusy = true;
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -87,22 +83,6 @@ public partial class BookshelfViewModel : BaseViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
|
||||||
public async Task RefreshBooksAsync()
|
|
||||||
{
|
|
||||||
if (IsRefreshing) return;
|
|
||||||
IsRefreshing = true;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await LoadBooksAsync();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
IsRefreshing = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
public async Task SearchAsync(object? parameter)
|
public async Task SearchAsync(object? parameter)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -65,10 +65,7 @@
|
|||||||
HorizontalTextAlignment="Center" />
|
HorizontalTextAlignment="Center" />
|
||||||
</VerticalStackLayout>
|
</VerticalStackLayout>
|
||||||
|
|
||||||
<!-- Book Collection with PullToRefresh -->
|
<!-- Book Collection -->
|
||||||
<RefreshView Command="{Binding RefreshBooksCommand}"
|
|
||||||
IsRefreshing="{Binding IsRefreshing}"
|
|
||||||
IsVisible="{Binding IsEmpty, Converter={StaticResource InvertedBoolConverter}}">
|
|
||||||
<CollectionView ItemsSource="{Binding Books}"
|
<CollectionView ItemsSource="{Binding Books}"
|
||||||
SelectionMode="None"
|
SelectionMode="None"
|
||||||
Margin="10">
|
Margin="10">
|
||||||
@@ -157,16 +154,6 @@
|
|||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</CollectionView.ItemTemplate>
|
</CollectionView.ItemTemplate>
|
||||||
</CollectionView>
|
</CollectionView>
|
||||||
</RefreshView>
|
|
||||||
|
|
||||||
<!-- Loading Indicator -->
|
|
||||||
<ActivityIndicator IsRunning="{Binding IsBusy}"
|
|
||||||
IsVisible="{Binding IsBusy}"
|
|
||||||
Color="#FF8A65"
|
|
||||||
VerticalOptions="Center"
|
|
||||||
HorizontalOptions="Center"
|
|
||||||
HeightRequest="50"
|
|
||||||
WidthRequest="50" />
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<!-- Bottom Shelf / Action Bar -->
|
<!-- Bottom Shelf / Action Bar -->
|
||||||
|
|||||||
@@ -16,10 +16,14 @@ public partial class BookshelfPage : ContentPage
|
|||||||
BindingContext = viewModel;
|
BindingContext = viewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async void OnAppearing()
|
protected override void OnAppearing()
|
||||||
{
|
{
|
||||||
base.OnAppearing();
|
base.OnAppearing();
|
||||||
await _viewModel.LoadBooksCommand.ExecuteAsync(null);
|
// Загружаем книги только если коллекция пуста
|
||||||
|
if (_viewModel.Books.Count == 0)
|
||||||
|
{
|
||||||
|
_ = _viewModel.LoadBooksCommand.ExecuteAsync(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OnMenuClicked(object? sender, EventArgs e)
|
private async void OnMenuClicked(object? sender, EventArgs e)
|
||||||
|
|||||||
Reference in New Issue
Block a user