Singleton Navigation
This commit is contained in:
1 parent
660d6e32f1
commit
9d59af29c5
7 files changed
+20
-34
No files matched your search
@@ -61,8 +61,7 @@ fun GalleryPager(
|
||||
} else {
|
||||
onNavigationModeChange()
|
||||
}
|
||||
navigation.invertMode = TappingInvertMode.entries[invertMode]
|
||||
navigation.regions
|
||||
navigation.regions(TappingInvertMode.entries[invertMode])
|
||||
}
|
||||
val navigator by rememberUpdatedState(regions)
|
||||
if (isPagerType) {
|
||||
|
||||
@@ -12,7 +12,6 @@ import eu.kanade.tachiyomi.ui.reader.viewer.navigation.RightAndLeftNavigation
|
||||
import eu.kanade.tachiyomi.util.lang.invert
|
||||
|
||||
abstract class ViewerNavigation {
|
||||
|
||||
sealed class NavigationRegion(@StringRes val nameRes: Int, val colorRes: Int) {
|
||||
data object MENU : NavigationRegion(R.string.action_menu, R.color.navigation_menu)
|
||||
data object PREV : NavigationRegion(R.string.nav_zone_prev, R.color.navigation_prev)
|
||||
@@ -21,32 +20,25 @@ abstract class ViewerNavigation {
|
||||
data object RIGHT : NavigationRegion(R.string.nav_zone_right, R.color.navigation_right)
|
||||
}
|
||||
|
||||
data class Region(
|
||||
val rectF: RectF,
|
||||
val type: NavigationRegion,
|
||||
) {
|
||||
data class Region(val rectF: RectF, val type: NavigationRegion) {
|
||||
fun invert(invertMode: TappingInvertMode): Region {
|
||||
if (invertMode == TappingInvertMode.NONE) return this
|
||||
return this.copy(
|
||||
rectF = this.rectF.invert(invertMode),
|
||||
)
|
||||
return this.copy(rectF = rectF.invert(invertMode))
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract val originalRegions: List<Region>
|
||||
|
||||
val regions get() = originalRegions.map { it.invert(invertMode) }
|
||||
|
||||
var invertMode = TappingInvertMode.NONE
|
||||
fun regions(invertMode: TappingInvertMode = TappingInvertMode.NONE) = originalRegions.map { it.invert(invertMode) }
|
||||
|
||||
companion object {
|
||||
fun fromPreference(value: Int, isVertical: Boolean) = when (value) {
|
||||
1 -> LNavigation()
|
||||
2 -> KindlishNavigation()
|
||||
3 -> EdgeNavigation()
|
||||
4 -> RightAndLeftNavigation()
|
||||
5 -> DisabledNavigation()
|
||||
else -> if (isVertical) LNavigation() else RightAndLeftNavigation()
|
||||
1 -> LNavigation
|
||||
2 -> KindlishNavigation
|
||||
3 -> EdgeNavigation
|
||||
4 -> RightAndLeftNavigation
|
||||
5 -> DisabledNavigation
|
||||
else -> if (isVertical) LNavigation else RightAndLeftNavigation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -12,7 +12,6 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||
* | M | M | M | N: Next
|
||||
* +---+---+---+
|
||||
*/
|
||||
class DisabledNavigation : ViewerNavigation() {
|
||||
|
||||
override val originalRegions: List<Region> = emptyList()
|
||||
object DisabledNavigation : ViewerNavigation() {
|
||||
override val originalRegions = emptyList<Region>()
|
||||
}
|
||||
+2
-3
@@ -13,9 +13,8 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||
* | N | P | N | N: Next
|
||||
* +---+---+---+
|
||||
*/
|
||||
class EdgeNavigation : ViewerNavigation() {
|
||||
|
||||
override val originalRegions: List<Region> = listOf(
|
||||
object EdgeNavigation : ViewerNavigation() {
|
||||
override val originalRegions = listOf(
|
||||
Region(
|
||||
rectF = RectF(0f, 0f, 0.33f, 1f),
|
||||
type = NavigationRegion.NEXT,
|
||||
|
||||
+2
-3
@@ -13,9 +13,8 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||
* | P | N | N | N: Next
|
||||
* +---+---+---+
|
||||
*/
|
||||
class KindlishNavigation : ViewerNavigation() {
|
||||
|
||||
override val originalRegions: List<Region> = listOf(
|
||||
object KindlishNavigation : ViewerNavigation() {
|
||||
override val originalRegions = listOf(
|
||||
Region(
|
||||
rectF = RectF(0.33f, 0.33f, 1f, 1f),
|
||||
type = NavigationRegion.NEXT,
|
||||
|
||||
@@ -13,9 +13,8 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||
* | N | N | N | N: Next
|
||||
* +---+---+---+
|
||||
*/
|
||||
open class LNavigation : ViewerNavigation() {
|
||||
|
||||
override val originalRegions: List<Region> = listOf(
|
||||
object LNavigation : ViewerNavigation() {
|
||||
override val originalRegions = listOf(
|
||||
Region(
|
||||
rectF = RectF(0f, 0.33f, 0.33f, 0.66f),
|
||||
type = NavigationRegion.PREV,
|
||||
|
||||
+2
-3
@@ -13,9 +13,8 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||
* | N | M | P | N: Move Left
|
||||
* +---+---+---+
|
||||
*/
|
||||
class RightAndLeftNavigation : ViewerNavigation() {
|
||||
|
||||
override val originalRegions: List<Region> = listOf(
|
||||
object RightAndLeftNavigation : ViewerNavigation() {
|
||||
override val originalRegions = listOf(
|
||||
Region(
|
||||
rectF = RectF(0f, 0f, 0.33f, 1f),
|
||||
type = NavigationRegion.LEFT,
|
||||
|
||||
Reference in new issue
Block a user