-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
200 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryComposeController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package eu.kanade.tachiyomi.ui.library | ||
|
||
import android.os.Bundle | ||
import androidx.compose.runtime.Composable | ||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper | ||
import eu.kanade.tachiyomi.ui.base.controller.BaseComposeController | ||
import uy.kohesive.injekt.Injekt | ||
import uy.kohesive.injekt.api.get | ||
import yokai.domain.ui.UiPreferences | ||
import yokai.presentation.library.LibraryScreen | ||
|
||
class LibraryComposeController( | ||
bundle: Bundle? = null, | ||
val uiPreferences: UiPreferences = Injekt.get(), | ||
val preferences: PreferencesHelper = Injekt.get(), | ||
) : BaseComposeController(bundle) { | ||
override val shouldHideLegacyAppBar = false | ||
|
||
@Composable | ||
override fun ScreenContent() { | ||
LibraryScreen() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
app/src/main/java/yokai/presentation/library/LibraryScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package yokai.presentation.library | ||
|
||
import androidx.compose.foundation.lazy.grid.items | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import yokai.presentation.AppBarType | ||
import yokai.presentation.YokaiScaffold | ||
import yokai.presentation.library.components.LazyLibraryGrid | ||
import yokai.util.Screen | ||
|
||
class LibraryScreen : Screen() { | ||
@Composable | ||
override fun Content() { | ||
val columns = 3 // FIXME: Retrieve from preferences | ||
val items = (0..100).toList() | ||
YokaiScaffold( | ||
onNavigationIconClicked = {}, | ||
appBarType = AppBarType.NONE, | ||
) { contentPadding -> | ||
LazyLibraryGrid( | ||
columns = columns, | ||
contentPadding = contentPadding, | ||
) { | ||
items( | ||
items = items, | ||
contentType = { "library_grid_item" } | ||
) { | ||
Text("Hello world! ($it)") | ||
} | ||
} | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
app/src/main/java/yokai/presentation/library/components/CommonMangaItem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package yokai.presentation.library.components | ||
|
||
import androidx.compose.ui.unit.dp | ||
|
||
object CommonMangaItemDefaults { | ||
val GridHorizontalSpacer = 4.dp | ||
val GridVerticalSpacer = 4.dp | ||
|
||
@Suppress("ConstPropertyName") | ||
const val BrowseFavoriteCoverAlpha = 0.34f | ||
} |
28 changes: 28 additions & 0 deletions
28
app/src/main/java/yokai/presentation/library/components/LazyLibraryGrid.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package yokai.presentation.library.components | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.lazy.grid.GridCells | ||
import androidx.compose.foundation.lazy.grid.LazyGridScope | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import yokai.presentation.core.components.FastScrollLazyVerticalGrid | ||
import yokai.presentation.core.util.plus | ||
|
||
@Composable | ||
internal fun LazyLibraryGrid( | ||
modifier: Modifier = Modifier, | ||
columns: Int, | ||
contentPadding: PaddingValues, | ||
content: LazyGridScope.() -> Unit, | ||
) { | ||
FastScrollLazyVerticalGrid( | ||
columns = if (columns == 0) GridCells.Adaptive(128.dp) else GridCells.Fixed(columns), | ||
modifier = modifier, | ||
contentPadding = contentPadding + PaddingValues(8.dp), | ||
verticalArrangement = Arrangement.spacedBy(CommonMangaItemDefaults.GridVerticalSpacer), | ||
horizontalArrangement = Arrangement.spacedBy(CommonMangaItemDefaults.GridHorizontalSpacer), | ||
content = content, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
presentation/core/src/main/java/yokai/presentation/core/components/LazyGrid.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package yokai.presentation.core.components | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.lazy.grid.GridCells | ||
import androidx.compose.foundation.lazy.grid.LazyGridScope | ||
import androidx.compose.foundation.lazy.grid.LazyGridState | ||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid | ||
import androidx.compose.foundation.lazy.grid.rememberLazyGridState | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
|
||
@Composable | ||
fun FastScrollLazyVerticalGrid( | ||
columns: GridCells, | ||
modifier: Modifier = Modifier, | ||
state: LazyGridState = rememberLazyGridState(), | ||
thumbAllowed: () -> Boolean = { true }, | ||
thumbColor: Color = MaterialTheme.colorScheme.primary, | ||
contentPadding: PaddingValues = PaddingValues(0.dp), | ||
topContentPadding: Dp = Dp.Hairline, | ||
bottomContentPadding: Dp = Dp.Hairline, | ||
endContentPadding: Dp = Dp.Hairline, | ||
reverseLayout: Boolean = false, | ||
verticalArrangement: Arrangement.Vertical = | ||
if (!reverseLayout) Arrangement.Top else Arrangement.Bottom, | ||
horizontalArrangement: Arrangement.Horizontal = Arrangement.Start, | ||
userScrollEnabled: Boolean = true, | ||
content: LazyGridScope.() -> Unit, | ||
) { | ||
VerticalGridFastScroller( | ||
state = state, | ||
columns = columns, | ||
arrangement = horizontalArrangement, | ||
contentPadding = contentPadding, | ||
modifier = modifier, | ||
thumbAllowed = thumbAllowed, | ||
thumbColor = thumbColor, | ||
topContentPadding = topContentPadding, | ||
bottomContentPadding = bottomContentPadding, | ||
endContentPadding = endContentPadding, | ||
) { | ||
LazyVerticalGrid( | ||
columns = columns, | ||
state = state, | ||
contentPadding = contentPadding, | ||
reverseLayout = reverseLayout, | ||
verticalArrangement = verticalArrangement, | ||
horizontalArrangement = horizontalArrangement, | ||
userScrollEnabled = userScrollEnabled, | ||
content = content, | ||
) | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
presentation/core/src/main/java/yokai/presentation/core/util/PaddingValues.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package yokai.presentation.core.util | ||
|
||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.calculateEndPadding | ||
import androidx.compose.foundation.layout.calculateStartPadding | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.ReadOnlyComposable | ||
import androidx.compose.ui.platform.LocalLayoutDirection | ||
|
||
@Composable | ||
@ReadOnlyComposable | ||
operator fun PaddingValues.plus(other: PaddingValues): PaddingValues { | ||
val layoutDirection = LocalLayoutDirection.current | ||
return PaddingValues( | ||
start = calculateStartPadding(layoutDirection) + | ||
other.calculateStartPadding(layoutDirection), | ||
end = calculateEndPadding(layoutDirection) + | ||
other.calculateEndPadding(layoutDirection), | ||
top = calculateTopPadding() + other.calculateTopPadding(), | ||
bottom = calculateBottomPadding() + other.calculateBottomPadding(), | ||
) | ||
} |