From e2f50bf57ea66b15d87873f6087e0ea7555a4d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D1=83=D1=80=D0=BD=D0=B0=D1=82=20=D0=90=D0=BD=D0=B4?= =?UTF-8?q?=D1=80=D0=B5=D0=B9?= Date: Tue, 17 Feb 2026 20:37:27 +0300 Subject: [PATCH] edit --- BookReader/Models/Book.cs | 1 + BookReader/Resources/Raw/wwwroot/index.html | 428 +++++++++----------- BookReader/Services/IDatabaseService.cs | 2 + BookReader/ViewModels/ReaderViewModel.cs | 26 ++ BookReader/Views/ReaderPage.xaml | 16 +- BookReader/Views/ReaderPage.xaml.cs | 38 +- 6 files changed, 246 insertions(+), 265 deletions(-) diff --git a/BookReader/Models/Book.cs b/BookReader/Models/Book.cs index bd847b7..686c556 100644 --- a/BookReader/Models/Book.cs +++ b/BookReader/Models/Book.cs @@ -24,6 +24,7 @@ public class Book public string? LastCfi { get; set; } // CFI location for epub, or position for fb2 public string? LastChapter { get; set; } + public string? Locations { get; set; } public DateTime DateAdded { get; set; } = DateTime.UtcNow; diff --git a/BookReader/Resources/Raw/wwwroot/index.html b/BookReader/Resources/Raw/wwwroot/index.html index 59471ff..f3e6367 100644 --- a/BookReader/Resources/Raw/wwwroot/index.html +++ b/BookReader/Resources/Raw/wwwroot/index.html @@ -5,31 +5,31 @@ Book Reader
-
-
-
+
Initializing...
@@ -127,14 +126,20 @@ - + ``` + + --- + + ### JavaScript Логика + + ```javascript diff --git a/BookReader/Services/IDatabaseService.cs b/BookReader/Services/IDatabaseService.cs index 99e659d..18a52e3 100644 --- a/BookReader/Services/IDatabaseService.cs +++ b/BookReader/Services/IDatabaseService.cs @@ -1,4 +1,6 @@ using BookReader.Models; +using System.Net; +using static Android.Provider.CallLog; namespace BookReader.Services; diff --git a/BookReader/ViewModels/ReaderViewModel.cs b/BookReader/ViewModels/ReaderViewModel.cs index 899a319..5f9b0f3 100644 --- a/BookReader/ViewModels/ReaderViewModel.cs +++ b/BookReader/ViewModels/ReaderViewModel.cs @@ -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 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"); diff --git a/BookReader/Views/ReaderPage.xaml b/BookReader/Views/ReaderPage.xaml index f1cbc09..683eff9 100644 --- a/BookReader/Views/ReaderPage.xaml +++ b/BookReader/Views/ReaderPage.xaml @@ -23,7 +23,7 @@ @@ -33,10 +33,9 @@ VerticalOptions="Start" HorizontalOptions="FillAndExpand" Padding="20" - HasShadow="True" BorderColor="Transparent"> - - - + @@ -159,7 +155,7 @@ Padding="10,2" BorderColor="Transparent" HasShadow="False"> -