diff --git a/.idea/misc.xml b/.idea/misc.xml index 04537b6a..575b9330 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/app/src/main/java/com/starry/myne/epub/EpubParser.kt b/app/src/main/java/com/starry/myne/epub/EpubParser.kt index 8bf9377a..bc561c39 100644 --- a/app/src/main/java/com/starry/myne/epub/EpubParser.kt +++ b/app/src/main/java/com/starry/myne/epub/EpubParser.kt @@ -40,7 +40,6 @@ import java.util.zip.ZipInputStream */ class EpubParser(private val context: Context) { - /** * Represents an EPUB document. * diff --git a/app/src/main/java/com/starry/myne/ui/screens/reader/activities/ReaderActivity.kt b/app/src/main/java/com/starry/myne/ui/screens/reader/activities/ReaderActivity.kt index 38d906df..0e1a2b3c 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/reader/activities/ReaderActivity.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/reader/activities/ReaderActivity.kt @@ -129,7 +129,13 @@ class ReaderActivity : AppCompatActivity() { } // Reader content lazy column. - ReaderContent(viewModel = viewModel, lazyListState = lazyListState) + ReaderContent( + state = viewModel.state, + lazyListState = lazyListState, + onToggleReaderMenu = { + viewModel.toggleReaderMenu() + toggleSystemBars(viewModel.state.showReaderMenu) + }) }) } } @@ -154,6 +160,25 @@ class ReaderActivity : AppCompatActivity() { // Keep screen on. window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) } + + private fun toggleSystemBars(show: Boolean) { + when (show) { + true -> showSystemBars() + false -> hideSystemBars() + } + } + + private fun showSystemBars() { + val controller = WindowInsetsControllerCompat(window, window.decorView) + controller.show(WindowInsetsCompat.Type.systemBars()) + controller.show(WindowInsetsCompat.Type.displayCutout()) + } + + private fun hideSystemBars() { + val controller = WindowInsetsControllerCompat(window, window.decorView) + controller.hide(WindowInsetsCompat.Type.systemBars()) + controller.hide(WindowInsetsCompat.Type.displayCutout()) + } } diff --git a/app/src/main/java/com/starry/myne/ui/screens/reader/composables/ReaderContent.kt b/app/src/main/java/com/starry/myne/ui/screens/reader/composables/ReaderContent.kt index c1d8b3d7..5855feb0 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/reader/composables/ReaderContent.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/reader/composables/ReaderContent.kt @@ -57,33 +57,31 @@ import com.starry.myne.epub.models.EpubChapter import com.starry.myne.helpers.toToast import com.starry.myne.ui.common.MyneSelectionContainer import com.starry.myne.ui.screens.reader.viewmodels.ReaderScreenState -import com.starry.myne.ui.screens.reader.viewmodels.ReaderViewModel import com.starry.myne.ui.theme.pacificoFont @Composable fun ReaderContent( - viewModel: ReaderViewModel, + state: ReaderScreenState, lazyListState: LazyListState, + onToggleReaderMenu: () -> Unit ) { LazyColumn( modifier = Modifier.fillMaxSize(), state = lazyListState ) { items( - count = viewModel.state.epubBook!!.chapters.size, - key = { index -> viewModel.state.epubBook!!.chapters[index].hashCode() } + count = state.epubBook!!.chapters.size, + key = { index -> state.epubBook.chapters[index].hashCode() } ) { index -> - val chapter = viewModel.state.epubBook!!.chapters[index] + val chapter = state.epubBook.chapters[index] ChapterLazyItemItem( chapter = chapter, - state = viewModel.state, - onClick = { viewModel.toggleReaderMenu() } + state = state, + onClick = onToggleReaderMenu ) } } - - } @Composable diff --git a/app/src/main/java/com/starry/myne/ui/screens/reader/composables/ReaderScreen.kt b/app/src/main/java/com/starry/myne/ui/screens/reader/composables/ReaderScreen.kt index b9992ca8..d092de30 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/reader/composables/ReaderScreen.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/reader/composables/ReaderScreen.kt @@ -39,6 +39,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.systemBarsPadding import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListState @@ -131,6 +132,7 @@ fun ReaderScreen( } ModalNavigationDrawer( + modifier = Modifier.systemBarsPadding(), drawerState = drawerState, gesturesEnabled = drawerState.isOpen, drawerContent = { diff --git a/app/src/main/java/com/starry/myne/ui/screens/reader/viewmodels/ReaderViewModel.kt b/app/src/main/java/com/starry/myne/ui/screens/reader/viewmodels/ReaderViewModel.kt index 97d9fef3..0e28e0fe 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/reader/viewmodels/ReaderViewModel.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/reader/viewmodels/ReaderViewModel.kt @@ -141,11 +141,7 @@ class ReaderViewModel @Inject constructor( } fun toggleReaderMenu() { - state = if (state.showReaderMenu) { - state.copy(showReaderMenu = false) - } else { - state.copy(showReaderMenu = true) - } + state = state.copy(showReaderMenu = !state.showReaderMenu) } fun hideReaderInfo() { diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml index a8e0a87e..016350f1 100644 --- a/app/src/main/res/values-night/themes.xml +++ b/app/src/main/res/values-night/themes.xml @@ -1,5 +1,12 @@ - \ No newline at end of file diff --git a/app/src/main/res/values-v27/themes.xml b/app/src/main/res/values-v27/themes.xml new file mode 100644 index 00000000..2f5e02cd --- /dev/null +++ b/app/src/main/res/values-v27/themes.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index a36adc51..f7dc55f3 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,5 +1,13 @@ - + - \ No newline at end of file