edit
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user