diff --git a/androidVariant/src/main/java/org/comixedproject/variant/android/view/reading/ReadingPageView.kt b/androidVariant/src/main/java/org/comixedproject/variant/android/view/reading/PageNavigationView.kt similarity index 53% rename from androidVariant/src/main/java/org/comixedproject/variant/android/view/reading/ReadingPageView.kt rename to androidVariant/src/main/java/org/comixedproject/variant/android/view/reading/PageNavigationView.kt index c7e2e4d..c2184c0 100644 --- a/androidVariant/src/main/java/org/comixedproject/variant/android/view/reading/ReadingPageView.kt +++ b/androidVariant/src/main/java/org/comixedproject/variant/android/view/reading/PageNavigationView.kt @@ -20,16 +20,17 @@ package org.comixedproject.variant.android.view.reading import android.graphics.BitmapFactory import androidx.compose.foundation.Image +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.material3.BottomAppBar +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Scaffold import androidx.compose.material3.Slider import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -43,6 +44,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import org.comixedproject.variant.adaptor.ArchiveAPI @@ -51,42 +53,33 @@ import org.comixedproject.variant.android.R import org.comixedproject.variant.android.VariantTheme import org.comixedproject.variant.platform.Log -private const val TAG = "ReadingPageView" +private const val TAG = "PageNavigationView" @Composable -fun ReadingPageView( +fun PageNavigationView( comicFilename: String, + comicTitle: String, pageFilename: String, title: String, currentPage: Int, totalPages: Int, + showPageOverlay: Boolean, onChangePage: (Int) -> Unit, onStopReading: () -> Unit, + onToggleShowOverlay: () -> Unit, modifier: Modifier = Modifier ) { var currentPageContent by remember { mutableStateOf(null) } - Scaffold( - content = { padding -> - if (currentPageContent == null) { - LaunchedEffect(currentPageContent) { - currentPageContent = - ArchiveAPI.loadPage(comicFilename, pageFilename) - } - } else { - currentPageContent?.let { content -> - Image( - bitmap = BitmapFactory.decodeByteArray(content, 0, content.size) - .asImageBitmap(), - contentDescription = title, - modifier = Modifier - .padding(padding) - .fillMaxHeight() - ) - } + Column( + modifier = modifier + .verticalScroll(rememberScrollState()) + .clickable { + Log.debug(TAG, "Page tapped") + onToggleShowOverlay() } - }, - topBar = { + .fillMaxSize()) { + if (showPageOverlay) { Row( verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth() @@ -107,69 +100,113 @@ fun ReadingPageView( } Text( - title, + text = comicTitle, style = MaterialTheme.typography.titleMedium, + textAlign = TextAlign.Center, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.fillMaxWidth() ) } - }, - bottomBar = { - BottomAppBar { - Row(modifier = Modifier.fillMaxWidth()) { - IconButton(onClick = { - currentPageContent = null - onChangePage(currentPage - 1) - }, enabled = (currentPage > 0)) { - Icon( - painterResource(R.drawable.ic_previous_page), - contentDescription = stringResource(R.string.previousPageLabel) - ) - } - Slider( - value = currentPage.toFloat(), - valueRange = 0f..(totalPages - 1).toFloat(), - steps = totalPages, - onValueChange = { - currentPageContent = null - onChangePage(it.toInt()) - }, - modifier = Modifier.weight(0.9f) + Text( + text = pageFilename, + style = MaterialTheme.typography.titleSmall, + textAlign = TextAlign.Center, + maxLines = 1, overflow = TextOverflow.Ellipsis, + modifier = Modifier.fillMaxWidth() + ) + Row(modifier = Modifier.fillMaxWidth()) { + IconButton(onClick = { + currentPageContent = null + onChangePage(currentPage - 1) + }, enabled = (currentPage > 0)) { + Icon( + painterResource(R.drawable.ic_previous_page), + contentDescription = stringResource(R.string.previousPageLabel) ) + } - IconButton(onClick = { + Slider( + value = currentPage.toFloat(), + valueRange = 0f..(totalPages - 1).toFloat(), + steps = totalPages, + onValueChange = { currentPageContent = null - onChangePage(currentPage + 1) - }, enabled = (currentPage < (totalPages - 1))) { - Icon( - painterResource(R.drawable.ic_next_page), - contentDescription = stringResource(R.string.nextPageLabel) - ) - } + onChangePage(it.toInt()) + }, + modifier = Modifier.weight(0.9f) + ) + + IconButton(onClick = { + currentPageContent = null + onChangePage(currentPage + 1) + }, enabled = (currentPage < (totalPages - 1))) { + Icon( + painterResource(R.drawable.ic_next_page), + contentDescription = stringResource(R.string.nextPageLabel) + ) } } - }, - modifier = modifier - .fillMaxSize() - ) + } + + + if (currentPageContent == null) { + LaunchedEffect(currentPageContent) { + currentPageContent = + ArchiveAPI.loadPage(comicFilename, pageFilename) + } + } else { + currentPageContent?.let { content -> + Image( + bitmap = BitmapFactory.decodeByteArray(content, 0, content.size) + .asImageBitmap(), + contentDescription = title, + modifier = modifier + .fillMaxHeight() + ) + } + } + } } @Composable @Preview -fun ReadingPageViewPreview() { +fun PageNavigationPreview() { val comic = COMIC_BOOK_LIST.get(0) + VariantTheme { - ReadingPageView( + PageNavigationView( + comic.path, comic.filename, comic.pages.get(0).filename, "Page Title", 5, 10, + false, + onChangePage = {}, + onStopReading = {}, + onToggleShowOverlay = {}) + } +} + +@Composable +@Preview +fun PageNavigationPreviewWithOverlay() { + val comic = COMIC_BOOK_LIST.get(0) + + VariantTheme { + PageNavigationView( + comic.path, + comic.metadata.title, + comic.pages.get(0).filename, + "Page Title", + 5, + 10, + true, onChangePage = {}, - onStopReading = {} - ) + onStopReading = {}, + onToggleShowOverlay = {}) } } \ No newline at end of file diff --git a/androidVariant/src/main/java/org/comixedproject/variant/android/view/reading/ReadingView.kt b/androidVariant/src/main/java/org/comixedproject/variant/android/view/reading/ReadingView.kt index 70e4fb6..d876183 100644 --- a/androidVariant/src/main/java/org/comixedproject/variant/android/view/reading/ReadingView.kt +++ b/androidVariant/src/main/java/org/comixedproject/variant/android/view/reading/ReadingView.kt @@ -21,6 +21,7 @@ package org.comixedproject.variant.android.view.reading import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier @@ -33,20 +34,31 @@ import org.comixedproject.variant.platform.Log private const val TAG = "ReadingView" @Composable -fun ReadingView(comicBook: ComicBook, onStopReading: () -> Unit, modifier: Modifier = Modifier) { +fun ReadingView( + comicBook: ComicBook, + onStopReading: () -> Unit, + modifier: Modifier = Modifier +) { var currentPage by remember { mutableIntStateOf(0) } + var showPageOverlay by remember { mutableStateOf(false) } - ReadingPageView( + PageNavigationView( comicBook.path, + comicBook.filename, comicBook.pages.get(currentPage).filename, comicBook.pages.get(currentPage).filename, currentPage, comicBook.pages.size, + showPageOverlay, onChangePage = { Log.debug(TAG, "Going to page ${it}") currentPage = it }, onStopReading = onStopReading, + onToggleShowOverlay = { + Log.debug(TAG, "Toggling showing overlay") + showPageOverlay = !showPageOverlay + }, modifier = modifier ) } diff --git a/iosVariant/Variant.xcodeproj/project.pbxproj b/iosVariant/Variant.xcodeproj/project.pbxproj index 97125f0..7089c80 100644 --- a/iosVariant/Variant.xcodeproj/project.pbxproj +++ b/iosVariant/Variant.xcodeproj/project.pbxproj @@ -16,7 +16,6 @@ 6AA5984C2DE72EF40078CC9F /* Fixtures.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AA5984B2DE72EF40078CC9F /* Fixtures.swift */; }; 6AA598502DE73A8F0078CC9F /* EditServerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AA5984F2DE73A8F0078CC9F /* EditServerView.swift */; }; 6AF012932E1DDF67001A6A19 /* ReadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AF012922E1DDF67001A6A19 /* ReadingView.swift */; }; - 6AF012952E1E89A3001A6A19 /* ReadingPageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AF012942E1E89A3001A6A19 /* ReadingPageView.swift */; }; 7555FF83242A565900829871 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* HomeView.swift */; }; B62AADC32DFDDF01000BCC0C /* DirectoryEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = B62AADC22DFDDF01000BCC0C /* DirectoryEntry.swift */; }; B67F711E2E1848A1005BFB6B /* ImageLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = B67F711D2E1848A1005BFB6B /* ImageLoader.swift */; }; @@ -26,6 +25,7 @@ B68FF2E92E0834980010853B /* ComicBooksView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B68FF2E82E0834980010853B /* ComicBooksView.swift */; }; B68FF2EB2E0834EF0010853B /* ComicBookListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B68FF2EA2E0834EF0010853B /* ComicBookListView.swift */; }; B68FF2ED2E0837610010853B /* ComicBookListItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B68FF2EC2E0837610010853B /* ComicBookListItemView.swift */; }; + B6A363ED2E456E5600E9D270 /* PageNavigationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6A363EC2E456E5600E9D270 /* PageNavigationView.swift */; }; B6AEB7952E1024FC003FB705 /* AppDestination.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6AEB7942E1024FC003FB705 /* AppDestination.swift */; }; B6AEB7972E102901003FB705 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6AEB7962E102901003FB705 /* SettingsView.swift */; }; B6B20B942DE5048E008598A7 /* KMPObservableViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6B20B932DE5048E008598A7 /* KMPObservableViewModel.swift */; }; @@ -57,7 +57,6 @@ 6AA5984B2DE72EF40078CC9F /* Fixtures.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Fixtures.swift; sourceTree = ""; }; 6AA5984F2DE73A8F0078CC9F /* EditServerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditServerView.swift; sourceTree = ""; }; 6AF012922E1DDF67001A6A19 /* ReadingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReadingView.swift; sourceTree = ""; }; - 6AF012942E1E89A3001A6A19 /* ReadingPageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReadingPageView.swift; sourceTree = ""; }; 7555FF7B242A565900829871 /* Variant.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Variant.app; sourceTree = BUILT_PRODUCTS_DIR; }; 7555FF82242A565900829871 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = ""; }; 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -69,6 +68,7 @@ B68FF2E82E0834980010853B /* ComicBooksView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComicBooksView.swift; sourceTree = ""; }; B68FF2EA2E0834EF0010853B /* ComicBookListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComicBookListView.swift; sourceTree = ""; }; B68FF2EC2E0837610010853B /* ComicBookListItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComicBookListItemView.swift; sourceTree = ""; }; + B6A363EC2E456E5600E9D270 /* PageNavigationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageNavigationView.swift; sourceTree = ""; }; B6AEB7942E1024FC003FB705 /* AppDestination.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDestination.swift; sourceTree = ""; }; B6AEB7962E102901003FB705 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = ""; }; B6B20B932DE5048E008598A7 /* KMPObservableViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMPObservableViewModel.swift; sourceTree = ""; }; @@ -108,7 +108,7 @@ isa = PBXGroup; children = ( 6AF012922E1DDF67001A6A19 /* ReadingView.swift */, - 6AF012942E1E89A3001A6A19 /* ReadingPageView.swift */, + B6A363EC2E456E5600E9D270 /* PageNavigationView.swift */, ); path = Reading; sourceTree = ""; @@ -322,6 +322,7 @@ B6B20B9E2DE50C0E008598A7 /* Koin.swift in Sources */, B68FF2E92E0834980010853B /* ComicBooksView.swift in Sources */, 6A4D18062E14191D00FF9EA2 /* Constants.swift in Sources */, + B6A363ED2E456E5600E9D270 /* PageNavigationView.swift in Sources */, B68922532DFDC29400BDC032 /* DirectoryItemView.swift in Sources */, 6AA598492DE72E910078CC9F /* ServerView.swift in Sources */, B6AEB7972E102901003FB705 /* SettingsView.swift in Sources */, @@ -330,7 +331,6 @@ B6B20B942DE5048E008598A7 /* KMPObservableViewModel.swift in Sources */, B689224F2DFDA77C00BDC032 /* BrowseServerView.swift in Sources */, B6AEB7952E1024FC003FB705 /* AppDestination.swift in Sources */, - 6AF012952E1E89A3001A6A19 /* ReadingPageView.swift in Sources */, B68FF2EB2E0834EF0010853B /* ComicBookListView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/iosVariant/iosVariant/Views/Reading/PageNavigationView.swift b/iosVariant/iosVariant/Views/Reading/PageNavigationView.swift new file mode 100644 index 0000000..84c48d0 --- /dev/null +++ b/iosVariant/iosVariant/Views/Reading/PageNavigationView.swift @@ -0,0 +1,184 @@ +/* + * Variant - A digital comic book reading application for the iPad and Android tablets. + * Copyright (C) 2025, The ComiXed Project + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +import KMPObservableViewModelSwiftUI +import SwiftUI +import shared + +private let TAG = "PageNavigationView" + +struct PageNavigationView: View { + @ObservedObject var imageLoader: ImageLoader + @Binding var pageNumber: Double + + let comicFilename: String + let comicTitle: String + let pageFilename: String + let title: String + let totalPages: Double + let showPageOverlay: Bool + + var onStopReading: () -> Void + var onToggleShowOverlay: (Bool) -> Void + + init( + comicFilename: String, + comicTitle: String, + pageFilename: String, + title: String, + pageNumber: Binding, + totalPages: Int, + showPageOverlay: Bool, + onStopReading: @escaping () -> Void, + onToggleShowOverlay: @escaping (Bool) -> Void + ) { + self.comicFilename = comicFilename + self.comicTitle = comicTitle + self.pageFilename = pageFilename + self.title = title + self._pageNumber = pageNumber + self.totalPages = Double(totalPages) + self.showPageOverlay = showPageOverlay + self.onStopReading = onStopReading + self.onToggleShowOverlay = onToggleShowOverlay + + self.imageLoader = ImageLoader( + comicFilename: self.comicFilename, + pageFileanme: self.pageFilename + ) + } + + var maxPage: Double { + return self.totalPages - 1 + } + + var body: some View { + NavigationStack { + ScrollView { + VStack(alignment: .leading) { + if showPageOverlay { + VStack(alignment: .center) { + Text(comicTitle).font(.headline).frame( + maxWidth: .infinity + ) + Text(pageFilename).font(.subheadline).frame( + maxWidth: .infinity + ) + } + HStack(alignment: .center) { + Button { + Log().info( + tag: TAG, + message: "Going to previous page" + ) + self.pageNumber = self.pageNumber - 1 + } label: { + Image("previous_page") + } + .disabled(pageNumber == 0) + + Slider( + value: $pageNumber, + in: 0...maxPage, + step: 1, + onEditingChanged: { editing in + if !editing { + Log().debug( + tag: TAG, + message: + "Going to page \(pageNumber)" + ) + } + } + ) + + Button { + Log().info( + tag: TAG, + message: "Going to next page" + ) + self.pageNumber = self.pageNumber + 1 + } label: { + Image("next_page") + } + .disabled(pageNumber == (totalPages - 1)) + } + } + + if imageLoader.image != nil { + Image(uiImage: imageLoader.image!) + .resizable() + .aspectRatio(contentMode: .fill) + .onTapGesture { + Log().debug( + tag: TAG, + message: "Comic page tapped" + ) + onToggleShowOverlay(!showPageOverlay) + } + } else { + Image(systemName: "placeholdertext.fill") + .resizable() + .aspectRatio(contentMode: .fill) + } + } + .toolbar { + if showPageOverlay { + ToolbarItem(placement: .topBarLeading) { + Button("Close") { + Log().info( + tag: TAG, + message: "Closing comic book" + ) + onStopReading() + } + } + } + } + } + } + } +} + +#Preview("normal") { + PageNavigationView( + comicFilename: COMIC_BOOK_LIST[0].filename, + comicTitle: COMIC_BOOK_LIST[0].filename, + pageFilename: (COMIC_BOOK_LIST[0].pages[0] as! ComicPage).filename, + title: (COMIC_BOOK_LIST[0].pages[0] as! ComicPage).filename, + pageNumber: .constant(5.0), + totalPages: 10, + showPageOverlay: false, + onStopReading: {}, + onToggleShowOverlay: { _ in } + ) +} + +#Preview("withOverlay") { + PageNavigationView( + comicFilename: COMIC_BOOK_LIST[0].filename, + comicTitle: COMIC_BOOK_LIST[0].filename, + pageFilename: (COMIC_BOOK_LIST[0].pages[0] as! ComicPage).filename, + title: (COMIC_BOOK_LIST[0].pages[0] as! ComicPage).filename, + pageNumber: .constant(5.0), + totalPages: 10, + showPageOverlay: true, + onStopReading: {}, + onToggleShowOverlay: { _ in } + ) +} diff --git a/iosVariant/iosVariant/Views/Reading/ReadingPageView.swift b/iosVariant/iosVariant/Views/Reading/ReadingPageView.swift deleted file mode 100644 index 04fe980..0000000 --- a/iosVariant/iosVariant/Views/Reading/ReadingPageView.swift +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Variant - A digital comic book reading application for the iPad and Android tablets. - * Copyright (C) 2025, The ComiXed Project - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see - */ - -import SwiftUI -import shared - -private let TAG = "ReadingPageView" - -struct ReadingPageView: View { - @ObservedObject var imageLoader: ImageLoader - @Binding var pageNumber: Double - - let comicFilename: String - let pageFilename: String - let title: String - let totalPages: Double - - var onStopReading: () -> Void - - init( - comicFilename: String, - pageFilename: String, - title: String, - pageNumber: Binding, - totalPages: Int, - onStopReading: @escaping () -> Void - ) { - self.comicFilename = comicFilename - self.pageFilename = pageFilename - self.title = title - self._pageNumber = pageNumber - self.totalPages = Double(totalPages) - self.onStopReading = onStopReading - - self.imageLoader = ImageLoader( - comicFilename: self.comicFilename, - pageFileanme: self.pageFilename - ) - } - - var maxPage: Double { - return self.totalPages - 1 - } - - var body: some View { - NavigationStack { - ScrollView { - VStack(alignment: .leading) { - if imageLoader.image != nil { - Image(uiImage: imageLoader.image!) - .resizable() - .aspectRatio(contentMode: .fill) - } else { - Image(systemName: "placeholdertext.fill") - .resizable() - .aspectRatio(contentMode: .fill) - } - - HStack(alignment: .center) { - Button { - Log().info( - tag: TAG, - message: "Going to previous page" - ) - self.pageNumber = self.pageNumber - 1 - } label: { - Image("previous_page") - } - .disabled(pageNumber == 0) - - Slider( - value: $pageNumber, - in: 0...maxPage, - step: 1, - onEditingChanged: { editing in - if !editing { - Log().debug( - tag: TAG, - message: "Going to page \(pageNumber)" - ) - } - } - ) - - Button { - Log().info(tag: TAG, message: "Going to next page") - self.pageNumber = self.pageNumber + 1 - } label: { - Image("next_page") - } - .disabled(pageNumber == (totalPages - 1)) - } - } - .onTapGesture { - Log().debug(tag: TAG, message: "Comic page tapped") - } - .navigationTitle(title) - .toolbar { - ToolbarItem(placement: .topBarLeading) { - Button("Close") { - Log().info( - tag: TAG, - message: "Closing comic book" - ) - onStopReading() - } - } - } - } - } - } -} - -#Preview { - ReadingPageView( - comicFilename: COMIC_BOOK_LIST[0].filename, - pageFilename: (COMIC_BOOK_LIST[0].pages[0] as! ComicPage).filename, - title: (COMIC_BOOK_LIST[0].pages[0] as! ComicPage).filename, - pageNumber: .constant(5.0), - totalPages: 10, - onStopReading: {} - ) -} diff --git a/iosVariant/iosVariant/Views/Reading/ReadingView.swift b/iosVariant/iosVariant/Views/Reading/ReadingView.swift index 762875d..6ac3891 100644 --- a/iosVariant/iosVariant/Views/Reading/ReadingView.swift +++ b/iosVariant/iosVariant/Views/Reading/ReadingView.swift @@ -24,6 +24,7 @@ private let TAG = "ReadingView" struct ReadingView: View { @State private var currentPage = 0.0 + @State private var showPageOverlay = false let comicBook: ComicBook @@ -33,6 +34,10 @@ struct ReadingView: View { return comicBook.path } + var comicTitle: String { + return comicBook.filename + } + var pageFilename: String { return (comicBook.pages[Int(currentPage)] as! ComicPage).filename } @@ -42,13 +47,22 @@ struct ReadingView: View { } var body: some View { - ReadingPageView( + PageNavigationView( comicFilename: comicFilename, + comicTitle: comicTitle, pageFilename: pageFilename, title: title, pageNumber: $currentPage, totalPages: comicBook.pages.count, - onStopReading: { onStopReading() } + showPageOverlay: showPageOverlay, + onStopReading: { onStopReading() }, + onToggleShowOverlay: { enable in + Log().debug( + tag: TAG, + message: "Setting show overlay to \(enable)" + ) + showPageOverlay = enable + } ) } }