mirror of
https://github.com/fankes/pagecurl-multiplatform.git
synced 2025-09-07 03:05:59 +08:00
Update versions, add detekt and spotless
This commit is contained in:
@@ -1,9 +1,18 @@
|
||||
@file:Suppress("MaxLineLength", "UndocumentedPublicProperty")
|
||||
|
||||
package eu.wewox.pagecurl
|
||||
|
||||
/**
|
||||
* The model for data for the page.
|
||||
*
|
||||
* @property title The title to show on the page.
|
||||
* @property message The message to show on the page.
|
||||
*/
|
||||
data class HowToPageData(
|
||||
val title: String,
|
||||
val message: String,
|
||||
) {
|
||||
|
||||
companion object {
|
||||
val simpleHowToPages = listOf(
|
||||
HowToPageData(
|
||||
|
@@ -18,6 +18,13 @@ import eu.wewox.pagecurl.HowToPageData
|
||||
import eu.wewox.pagecurl.ui.SpacingLarge
|
||||
import eu.wewox.pagecurl.ui.SpacingMedium
|
||||
|
||||
/**
|
||||
* The simple page to use for demo purposes.
|
||||
*
|
||||
* @param index The index of the page to show a page number in the bottom.
|
||||
* @param page The page data to show.
|
||||
* @param modifier The modifier for this composable.
|
||||
*/
|
||||
@Composable
|
||||
fun HowToPage(
|
||||
index: Int,
|
||||
|
@@ -20,6 +20,15 @@ import androidx.compose.ui.unit.dp
|
||||
import eu.wewox.pagecurl.ExperimentalPageCurlApi
|
||||
import eu.wewox.pagecurl.config.PageCurlConfig
|
||||
|
||||
/**
|
||||
* Layout which could be zoomed out and zoomed in to show / hide the [bottom] bar.
|
||||
*
|
||||
* @param zoomOut True when layout is zoomed out.
|
||||
* @param config The [PageCurlConfig] to turn off interactions in the page curl.
|
||||
* @param bottom The content of the bottom bar.
|
||||
* @param modifier The modifier for this composable.
|
||||
* @param pageCurl The content where PageCurl should be placed.
|
||||
*/
|
||||
@Composable
|
||||
fun ZoomOutLayout(
|
||||
zoomOut: Boolean,
|
||||
@@ -29,7 +38,7 @@ fun ZoomOutLayout(
|
||||
pageCurl: @Composable () -> Unit,
|
||||
) {
|
||||
// Disable all state interactions when PageCurl is zoomed out
|
||||
LaunchedEffect(zoomOut) {
|
||||
LaunchedEffect(zoomOut, config) {
|
||||
with(config) {
|
||||
dragForwardEnabled = !zoomOut
|
||||
dragBackwardEnabled = !zoomOut
|
||||
@@ -54,9 +63,8 @@ fun ZoomOutLayout(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Composable
|
||||
fun ZoomOutLayout(
|
||||
private fun ZoomOutLayout(
|
||||
zoomOut: Boolean,
|
||||
bottom: @Composable () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
|
@@ -1,4 +1,5 @@
|
||||
@file:OptIn(ExperimentalPageCurlApi::class)
|
||||
@file:Suppress("MagicNumber")
|
||||
|
||||
package eu.wewox.pagecurl.screens
|
||||
|
||||
@@ -42,6 +43,10 @@ import eu.wewox.pagecurl.ui.SpacingLarge
|
||||
import eu.wewox.pagecurl.ui.SpacingMedium
|
||||
import eu.wewox.pagecurl.ui.SpacingSmall
|
||||
|
||||
/**
|
||||
* Back-Page Configuration in Page Curl.
|
||||
* Example how to customize the back-page (the back of the page user see during the drag or animation).
|
||||
*/
|
||||
@Composable
|
||||
fun BackPagePageCurlScreen() {
|
||||
Box(Modifier.fillMaxSize()) {
|
||||
@@ -86,7 +91,7 @@ private fun SettingsRow(
|
||||
Column(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = SpacingMedium)
|
||||
.padding(vertical = SpacingLarge)
|
||||
) {
|
||||
Text(
|
||||
text = "Alpha",
|
||||
|
@@ -38,6 +38,10 @@ import eu.wewox.pagecurl.ui.SpacingLarge
|
||||
import eu.wewox.pagecurl.ui.SpacingMedium
|
||||
import eu.wewox.pagecurl.ui.SpacingSmall
|
||||
|
||||
/**
|
||||
* Interactions Configurations In Page Curl.
|
||||
* Example interactions (drag / tap) can be customized.
|
||||
*/
|
||||
@Composable
|
||||
fun InteractionConfigInPageCurlScreen() {
|
||||
Box(Modifier.fillMaxSize()) {
|
||||
@@ -114,37 +118,48 @@ private fun SettingsRow(
|
||||
}
|
||||
}
|
||||
|
||||
when (selectedOption) {
|
||||
InteractionOption.Drag -> {
|
||||
Slider(
|
||||
value = config.dragForwardInteraction.start.left,
|
||||
onValueChange = {
|
||||
config.dragForwardInteraction = PageCurlConfig.DragInteraction(
|
||||
Rect(it, 0.0f, 1.0f, 1.0f),
|
||||
Rect(0.0f, 0.0f, it, 1.0f)
|
||||
)
|
||||
config.dragBackwardInteraction = PageCurlConfig.DragInteraction(
|
||||
Rect(0.0f, 0.0f, it, 1.0f),
|
||||
Rect(it, 0.0f, 1.0f, 1.0f),
|
||||
)
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
InteractionOption.Tap -> {
|
||||
Slider(
|
||||
value = config.tapForwardInteraction.target.left,
|
||||
onValueChange = {
|
||||
config.tapForwardInteraction = PageCurlConfig.TapInteraction(
|
||||
Rect(it, 0.0f, 1.0f, 1.0f),
|
||||
)
|
||||
config.tapBackwardInteraction = PageCurlConfig.TapInteraction(
|
||||
Rect(0.0f, 0.0f, it, 1.0f),
|
||||
)
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
SettingsRowSlider(
|
||||
selectedOption = selectedOption,
|
||||
config = config,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SettingsRowSlider(
|
||||
selectedOption: InteractionOption,
|
||||
config: PageCurlConfig,
|
||||
) {
|
||||
when (selectedOption) {
|
||||
InteractionOption.Drag -> {
|
||||
Slider(
|
||||
value = config.dragForwardInteraction.start.left,
|
||||
onValueChange = {
|
||||
config.dragForwardInteraction = PageCurlConfig.DragInteraction(
|
||||
Rect(it, 0.0f, 1.0f, 1.0f),
|
||||
Rect(0.0f, 0.0f, it, 1.0f)
|
||||
)
|
||||
config.dragBackwardInteraction = PageCurlConfig.DragInteraction(
|
||||
Rect(0.0f, 0.0f, it, 1.0f),
|
||||
Rect(it, 0.0f, 1.0f, 1.0f),
|
||||
)
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
InteractionOption.Tap -> {
|
||||
Slider(
|
||||
value = config.tapForwardInteraction.target.left,
|
||||
onValueChange = {
|
||||
config.tapForwardInteraction = PageCurlConfig.TapInteraction(
|
||||
Rect(it, 0.0f, 1.0f, 1.0f),
|
||||
)
|
||||
config.tapBackwardInteraction = PageCurlConfig.TapInteraction(
|
||||
Rect(0.0f, 0.0f, it, 1.0f),
|
||||
)
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,10 @@ import eu.wewox.pagecurl.config.rememberPageCurlConfig
|
||||
import eu.wewox.pagecurl.page.PageCurl
|
||||
import eu.wewox.pagecurl.page.rememberPageCurlState
|
||||
|
||||
/**
|
||||
* Page Curl With Settings.
|
||||
* Showcases how individual interactions can be toggled on / off.
|
||||
*/
|
||||
@Composable
|
||||
fun SettingsPageCurlScreen() {
|
||||
Box(Modifier.fillMaxSize()) {
|
||||
|
@@ -1,4 +1,5 @@
|
||||
@file:OptIn(ExperimentalPageCurlApi::class)
|
||||
@file:Suppress("MagicNumber")
|
||||
|
||||
package eu.wewox.pagecurl.screens
|
||||
|
||||
@@ -29,6 +30,10 @@ import eu.wewox.pagecurl.page.PageCurl
|
||||
import eu.wewox.pagecurl.page.rememberPageCurlState
|
||||
import eu.wewox.pagecurl.ui.SpacingLarge
|
||||
|
||||
/**
|
||||
* Shadow Configuration in Page Curl.
|
||||
* Example how to customize shadow of the page.
|
||||
*/
|
||||
@Composable
|
||||
fun ShadowInPageCurlScreen() {
|
||||
Box(Modifier.fillMaxSize()) {
|
||||
|
@@ -13,6 +13,10 @@ import eu.wewox.pagecurl.components.HowToPage
|
||||
import eu.wewox.pagecurl.page.PageCurl
|
||||
import eu.wewox.pagecurl.page.rememberPageCurlState
|
||||
|
||||
/**
|
||||
* Page Curl With Settings.
|
||||
* Showcases how individual interactions can be toggled on / off.
|
||||
*/
|
||||
@Composable
|
||||
fun SimplePageCurlScreen() {
|
||||
Box(Modifier.fillMaxSize()) {
|
||||
|
@@ -35,6 +35,10 @@ import eu.wewox.pagecurl.ui.SpacingLarge
|
||||
import eu.wewox.pagecurl.ui.SpacingMedium
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
* Page Curl With State Management.
|
||||
* Example how state can be used to change current page (snap / animate).
|
||||
*/
|
||||
@Composable
|
||||
fun StateInPageCurlScreen() {
|
||||
Box(Modifier.fillMaxSize()) {
|
||||
|
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("UndocumentedPublicProperty")
|
||||
|
||||
package eu.wewox.pagecurl.ui.theme
|
||||
|
||||
import androidx.compose.ui.graphics.Color
|
||||
@@ -5,4 +7,4 @@ import androidx.compose.ui.graphics.Color
|
||||
val Purple200 = Color(0xFFBB86FC)
|
||||
val Purple500 = Color(0xFF6200EE)
|
||||
val Purple700 = Color(0xFF3700B3)
|
||||
val Teal200 = Color(0xFF03DAC5)
|
||||
val Teal200 = Color(0xFF03DAC5)
|
||||
|
@@ -4,8 +4,11 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.Shapes
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
/**
|
||||
* The application shapes.
|
||||
*/
|
||||
val Shapes = Shapes(
|
||||
small = RoundedCornerShape(4.dp),
|
||||
medium = RoundedCornerShape(4.dp),
|
||||
large = RoundedCornerShape(0.dp)
|
||||
)
|
||||
)
|
||||
|
@@ -2,6 +2,7 @@ package eu.wewox.pagecurl.ui.theme
|
||||
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Typography
|
||||
import androidx.compose.material.darkColors
|
||||
import androidx.compose.material.lightColors
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -9,24 +10,18 @@ import androidx.compose.runtime.Composable
|
||||
private val DarkColorPalette = darkColors(
|
||||
primary = Purple200,
|
||||
primaryVariant = Purple700,
|
||||
secondary = Teal200
|
||||
secondary = Teal200,
|
||||
)
|
||||
|
||||
private val LightColorPalette = lightColors(
|
||||
primary = Purple500,
|
||||
primaryVariant = Purple700,
|
||||
secondary = Teal200
|
||||
|
||||
/* Other default colors to override
|
||||
background = Color.White,
|
||||
surface = Color.White,
|
||||
onPrimary = Color.White,
|
||||
onSecondary = Color.Black,
|
||||
onBackground = Color.Black,
|
||||
onSurface = Color.Black,
|
||||
*/
|
||||
secondary = Teal200,
|
||||
)
|
||||
|
||||
/**
|
||||
* The theme to use for demo application.
|
||||
*/
|
||||
@Composable
|
||||
fun PageCurlTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
|
||||
val colors = if (darkTheme) {
|
||||
@@ -37,8 +32,8 @@ fun PageCurlTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composab
|
||||
|
||||
MaterialTheme(
|
||||
colors = colors,
|
||||
typography = Typography,
|
||||
typography = Typography(),
|
||||
shapes = Shapes,
|
||||
content = content
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@@ -1,28 +0,0 @@
|
||||
package eu.wewox.pagecurl.ui.theme
|
||||
|
||||
import androidx.compose.material.Typography
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
||||
// Set of Material typography styles to start with
|
||||
val Typography = Typography(
|
||||
body1 = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.Normal,
|
||||
fontSize = 16.sp
|
||||
)
|
||||
/* Other default text styles to override
|
||||
button = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.W500,
|
||||
fontSize = 14.sp
|
||||
),
|
||||
caption = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.Normal,
|
||||
fontSize = 12.sp
|
||||
)
|
||||
*/
|
||||
)
|
Reference in New Issue
Block a user