qwen edit

This commit is contained in:
Курнат Андрей
2026-02-18 15:58:43 +03:00
parent 5c45538c2f
commit 0d9fa23db8
3 changed files with 94 additions and 123 deletions

View File

@@ -19,9 +19,6 @@ public partial class BookshelfViewModel : BaseViewModel
[ObservableProperty]
private bool _isEmpty;
[ObservableProperty]
private bool _isRefreshing;
[ObservableProperty]
private string _searchText = string.Empty;
@@ -53,7 +50,6 @@ public partial class BookshelfViewModel : BaseViewModel
[RelayCommand]
public async Task LoadBooksAsync()
{
if (IsBusy) return;
IsBusy = true;
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]
public async Task SearchAsync(object? parameter)
{

View File

@@ -65,108 +65,95 @@
HorizontalTextAlignment="Center" />
</VerticalStackLayout>
<!-- Book Collection with PullToRefresh -->
<RefreshView Command="{Binding RefreshBooksCommand}"
IsRefreshing="{Binding IsRefreshing}"
IsVisible="{Binding IsEmpty, Converter={StaticResource InvertedBoolConverter}}">
<CollectionView ItemsSource="{Binding Books}"
SelectionMode="None"
Margin="10">
<!-- Book Collection -->
<CollectionView ItemsSource="{Binding Books}"
SelectionMode="None"
Margin="10">
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Vertical"
Span="3"
HorizontalItemSpacing="10"
VerticalItemSpacing="15" />
</CollectionView.ItemsLayout>
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Vertical"
Span="3"
HorizontalItemSpacing="10"
VerticalItemSpacing="15" />
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="models:Book">
<SwipeView>
<SwipeView.RightItems>
<SwipeItems>
<SwipeItem Text="Delete"
BackgroundColor="#D32F2F"
Command="{Binding Source={RelativeSource AncestorType={x:Type vm:BookshelfViewModel}}, Path=DeleteBookCommand}"
CommandParameter="{Binding .}" />
</SwipeItems>
</SwipeView.RightItems>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="models:Book">
<SwipeView>
<SwipeView.RightItems>
<SwipeItems>
<SwipeItem Text="Delete"
BackgroundColor="#D32F2F"
Command="{Binding Source={RelativeSource AncestorType={x:Type vm:BookshelfViewModel}}, Path=DeleteBookCommand}"
CommandParameter="{Binding .}" />
</SwipeItems>
</SwipeView.RightItems>
<Frame Padding="0"
CornerRadius="8"
BackgroundColor="#5D4037"
HasShadow="True"
BorderColor="Transparent">
<Frame.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding Source={RelativeSource AncestorType={x:Type vm:BookshelfViewModel}}, Path=OpenBookCommand}"
CommandParameter="{Binding .}" />
</Frame.GestureRecognizers>
<Frame Padding="0"
CornerRadius="8"
BackgroundColor="#5D4037"
HasShadow="True"
BorderColor="Transparent">
<Frame.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding Source={RelativeSource AncestorType={x:Type vm:BookshelfViewModel}}, Path=OpenBookCommand}"
CommandParameter="{Binding .}" />
</Frame.GestureRecognizers>
<Grid RowDefinitions="150,Auto,Auto,Auto" Padding="0">
<!-- Cover Image -->
<Frame Grid.Row="0"
Padding="0"
CornerRadius="8,8,0,0"
IsClippedToBounds="True"
HasShadow="False"
BorderColor="Transparent">
<Image Source="{Binding CoverImage, Converter={StaticResource ByteArrayToImageConverter}}"
Aspect="AspectFill"
HeightRequest="150" />
</Frame>
<Grid RowDefinitions="150,Auto,Auto,Auto" Padding="0">
<!-- Cover Image -->
<Frame Grid.Row="0"
Padding="0"
CornerRadius="8,8,0,0"
IsClippedToBounds="True"
HasShadow="False"
BorderColor="Transparent">
<Image Source="{Binding CoverImage, Converter={StaticResource ByteArrayToImageConverter}}"
Aspect="AspectFill"
HeightRequest="150" />
</Frame>
<!-- Progress Bar -->
<Grid Grid.Row="0"
VerticalOptions="End"
HeightRequest="4"
BackgroundColor="#44000000">
<BoxView BackgroundColor="#4CAF50"
HorizontalOptions="Start"
WidthRequest="{Binding ReadingProgress, Converter={StaticResource ProgressToWidthConverter}}" />
<!-- Progress Bar -->
<Grid Grid.Row="0"
VerticalOptions="End"
HeightRequest="4"
BackgroundColor="#44000000">
<BoxView BackgroundColor="#4CAF50"
HorizontalOptions="Start"
WidthRequest="{Binding ReadingProgress, Converter={StaticResource ProgressToWidthConverter}}" />
</Grid>
<!-- Title -->
<Label Grid.Row="1"
Text="{Binding Title}"
FontSize="11"
FontAttributes="Bold"
TextColor="#EFEBE9"
LineBreakMode="TailTruncation"
MaxLines="2"
Padding="5,5,5,0" />
<!-- Author -->
<Label Grid.Row="2"
Text="{Binding Author}"
FontSize="9"
TextColor="#A1887F"
LineBreakMode="TailTruncation"
MaxLines="1"
Padding="5,0,5,2" />
<!-- Progress Text -->
<Label Grid.Row="3"
Text="{Binding ProgressText}"
FontSize="9"
TextColor="#81C784"
Padding="5,0,5,5" />
</Grid>
<!-- Title -->
<Label Grid.Row="1"
Text="{Binding Title}"
FontSize="11"
FontAttributes="Bold"
TextColor="#EFEBE9"
LineBreakMode="TailTruncation"
MaxLines="2"
Padding="5,5,5,0" />
<!-- Author -->
<Label Grid.Row="2"
Text="{Binding Author}"
FontSize="9"
TextColor="#A1887F"
LineBreakMode="TailTruncation"
MaxLines="1"
Padding="5,0,5,2" />
<!-- Progress Text -->
<Label Grid.Row="3"
Text="{Binding ProgressText}"
FontSize="9"
TextColor="#81C784"
Padding="5,0,5,5" />
</Grid>
</Frame>
</SwipeView>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</RefreshView>
<!-- Loading Indicator -->
<ActivityIndicator IsRunning="{Binding IsBusy}"
IsVisible="{Binding IsBusy}"
Color="#FF8A65"
VerticalOptions="Center"
HorizontalOptions="Center"
HeightRequest="50"
WidthRequest="50" />
</Frame>
</SwipeView>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Grid>
<!-- Bottom Shelf / Action Bar -->

View File

@@ -16,10 +16,14 @@ public partial class BookshelfPage : ContentPage
BindingContext = viewModel;
}
protected override async void OnAppearing()
protected override void 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)