This commit is contained in:
Курнат Андрей
2026-02-17 20:37:27 +03:00
parent ee0fa14ee7
commit e2f50bf57e
6 changed files with 246 additions and 265 deletions

View File

@@ -39,13 +39,26 @@ public partial class ReaderViewModel : BaseViewModel
[ObservableProperty]
private int _chapterTotalPages = 1;
[ObservableProperty]
private int _currentPage = 1;
[ObservableProperty]
private int _totalPages = 1;
// Это свойство будет обновляться автоматически при изменении любого из полей выше
public string ChapterProgressText => $"{ChapterCurrentPage} из {ChapterTotalPages}";
// Это свойство будет обновляться автоматически при изменении любого из полей выше
public string ProgressText => $"{CurrentPage} из {TotalPages}";
// Чтобы ChapterProgressText уведомлял интерфейс, добавим частичные методы (особенность Toolkit)
partial void OnChapterCurrentPageChanged(int value) => OnPropertyChanged(nameof(ChapterProgressText));
partial void OnChapterTotalPagesChanged(int value) => OnPropertyChanged(nameof(ChapterProgressText));
// Чтобы ProgressText уведомлял интерфейс, добавим частичные методы (особенность Toolkit)
partial void OnCurrentPageChanged(int value) => OnPropertyChanged(nameof(ProgressText));
partial void OnTotalPagesChanged(int value) => OnPropertyChanged(nameof(ProgressText));
public List<string> AvailableFonts { get; } = new()
{
"serif",
@@ -130,6 +143,14 @@ public partial class ReaderViewModel : BaseViewModel
IsMenuVisible = false;
}
public async Task SaveLocationsAsync(string locations)
{
if (Book == null) return;
Book.Locations = locations;
// Сохраняем в базу данных
await _databaseService.UpdateBookAsync(Book);
}
public async Task SaveProgressAsync(double progress, string? cfi, string? chapter, int currentPage, int totalPages)
{
if (Book == null) return;
@@ -172,6 +193,11 @@ public partial class ReaderViewModel : BaseViewModel
return Book?.LastCfi;
}
public string? GetLocations()
{
return Book?.Locations;
}
private static string EscapeJs(string value)
{
return value.Replace("\\", "\\\\").Replace("'", "\\'").Replace("\n", "\\n").Replace("\r", "\\r");