├── .github ├── images │ ├── dragrefresh-flipped.gif │ ├── dragrefresh.gif │ ├── pullrefresh-flipped.gif │ └── pullrefresh.gif └── workflows │ ├── build.yml │ └── release.yml ├── .gitignore ├── LICENSE ├── README.md ├── build.gradle.kts ├── demo ├── .gitignore ├── build.gradle.kts ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── dev │ │ └── materii │ │ └── pullrefresh │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── dev │ │ │ └── materii │ │ │ └── pullrefresh │ │ │ └── demo │ │ │ ├── MainActivity.kt │ │ │ ├── sample │ │ │ ├── DragRefreshSample.kt │ │ │ └── PullRefreshSample.kt │ │ │ └── theme │ │ │ └── Theme.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── themes.xml │ │ └── xml │ │ ├── backup_rules.xml │ │ └── data_extraction_rules.xml │ └── test │ └── java │ └── dev │ └── materii │ └── pullrefresh │ └── ExampleUnitTest.kt ├── gradle.properties ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── pullrefresh ├── .gitignore ├── build.gradle.kts └── src │ ├── androidMain │ └── AndroidManifest.xml │ └── commonMain │ └── kotlin │ └── dev │ └── materii │ └── pullrefresh │ ├── CircularLoadingIndicator.kt │ ├── Constants.kt │ ├── DragRefreshIndicator.kt │ ├── DragRefreshLayout.kt │ ├── PullRefresh.kt │ ├── PullRefreshIndicator.kt │ ├── PullRefreshLayout.kt │ ├── PullRefreshState.kt │ └── PullRequestIndicatorTransform.kt └── settings.gradle.kts /.github/images/dragrefresh-flipped.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MateriiApps/pullrefresh/0deeec24bef8e439d5c4117b9b7dfecc65d1d41b/.github/images/dragrefresh-flipped.gif -------------------------------------------------------------------------------- /.github/images/dragrefresh.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MateriiApps/pullrefresh/0deeec24bef8e439d5c4117b9b7dfecc65d1d41b/.github/images/dragrefresh.gif -------------------------------------------------------------------------------- /.github/images/pullrefresh-flipped.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MateriiApps/pullrefresh/0deeec24bef8e439d5c4117b9b7dfecc65d1d41b/.github/images/pullrefresh-flipped.gif -------------------------------------------------------------------------------- /.github/images/pullrefresh.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MateriiApps/pullrefresh/0deeec24bef8e439d5c4117b9b7dfecc65d1d41b/.github/images/pullrefresh.gif -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches: 6 | - '*' 7 | - '!release' 8 | paths-ignore: 9 | - '**.md' 10 | pull_request: 11 | branches: 12 | - '*' 13 | paths-ignore: 14 | - '**.md' 15 | workflow_dispatch: 16 | 17 | jobs: 18 | build: 19 | timeout-minutes: 60 20 | runs-on: macos-latest 21 | steps: 22 | - uses: actions/checkout@v2 23 | 24 | - name: Set up JDK 17 25 | uses: actions/setup-java@v2 26 | with: 27 | java-version: 17 28 | distribution: 'zulu' 29 | cache: 'gradle' 30 | 31 | - name: Setup Android SDK 32 | uses: android-actions/setup-android@v2.0.10 33 | 34 | - name: Build artifacts 35 | run: | 36 | chmod +x gradlew 37 | ./gradlew publishToMavenLocal --no-daemon --stacktrace 38 | 39 | - name: Upload artifacts 40 | uses: actions/upload-artifact@v3 41 | with: 42 | name: artifacts 43 | path: ~/.m2/repository/ -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Publish release 2 | 3 | concurrency: 4 | group: "release" 5 | cancel-in-progress: true 6 | 7 | on: 8 | workflow_dispatch: 9 | push: 10 | branches: 11 | - 'release' 12 | 13 | # Required actions secrets: 14 | # SONATYPE_USERNAME: sonatype staging repo user token username 15 | # SONATYPE_PASSWORD: sonatype staging repo user token password 16 | # GPG_KEY_ID: last 8 chars of master/(singing) subkey fingerprint (gpg --list-keys --keyid-format short) 17 | # GPG_SIGNING_KEY: an armored gpg key: (gpg --armor --export-secret-key ) OR (gpg --armor --export-secret-subkey !) 18 | # GPG_KEY_PASSWORD: password for key-block 19 | 20 | jobs: 21 | build: 22 | timeout-minutes: 60 23 | runs-on: macos-latest 24 | steps: 25 | - name: Checkout 26 | uses: actions/checkout@master 27 | with: 28 | ref: release 29 | path: "src" 30 | 31 | - name: Setup JDK 17 32 | uses: actions/setup-java@v2 33 | with: 34 | java-version: 17 35 | distribution: zulu 36 | cache: gradle 37 | 38 | - name: Setup Android SDK 39 | uses: android-actions/setup-android@v2.0.10 40 | 41 | - name: Test version 42 | id: version 43 | run: | 44 | cd $GITHUB_WORKSPACE/src 45 | version=$(cat build.gradle.kts | grep -E 'version = "' | cut -d \" -f 2) 46 | if git show-ref --tags --quiet --verify -- "refs/tags/$version" >/dev/null; then 47 | echo "Git tag $version already exists, failing to publish"; 48 | exit 1 49 | else 50 | echo "::set-output name=release_tag::$version" 51 | fi 52 | 53 | - name: Build and Maven publish 54 | env: 55 | SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} 56 | SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} 57 | SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} 58 | SIGNING_KEY_ID: ${{ secrets.GPG_KEY_ID }} 59 | SIGNING_PASSWORD: ${{ secrets.GPG_KEY_PASSWORD }} 60 | run: | 61 | cd $GITHUB_WORKSPACE/src 62 | chmod +x gradlew 63 | ./gradlew publishToMavenLocal publish --no-daemon --stacktrace 64 | 65 | - name: Prepare Release 66 | run: | 67 | cd ~/.m2/repository 68 | zip -r $GITHUB_WORKSPACE/artifacts.zip * 69 | 70 | - name: Create Release 71 | uses: softprops/action-gh-release@v1 72 | with: 73 | tag_name: ${{ steps.version.outputs.release_tag }} 74 | generate_release_notes: true 75 | fail_on_unmatched_files: true 76 | files: artifacts.zip -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Gradle files 2 | .gradle/ 3 | build/ 4 | 5 | # Local configuration file (sdk path, etc) 6 | local.properties 7 | 8 | # Log/OS Files 9 | *.log 10 | 11 | # Android Studio generated files and folders 12 | captures/ 13 | .externalNativeBuild/ 14 | .cxx/ 15 | *.apk 16 | output.json 17 | 18 | # IntelliJ 19 | *.iml 20 | .idea/ 21 | misc.xml 22 | deploymentTargetDropDown.xml 23 | render.experimental.xml 24 | 25 | # Keystore files 26 | *.jks 27 | *.keystore 28 | 29 | # Google Services (e.g. APIs or Firebase) 30 | google-services.json 31 | 32 | # Android Profiling 33 | *.hprof 34 | 35 | # Kotlin cache folder used by kotlin 2.0.0 36 | .kotlin 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Materii 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pullrefresh 2 | Standalone pull to refresh library for Jetpack Compose multiplatform without the reliance on Material. 3 | 4 | [![Maven Central](https://img.shields.io/maven-central/v/dev.materii.pullrefresh/pullrefresh?style=for-the-badge&label=Maven%20Central)](https://central.sonatype.com/artifact/dev.materii.pullrefresh/pullrefresh/) 5 | [![Repo stars](https://img.shields.io/github/stars/MateriiApps/pullrefresh?style=for-the-badge&logo=github)](https://github.com/MateriiApps/pullrefresh/stargazers) 6 | ![Build status](https://img.shields.io/github/actions/workflow/status/MateriiApps/pullrefresh/build.yml?style=for-the-badge&logo=github) 7 | 8 | ## Use 9 | 10 | ### Add to project 11 | 12 | Gradle (Kotlin): 13 | ```kts 14 | implementation("dev.materii.pullrefresh:pullrefresh:$pullRefreshVersion") 15 | ``` 16 | 17 | Gradle (Groovy): 18 | ```groovy 19 | implementation 'dev.materii.pullrefresh:pullrefresh:$pullRefreshVersion' 20 | ``` 21 | 22 | Gradle (Version Catalog): 23 | ```toml 24 | materii-pullrefresh = { group = "dev.materii.pullrefresh", name = "pullrefresh", version.ref = "pullrefresh" } 25 | ``` 26 | 27 | ### Basic setup 28 | 29 | #### Pull to refresh 30 | > See the [sample](https://github.com/MateriiApps/pullrefresh/blob/main/demo/src/main/java/dev/materii/pullrefresh/demo/sample/PullRefreshSample.kt). 31 | 32 | | Default | Flipped | 33 | | ------- | ------- | 34 | | Pull refresh demo | Flipped pull refresh demo | 35 | 36 | ```kt 37 | @Composable 38 | fun Test() { 39 | var isRefreshing by remember { 40 | mutableStateOf(false) 41 | } 42 | var pullRefreshState = rememberPullRefreshState(refreshing = isRefreshing, onRefresh = { /* Refresh some data here */ }) 43 | 44 | PullRefreshLayout( 45 | modifier = modifier, 46 | state = pullRefreshState 47 | ) { 48 | Text("Some content") 49 | } 50 | } 51 | ``` 52 | 53 | #### Drag to refresh 54 | > See the [sample](https://github.com/MateriiApps/pullrefresh/blob/main/demo/src/main/java/dev/materii/pullrefresh/demo/sample/DragRefreshSample.kt). 55 | 56 | | Default | Flipped | 57 | | ------- | ------- | 58 | | Drag refresh demo | Flipped drag refresh demo | 59 | 60 | ```kt 61 | @Composable 62 | fun Test() { 63 | var isRefreshing by remember { 64 | mutableStateOf(false) 65 | } 66 | var pullRefreshState = rememberPullRefreshState(refreshing = isRefreshing, onRefresh = { /* Refresh some data here */ }) 67 | 68 | DragRefreshLayout( 69 | modifier = modifier, 70 | state = pullRefreshState 71 | ) { 72 | Text("Some content") 73 | } 74 | } 75 | ``` 76 | 77 | ## Notice 78 | All of the included components come directly from the official Jetpack Compose Material library, with only the bare minimum required. 79 | 80 | ``` 81 | Copyright 2022 The Android Open Source Project 82 | 83 | Licensed under the Apache License, Version 2.0 (the "License"); 84 | you may not use this file except in compliance with the License. 85 | You may obtain a copy of the License at 86 | 87 | http://www.apache.org/licenses/LICENSE-2.0 88 | 89 | Unless required by applicable law or agreed to in writing, software 90 | distributed under the License is distributed on an "AS IS" BASIS, 91 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 92 | See the License for the specific language governing permissions and 93 | limitations under the License. 94 | ``` 95 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | alias(libs.plugins.android.application) apply false 3 | alias(libs.plugins.android.library) apply false 4 | alias(libs.plugins.compose) apply false 5 | alias(libs.plugins.compose.compiler) apply false 6 | alias(libs.plugins.kotlin.android) apply false 7 | alias(libs.plugins.kotlin.multiplatform) apply false 8 | } 9 | 10 | allprojects { 11 | group = "dev.materii.pullrefresh" 12 | version = "1.4.0-beta03" 13 | 14 | repositories { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /demo/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /demo/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | alias(libs.plugins.android.application) 3 | alias(libs.plugins.kotlin.android) 4 | alias(libs.plugins.compose.compiler) 5 | } 6 | 7 | android { 8 | namespace = "dev.materii.pullrefresh.demo" 9 | compileSdk = 34 10 | 11 | defaultConfig { 12 | applicationId = "dev.materii.pullrefresh.demo" 13 | minSdk = 21 14 | targetSdk = 34 15 | versionCode = 1 16 | versionName = "1.0" 17 | 18 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" 19 | vectorDrawables { 20 | useSupportLibrary = true 21 | } 22 | } 23 | 24 | buildTypes { 25 | release { 26 | isMinifyEnabled = false 27 | proguardFiles( 28 | getDefaultProguardFile("proguard-android-optimize.txt"), 29 | "proguard-rules.pro" 30 | ) 31 | } 32 | } 33 | compileOptions { 34 | sourceCompatibility = JavaVersion.VERSION_17 35 | targetCompatibility = JavaVersion.VERSION_17 36 | } 37 | kotlinOptions { 38 | jvmTarget = "17" 39 | } 40 | buildFeatures { 41 | compose = true 42 | } 43 | packaging { 44 | resources { 45 | excludes += "/META-INF/{AL2.0,LGPL2.1}" 46 | } 47 | } 48 | } 49 | 50 | dependencies { 51 | implementation(libs.core.ktx) 52 | implementation(libs.lifecycle.runtime.ktx) 53 | implementation(libs.activity.compose) 54 | implementation(libs.material3) 55 | implementation(libs.material.icons.extended) 56 | 57 | implementation(project(":pullrefresh")) 58 | } -------------------------------------------------------------------------------- /demo/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /demo/src/androidTest/java/dev/materii/pullrefresh/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package dev.materii.pullrefresh 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("dev.materii.swiperefresh", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /demo/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 15 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /demo/src/main/java/dev/materii/pullrefresh/demo/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package dev.materii.pullrefresh.demo 2 | 3 | import android.os.Bundle 4 | import androidx.activity.ComponentActivity 5 | import androidx.activity.compose.setContent 6 | import androidx.compose.foundation.ExperimentalFoundationApi 7 | import androidx.compose.foundation.layout.Column 8 | import androidx.compose.foundation.layout.fillMaxSize 9 | import androidx.compose.foundation.layout.padding 10 | import androidx.compose.foundation.pager.HorizontalPager 11 | import androidx.compose.foundation.pager.rememberPagerState 12 | import androidx.compose.material.icons.Icons 13 | import androidx.compose.material.icons.filled.Flip 14 | import androidx.compose.material3.ExperimentalMaterial3Api 15 | import androidx.compose.material3.Icon 16 | import androidx.compose.material3.IconButtonDefaults 17 | import androidx.compose.material3.IconToggleButton 18 | import androidx.compose.material3.MaterialTheme 19 | import androidx.compose.material3.PrimaryTabRow 20 | import androidx.compose.material3.Scaffold 21 | import androidx.compose.material3.Tab 22 | import androidx.compose.material3.Text 23 | import androidx.compose.material3.TopAppBar 24 | import androidx.compose.material3.TopAppBarDefaults 25 | import androidx.compose.material3.surfaceColorAtElevation 26 | import androidx.compose.runtime.getValue 27 | import androidx.compose.runtime.mutableStateOf 28 | import androidx.compose.runtime.remember 29 | import androidx.compose.runtime.rememberCoroutineScope 30 | import androidx.compose.runtime.setValue 31 | import androidx.compose.ui.Modifier 32 | import androidx.compose.ui.res.stringResource 33 | import androidx.compose.ui.unit.dp 34 | import androidx.core.view.WindowCompat 35 | import dev.materii.pullrefresh.demo.sample.DragRefreshSample 36 | import dev.materii.pullrefresh.demo.sample.PullRefreshSample 37 | import dev.materii.pullrefresh.demo.theme.SwipeRefreshTheme 38 | import dev.materii.pullrefresh.pullRefresh 39 | import dev.materii.pullrefresh.rememberPullRefreshState 40 | import kotlinx.coroutines.delay 41 | import kotlinx.coroutines.launch 42 | 43 | class MainActivity : ComponentActivity() { 44 | @OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class) 45 | override fun onCreate(savedInstanceState: Bundle?) { 46 | super.onCreate(savedInstanceState) 47 | WindowCompat.setDecorFitsSystemWindows(window, false) 48 | 49 | setContent { 50 | var flipped by remember { mutableStateOf(false) } 51 | val pagerState = rememberPagerState { 2 } 52 | val scope = rememberCoroutineScope() 53 | var isRefreshing by remember { 54 | mutableStateOf(false) 55 | } 56 | val pullRefreshState = rememberPullRefreshState( 57 | refreshing = isRefreshing, 58 | onRefresh = { 59 | scope.launch { 60 | isRefreshing = true 61 | delay(3_000) 62 | isRefreshing = false 63 | } 64 | } 65 | ) 66 | 67 | SwipeRefreshTheme { 68 | Scaffold( 69 | topBar = { 70 | TopAppBar( 71 | title = { Text(stringResource(R.string.app_name)) }, 72 | colors = TopAppBarDefaults.topAppBarColors( 73 | containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(3.dp) 74 | ), 75 | actions = { 76 | IconToggleButton( 77 | checked = flipped, 78 | onCheckedChange = { checked -> flipped = checked }, 79 | colors = IconButtonDefaults.iconToggleButtonColors( 80 | checkedContainerColor = MaterialTheme.colorScheme.primaryContainer.copy( 81 | alpha = 0.5f 82 | ) 83 | ) 84 | ) { 85 | Icon( 86 | imageVector = Icons.Filled.Flip, 87 | contentDescription = "Flip" 88 | ) 89 | } 90 | } 91 | ) 92 | }, 93 | modifier = Modifier.fillMaxSize() 94 | ) { 95 | Column( 96 | modifier = Modifier.padding(it) 97 | ) { 98 | PrimaryTabRow( 99 | selectedTabIndex = pagerState.currentPage, 100 | containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(3.dp), 101 | divider = {} 102 | ) { 103 | Tab( 104 | text = { Text("Pull to refresh") }, 105 | selected = pagerState.currentPage == 0, 106 | onClick = { 107 | scope.launch { 108 | pagerState.animateScrollToPage(0) 109 | } 110 | } 111 | ) 112 | 113 | Tab( 114 | text = { Text("Drag to refresh") }, 115 | selected = pagerState.currentPage == 1, 116 | onClick = { 117 | scope.launch { 118 | pagerState.animateScrollToPage(1) 119 | } 120 | } 121 | ) 122 | } 123 | 124 | HorizontalPager( 125 | state = pagerState, 126 | modifier = Modifier.fillMaxSize() 127 | ) { page -> 128 | when (page) { 129 | 0 -> PullRefreshSample( 130 | flipped = flipped, 131 | pullRefreshState = pullRefreshState, 132 | modifier = Modifier.fillMaxSize(), 133 | ) 134 | 135 | 1 -> DragRefreshSample( 136 | flipped = flipped, 137 | pullRefreshState = pullRefreshState, 138 | modifier = Modifier.fillMaxSize() 139 | ) 140 | } 141 | } 142 | } 143 | } 144 | } 145 | } 146 | } 147 | } -------------------------------------------------------------------------------- /demo/src/main/java/dev/materii/pullrefresh/demo/sample/DragRefreshSample.kt: -------------------------------------------------------------------------------- 1 | package dev.materii.pullrefresh.demo.sample 2 | 3 | import androidx.compose.foundation.layout.Box 4 | import androidx.compose.foundation.layout.fillMaxSize 5 | import androidx.compose.foundation.rememberScrollState 6 | import androidx.compose.foundation.verticalScroll 7 | import androidx.compose.material3.MaterialTheme 8 | import androidx.compose.material3.Text 9 | import androidx.compose.runtime.Composable 10 | import androidx.compose.ui.Alignment 11 | import androidx.compose.ui.Modifier 12 | import dev.materii.pullrefresh.DragRefreshIndicator 13 | import dev.materii.pullrefresh.DragRefreshLayout 14 | import dev.materii.pullrefresh.PullRefreshState 15 | 16 | @Composable 17 | fun DragRefreshSample( 18 | flipped: Boolean, 19 | pullRefreshState: PullRefreshState, 20 | modifier: Modifier = Modifier 21 | ) { 22 | DragRefreshLayout( 23 | modifier = modifier, 24 | state = pullRefreshState, 25 | flipped = flipped, 26 | indicator = { 27 | DragRefreshIndicator( 28 | state = pullRefreshState, 29 | flipped = flipped, 30 | color = MaterialTheme.colorScheme.primary 31 | ) 32 | } 33 | ) { 34 | Box( 35 | modifier = Modifier 36 | .fillMaxSize() 37 | .verticalScroll(rememberScrollState()), 38 | contentAlignment = Alignment.Center 39 | ) { 40 | Text(text = "Pull ${if (flipped) "up" else "down"} to refresh") 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /demo/src/main/java/dev/materii/pullrefresh/demo/sample/PullRefreshSample.kt: -------------------------------------------------------------------------------- 1 | package dev.materii.pullrefresh.demo.sample 2 | 3 | import androidx.compose.foundation.layout.Box 4 | import androidx.compose.foundation.layout.fillMaxSize 5 | import androidx.compose.foundation.rememberScrollState 6 | import androidx.compose.foundation.verticalScroll 7 | import androidx.compose.material3.MaterialTheme 8 | import androidx.compose.material3.Text 9 | import androidx.compose.material3.surfaceColorAtElevation 10 | import androidx.compose.runtime.Composable 11 | import androidx.compose.ui.Alignment 12 | import androidx.compose.ui.Modifier 13 | import androidx.compose.ui.unit.dp 14 | import dev.materii.pullrefresh.PullRefreshLayout 15 | import dev.materii.pullrefresh.PullRefreshIndicator 16 | import dev.materii.pullrefresh.PullRefreshState 17 | 18 | @Composable 19 | fun PullRefreshSample( 20 | flipped: Boolean, 21 | pullRefreshState: PullRefreshState, 22 | modifier: Modifier = Modifier 23 | ) { 24 | PullRefreshLayout( 25 | modifier = modifier, 26 | state = pullRefreshState, 27 | flipped = flipped, 28 | indicator = { 29 | PullRefreshIndicator( 30 | state = pullRefreshState, 31 | flipped = flipped, 32 | backgroundColor = MaterialTheme.colorScheme.surfaceColorAtElevation(3.dp), 33 | contentColor = MaterialTheme.colorScheme.primary 34 | ) 35 | } 36 | ) { 37 | Box( 38 | modifier = Modifier 39 | .fillMaxSize() 40 | .verticalScroll(rememberScrollState()), 41 | contentAlignment = Alignment.Center 42 | ) { 43 | Text(text = "Pull ${if (flipped) "up" else "down"} to refresh") 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /demo/src/main/java/dev/materii/pullrefresh/demo/theme/Theme.kt: -------------------------------------------------------------------------------- 1 | package dev.materii.pullrefresh.demo.theme 2 | 3 | import android.app.Activity 4 | import android.os.Build 5 | import androidx.compose.foundation.isSystemInDarkTheme 6 | import androidx.compose.material3.MaterialTheme 7 | import androidx.compose.material3.darkColorScheme 8 | import androidx.compose.material3.dynamicDarkColorScheme 9 | import androidx.compose.material3.dynamicLightColorScheme 10 | import androidx.compose.material3.lightColorScheme 11 | import androidx.compose.runtime.Composable 12 | import androidx.compose.runtime.SideEffect 13 | import androidx.compose.ui.graphics.Color 14 | import androidx.compose.ui.graphics.toArgb 15 | import androidx.compose.ui.platform.LocalContext 16 | import androidx.compose.ui.platform.LocalView 17 | import androidx.core.view.WindowCompat 18 | 19 | @Composable 20 | fun SwipeRefreshTheme( 21 | darkTheme: Boolean = isSystemInDarkTheme(), 22 | // Dynamic color is available on Android 12+ 23 | dynamicColor: Boolean = true, 24 | content: @Composable () -> Unit 25 | ) { 26 | val colorScheme = when { 27 | dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { 28 | val context = LocalContext.current 29 | if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) 30 | } 31 | 32 | darkTheme -> darkColorScheme() 33 | else -> lightColorScheme() 34 | } 35 | val view = LocalView.current 36 | if (!view.isInEditMode) { 37 | SideEffect { 38 | val window = (view.context as Activity).window 39 | window.statusBarColor = Color.Transparent.toArgb() 40 | window.navigationBarColor = Color.Transparent.toArgb() 41 | WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = !darkTheme 42 | } 43 | } 44 | 45 | MaterialTheme( 46 | colorScheme = colorScheme, 47 | content = content 48 | ) 49 | } -------------------------------------------------------------------------------- /demo/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MateriiApps/pullrefresh/0deeec24bef8e439d5c4117b9b7dfecc65d1d41b/demo/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MateriiApps/pullrefresh/0deeec24bef8e439d5c4117b9b7dfecc65d1d41b/demo/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MateriiApps/pullrefresh/0deeec24bef8e439d5c4117b9b7dfecc65d1d41b/demo/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MateriiApps/pullrefresh/0deeec24bef8e439d5c4117b9b7dfecc65d1d41b/demo/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MateriiApps/pullrefresh/0deeec24bef8e439d5c4117b9b7dfecc65d1d41b/demo/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MateriiApps/pullrefresh/0deeec24bef8e439d5c4117b9b7dfecc65d1d41b/demo/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MateriiApps/pullrefresh/0deeec24bef8e439d5c4117b9b7dfecc65d1d41b/demo/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MateriiApps/pullrefresh/0deeec24bef8e439d5c4117b9b7dfecc65d1d41b/demo/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MateriiApps/pullrefresh/0deeec24bef8e439d5c4117b9b7dfecc65d1d41b/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MateriiApps/pullrefresh/0deeec24bef8e439d5c4117b9b7dfecc65d1d41b/demo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /demo/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /demo/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Pull Refresh Demo 3 | -------------------------------------------------------------------------------- /demo/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |