Update compose to 2023.08.00

This commit is contained in:
Oleksandr Balan
2023-09-06 22:37:10 +02:00
parent 9addca8f27
commit 23a394897a
35 changed files with 431 additions and 332 deletions

View File

@@ -6,8 +6,8 @@ name: Publish To Maven Central
on:
# Triggers the workflow when tag is pushed
push:
tags:
- 'v*'
tags:
- 'v*'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
@@ -17,17 +17,22 @@ jobs:
# This workflow contains a single job called "publish"
publish:
# The type of runner that the job will run on
runs-on: ubuntu-latest
runs-on: macos-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# Runs a single command using the runners shell
- name: publish
run: ./gradlew publish --no-daemon --no-parallel --stacktrace --info
env:
run: ./gradlew publish --no-daemon --no-parallel
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}

View File

@@ -12,12 +12,17 @@ on:
jobs:
detekt:
name: Detekt
runs-on: ubuntu-latest
runs-on: macos-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# Runs a single command using the runners shell
- name: detekt
@@ -25,12 +30,17 @@ jobs:
spotless:
name: Spotless
runs-on: ubuntu-latest
runs-on: macos-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# Runs a single command using the runners shell
- name: spotless

14
.gitignore vendored
View File

@@ -1,19 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/inspectionProfiles
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
/.idea/misc.xml
/.idea/deploymentTargetDropDown.xml
/.idea/kotlinc.xml
/.idea
.DS_Store
/build
build/
/captures
.externalNativeBuild
.cxx
local.properties

14
.idea/gradle.xml generated
View File

@@ -4,12 +4,26 @@
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<compositeConfiguration>
<compositeBuild compositeDefinitionSource="SCRIPT">
<builds>
<build path="$PROJECT_DIR$/build-logic" name="build-logic">
<projects>
<project path="$PROJECT_DIR$/build-logic" />
<project path="$PROJECT_DIR$/build-logic/convention" />
</projects>
</build>
</builds>
</compositeBuild>
</compositeConfiguration>
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="/usr/local/Cellar/gradle/6.0.1/libexec" />
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/build-logic" />
<option value="$PROJECT_DIR$/build-logic/convention" />
<option value="$PROJECT_DIR$/demo" />
<option value="$PROJECT_DIR$/pagecurl" />
</set>

View File

@@ -15,8 +15,8 @@ This library allows to create an effect of turning pages, which can be used in b
### Get a dependency
**Step 1.** Add the MavenCentral repository to your build file.
Add it in your root `build.gradle` at the end of repositories:
```
Add it in your root `build.gradle.kts` at the end of repositories:
```kotlin
allprojects {
repositories {
...
@@ -25,8 +25,8 @@ allprojects {
}
```
Or in `settings.gradle`:
```
Or in `settings.gradle.kts`:
```kotlin
pluginManagement {
repositories {
...
@@ -37,9 +37,9 @@ pluginManagement {
**Step 2.** Add the dependency.
Check latest version on the [releases page](https://github.com/oleksandrbalan/pagecurl/releases).
```
```kotlin
dependencies {
implementation 'io.github.oleksandrbalan:pagecurl:$version'
implementation("io.github.oleksandrbalan:pagecurl:$version")
}
```

1
build-logic/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

1
build-logic/convention/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1,19 @@
plugins {
`kotlin-dsl`
}
java {
toolchain {
val version = libs.versions.java.toolchain.get()
languageVersion.set(JavaLanguageVersion.of(version))
}
}
gradlePlugin {
plugins {
register("conventionJvmToolchain") {
id = "convention.jvm.toolchain"
implementationClass = "JvmToolchainConventionPlugin"
}
}
}

View File

@@ -0,0 +1,18 @@
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.kotlin.dsl.configure
import utils.libs
class JvmToolchainConventionPlugin : Plugin<Project> {
override fun apply(target: Project) =
with(target) {
extensions.configure<JavaPluginExtension> {
toolchain {
val version = libs.findVersion("java-toolchain").get().displayName
languageVersion.set(JavaLanguageVersion.of(version))
}
}
}
}

View File

@@ -0,0 +1,9 @@
package utils
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalog
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.getByType
val Project.libs: VersionCatalog
get() = extensions.getByType<VersionCatalogsExtension>().named("libs")

View File

@@ -0,0 +1,18 @@
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
}
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version ("0.7.0")
}
rootProject.name = "build-logic"
include(":convention")

View File

@@ -1,34 +0,0 @@
buildscript {
ext {
compile_sdk_version = 33
min_sdk_version = 24
target_sdk_version = 33
compose_bom_version = "2023.03.00"
compose_compiler_version = "1.4.2"
accompanist_version = "0.28.0"
activity_version = "1.6.1"
paging_version = "3.1.1"
paging_compose_version = "1.0.0-alpha18"
}
}
plugins {
id "com.android.application" version '7.4.2' apply false
id "com.android.library" version '7.4.2' apply false
id "org.jetbrains.kotlin.android" version "1.8.10" apply false
id "io.gitlab.arturbosch.detekt" version "1.21.0"
id "com.diffplug.spotless" version "6.5.1"
id "com.vanniktech.maven.publish" version "0.21.0"
}
configure(subprojects) {
apply plugin: "io.gitlab.arturbosch.detekt"
apply plugin: "com.diffplug.spotless"
spotless {
kotlin {
target("**/*.kt")
ktlint("0.43.2")
}
}
}

23
build.gradle.kts Normal file
View File

@@ -0,0 +1,23 @@
import com.diffplug.gradle.spotless.SpotlessPlugin
import io.gitlab.arturbosch.detekt.DetektPlugin
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin) apply false
alias(libs.plugins.detekt)
alias(libs.plugins.spotless)
alias(libs.plugins.mavenpublish)
}
configure(subprojects) {
apply<DetektPlugin>()
apply<SpotlessPlugin>()
spotless {
kotlin {
target("**/*.kt")
ktlint("0.43.2")
}
}
}

View File

@@ -1,60 +0,0 @@
plugins {
id "com.android.application"
id "org.jetbrains.kotlin.android"
}
android {
compileSdk compile_sdk_version
defaultConfig {
applicationId "eu.wewox.pagecurl"
minSdk min_sdk_version
targetSdk target_sdk_version
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = freeCompilerArgs +
"-Xopt-in=kotlin.RequiresOptIn"
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion compose_compiler_version
}
packagingOptions {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}
dependencies {
implementation(project(":pagecurl"))
implementation(platform("androidx.compose:compose-bom:$compose_bom_version"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.material:material")
implementation("androidx.activity:activity-compose:$activity_version")
implementation("com.google.accompanist:accompanist-systemuicontroller:$accompanist_version")
implementation("androidx.paging:paging-runtime:$paging_version")
implementation("androidx.paging:paging-compose:$paging_compose_version")
}

61
demo/build.gradle.kts Normal file
View File

@@ -0,0 +1,61 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin)
id("convention.jvm.toolchain")
}
android {
namespace = "eu.wewox.pagecurl"
compileSdk = libs.versions.sdk.compile.get().toInt()
defaultConfig {
applicationId = "eu.wewox.pagecurl"
minSdk = libs.versions.sdk.min.get().toInt()
targetSdk = libs.versions.sdk.target.get().toInt()
versionCode = 1
versionName = "1.0"
vectorDrawables {
useSupportLibrary = true
}
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}
kotlinOptions {
freeCompilerArgs = freeCompilerArgs +
"-opt-in=androidx.compose.material3.ExperimentalMaterial3Api"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}
dependencies {
implementation(project(":pagecurl"))
implementation(platform(libs.compose.bom))
implementation(libs.compose.material3)
implementation(libs.compose.ui)
implementation(libs.androidx.activitycompose)
implementation(libs.androidx.pagingruntime)
implementation(libs.androidx.pagingcompose)
}

View File

@@ -4,31 +4,17 @@ import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.BackHandler
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.animation.Crossfade
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawingPadding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.KeyboardArrowRight
import androidx.compose.runtime.Composable
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.core.view.WindowCompat
import eu.wewox.pagecurl.components.TopBar
import eu.wewox.pagecurl.screens.BackPagePageCurlScreen
import eu.wewox.pagecurl.screens.InteractionConfigInPageCurlScreen
import eu.wewox.pagecurl.screens.PagingPageCurlScreen
@@ -36,7 +22,6 @@ import eu.wewox.pagecurl.screens.SettingsPageCurlScreen
import eu.wewox.pagecurl.screens.ShadowInPageCurlScreen
import eu.wewox.pagecurl.screens.SimplePageCurlScreen
import eu.wewox.pagecurl.screens.StateInPageCurlScreen
import eu.wewox.pagecurl.ui.SpacingMedium
import eu.wewox.pagecurl.ui.theme.PageCurlTheme
/**
@@ -46,6 +31,7 @@ import eu.wewox.pagecurl.ui.theme.PageCurlTheme
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
WindowCompat.setDecorFitsSystemWindows(window, false)
@@ -57,8 +43,8 @@ class MainActivity : ComponentActivity() {
example = null
}
Surface(color = MaterialTheme.colors.background) {
Crossfade(targetState = example, Modifier.safeDrawingPadding()) { selected ->
Surface(color = MaterialTheme.colorScheme.background) {
Crossfade(targetState = example, Modifier.safeDrawingPadding(), label = "Crossfade") { selected ->
when (selected) {
null -> RootScreen(onExampleClick = { example = it })
Example.SimplePageCurl -> SimplePageCurlScreen()
@@ -75,37 +61,3 @@ class MainActivity : ComponentActivity() {
}
}
}
@Composable
private fun RootScreen(onExampleClick: (Example) -> Unit) {
Scaffold(
topBar = { TopBar("Page Curl Demo") }
) { padding ->
LazyColumn(Modifier.padding(padding)) {
items(Example.values()) {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
.clickable { onExampleClick(it) }
.padding(SpacingMedium)
) {
Column(modifier = Modifier.weight(1f)) {
Text(
text = it.label,
style = MaterialTheme.typography.h6
)
Text(
text = it.description,
style = MaterialTheme.typography.body2
)
}
Icon(
imageVector = Icons.Default.KeyboardArrowRight,
contentDescription = null
)
}
}
}
}
}

View File

@@ -0,0 +1,54 @@
package eu.wewox.pagecurl
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.KeyboardArrowRight
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import eu.wewox.pagecurl.components.TopBar
import eu.wewox.pagecurl.ui.SpacingMedium
@Composable
internal fun RootScreen(onExampleClick: (Example) -> Unit) {
Scaffold(
topBar = { TopBar("PageCurl Demo") }
) { padding ->
LazyColumn(Modifier.padding(padding)) {
items(Example.entries) {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
.clickable { onExampleClick(it) }
.padding(SpacingMedium)
) {
Column(modifier = Modifier.weight(1f)) {
Text(
text = it.label,
style = MaterialTheme.typography.titleMedium
)
Text(
text = it.description,
style = MaterialTheme.typography.bodyMedium
)
}
Icon(
imageVector = Icons.Default.KeyboardArrowRight,
contentDescription = null
)
}
}
}
}
}

View File

@@ -8,8 +8,8 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -34,7 +34,7 @@ fun HowToPage(
Box(
modifier = modifier
.fillMaxSize()
.background(MaterialTheme.colors.background)
.background(MaterialTheme.colorScheme.background)
) {
Column(
verticalArrangement = Arrangement.spacedBy(SpacingMedium, Alignment.CenterVertically),
@@ -44,24 +44,24 @@ fun HowToPage(
) {
Text(
text = page.title,
style = MaterialTheme.typography.h4,
style = MaterialTheme.typography.headlineMedium,
textAlign = TextAlign.Center,
modifier = Modifier.fillMaxWidth()
)
Text(
text = page.message,
style = MaterialTheme.typography.body1,
style = MaterialTheme.typography.bodyMedium,
textAlign = TextAlign.Center,
modifier = Modifier.fillMaxWidth()
)
}
Text(
text = index.toString(),
color = MaterialTheme.colors.background,
color = MaterialTheme.colorScheme.background,
modifier = Modifier
.align(Alignment.BottomEnd)
.background(MaterialTheme.colors.onBackground, RoundedCornerShape(topStartPercent = 100))
.background(MaterialTheme.colorScheme.onBackground, RoundedCornerShape(topStartPercent = 100))
.padding(SpacingMedium)
)
}

View File

@@ -10,9 +10,10 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Card
import androidx.compose.material.Switch
import androidx.compose.material.Text
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -34,7 +35,7 @@ internal fun SettingsPopup(
) {
Card(
shape = RoundedCornerShape(24.dp),
elevation = 8.dp,
elevation = CardDefaults.cardElevation(8.dp),
) {
Column(
verticalArrangement = Arrangement.spacedBy(8.dp),

View File

@@ -1,25 +1,47 @@
package eu.wewox.pagecurl.components
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import eu.wewox.pagecurl.ui.SpacingMedium
import androidx.compose.ui.graphics.Color
/**
* The reusable component for top bar.
*
* @param title The text to show in top bar.
* @param modifier The modifier instance for the root composable.
*/
@Composable
fun TopBar(title: String) {
Text(
text = title,
style = MaterialTheme.typography.h4,
modifier = Modifier
.padding(SpacingMedium)
.statusBarsPadding()
fun TopBar(
title: String,
modifier: Modifier = Modifier,
onBackClick: (() -> Unit)? = null,
) {
TopAppBar(
title = {
Text(
text = title,
style = MaterialTheme.typography.titleLarge,
)
},
navigationIcon = {
if (onBackClick != null) {
IconButton(onClick = onBackClick) {
Icon(
imageVector = Icons.Filled.ArrowBack,
contentDescription = "Back button"
)
}
}
},
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(Color.Transparent),
modifier = modifier,
)
}

View File

@@ -8,7 +8,8 @@ import androidx.compose.animation.expandIn
import androidx.compose.animation.shrinkOut
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Card
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
@@ -58,8 +59,8 @@ fun ZoomOutLayout(
if (cornersAndElevation != 0.dp) {
Card(
shape = RoundedCornerShape(cornersAndElevation),
elevation = cornersAndElevation,
content = pageCurl,
elevation = CardDefaults.cardElevation(cornersAndElevation),
content = { pageCurl() },
)
} else {
pageCurl()

View File

@@ -18,8 +18,8 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.Slider
import androidx.compose.material.Text
import androidx.compose.material3.Slider
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf

View File

@@ -11,9 +11,9 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.selection.selectable
import androidx.compose.foundation.selection.selectableGroup
import androidx.compose.material.RadioButton
import androidx.compose.material.Slider
import androidx.compose.material.Text
import androidx.compose.material3.RadioButton
import androidx.compose.material3.Slider
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf

View File

@@ -7,9 +7,9 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
@@ -46,7 +46,7 @@ fun PagingPageCurlScreen() {
contentAlignment = Alignment.Center,
modifier = Modifier
.fillMaxSize()
.background(MaterialTheme.colors.background)
.background(MaterialTheme.colorScheme.background)
) {
CircularProgressIndicator()
}
@@ -61,7 +61,7 @@ fun PagingPageCurlScreen() {
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.fillMaxSize()
.background(MaterialTheme.colors.background)
.background(MaterialTheme.colorScheme.background)
) {
Text(items[index]?.content.orEmpty())
Text(if (loading) "Loading..." else "")

View File

@@ -8,8 +8,8 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Slider
import androidx.compose.material.Text
import androidx.compose.material3.Slider
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf

View File

@@ -10,8 +10,8 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf

View File

@@ -1,14 +0,0 @@
package eu.wewox.pagecurl.ui.theme
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)
)

View File

@@ -1,59 +1,61 @@
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.material3.MaterialTheme
import androidx.compose.material3.Typography
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.graphics.Color
import com.google.accompanist.systemuicontroller.rememberSystemUiController
private val DarkColorPalette = darkColors(
private val DarkColorScheme = darkColorScheme(
primary = LightBlue,
primaryVariant = LightBlue,
secondary = LightYellow,
secondaryVariant = LightYellow,
secondary = LightBlue,
tertiary = LightYellow,
onPrimary = Color.Black,
onSecondary = Color.Black,
onTertiary = Color.Black,
surface = Color.Black,
background = Color.Black,
onSurface = Color.White,
onBackground = Color.White,
)
private val LightColorPalette = lightColors(
private val LightColorScheme = lightColorScheme(
primary = LightBlue,
primaryVariant = LightBlue,
secondary = LightYellow,
secondaryVariant = LightYellow,
secondary = LightBlue,
tertiary = LightYellow,
onPrimary = Color.Black,
onSecondary = Color.Black,
onTertiary = Color.Black,
surface = Color.White,
background = Color.White,
onSurface = Color.Black,
onBackground = Color.Black,
)
/**
* The theme to use for demo application.
*/
@Composable
fun PageCurlTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
val sysUiController = rememberSystemUiController()
SideEffect {
sysUiController.setSystemBarsColor(
color = Color.Transparent,
darkIcons = !darkTheme,
isNavigationBarContrastEnforced = false
)
}
val colors = if (darkTheme) {
DarkColorPalette
} else {
LightColorPalette
fun PageCurlTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable () -> Unit
) {
val colorScheme = when {
darkTheme -> DarkColorScheme
else -> LightColorScheme
}
MaterialTheme(
colors = colors,
colorScheme = colorScheme,
typography = Typography(),
shapes = Shapes,
content = content
)
}

34
gradle/libs.versions.toml Normal file
View File

@@ -0,0 +1,34 @@
[versions]
sdk-compile = "34"
sdk-min = "21"
sdk-target = "33"
compose-bom = "2023.08.00"
compose-compiler = "1.5.3"
activity-compose = "1.8.0-beta01"
paging = "3.2.1"
plugin-android-gradle = "8.1.1"
plugin-kotlin = "1.9.10"
plugin-detekt = "1.21.0"
plugin-spotless = "6.5.1"
plugin-mavenpublish = "0.25.3"
java-toolchain = "17"
[libraries]
compose-bom = { module = "androidx.compose:compose-bom", version.ref = "compose-bom" }
compose-foundation = { module = "androidx.compose.foundation:foundation" }
compose-material3 = { module = "androidx.compose.material3:material3" }
compose-ui = { module = "androidx.compose.ui:ui" }
androidx-activitycompose = { module = "androidx.activity:activity-compose", version.ref = "activity-compose" }
androidx-pagingruntime = { module = "androidx.paging:paging-runtime", version.ref = "paging" }
androidx-pagingcompose = { module = "androidx.paging:paging-compose", version.ref = "paging" }
[plugins]
android-application = { id = "com.android.application", version.ref = "plugin-android-gradle" }
android-library = { id = "com.android.library", version.ref = "plugin-android-gradle" }
kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "plugin-kotlin" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "plugin-detekt" }
spotless = { id = "com.diffplug.spotless", version.ref = "plugin-spotless" }
mavenpublish = { id = "com.vanniktech.maven.publish", version.ref = "plugin-mavenpublish" }

View File

@@ -1,6 +1,6 @@
#Wed Mar 15 10:05:21 CET 2023
#Wed Sep 06 22:11:14 CEST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -1,45 +0,0 @@
plugins {
id "com.android.library"
id "org.jetbrains.kotlin.android"
id "com.vanniktech.maven.publish"
}
android {
compileSdk compile_sdk_version
defaultConfig {
minSdk min_sdk_version
targetSdk target_sdk_version
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion compose_compiler_version
}
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = freeCompilerArgs +
"-Xexplicit-api=strict" +
"-Xopt-in=kotlin.RequiresOptIn"
}
}
dependencies {
implementation(platform("androidx.compose:compose-bom:$compose_bom_version"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.foundation:foundation")
}

32
pagecurl/build.gradle.kts Normal file
View File

@@ -0,0 +1,32 @@
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin)
alias(libs.plugins.mavenpublish)
id("convention.jvm.toolchain")
}
android {
namespace = "eu.wewox.pagecurl"
compileSdk = libs.versions.sdk.compile.get().toInt()
defaultConfig {
minSdk = libs.versions.sdk.min.get().toInt()
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}
kotlinOptions {
freeCompilerArgs = freeCompilerArgs +
"-Xexplicit-api=strict"
}
}
dependencies {
implementation(platform(libs.compose.bom))
implementation(libs.compose.foundation)
implementation(libs.compose.ui)
}

View File

@@ -1,21 +0,0 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@@ -1,17 +1,23 @@
pluginManagement {
includeBuild("build-logic")
repositories {
google()
mavenCentral()
gradlePluginPortal()
google()
mavenCentral()
}
}
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version ("0.7.0")
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "PageCurl"
include ':demo'
include ':pagecurl'
include(":demo")
include(":pagecurl")