PageRoundDemo - Page Round Demo with kotlin

Overview

PageRoundDemo

I don't like the mode of swiping to the bottom to load more, as it doesn't quickly jump to a specific location.

Also, the paging 2 or 3 library that Jetpack offered is not easy to use. It is too deeply bound to ViewModel or Repository structure. It is difficult to freely change the structure later on.

I like to select pages directly. It's sample and clear. I found that there is very little such code on Github, so I extracted the relevant code from my own project, maybe someone needs this reference.

You can copy the PageRound.kt file directly to your project directory. Currently there is only Compose version.

You need to define your favorite button and spacer pattern, and then pass to the PageRound(), very simple. App.kt is an example.

video_2022-01-23_10-31-23.mp4

Usage

photo_2022-01-23_17-00-01

Above shows one RoundInterval is between the RoundButton 1 and 4, another is between RoundButton 8 and 30.

First, define your RoundInterval and RoundButton:

val RoundInterval = @Composable {
    Box(
        modifier = Modifier
            .fillMaxSize()
            .padding(2.dp)
            .background(Color(0x22AC9C95)),
        contentAlignment = Alignment.Center
    ) {
        Text(text = "---")
    }
}

val RoundButton = @Composable { count: Int, isCurrent: Boolean, onClick: (Int) -> Unit ->
    Box(
        modifier = Modifier
            .padding(2.dp)
            .aspectRatio(1f)
            .clip(CircleShape)
            .fillMaxSize()
            .clickable { onClick(count) }
            .background(if (isCurrent) Color(0xFFACDC75) else Color(0xFF6C9C35)),
        contentAlignment = Alignment.Center
    ) {
        Text(text = "${count}")
    }
}

And then, put it into PageRound()

Box(modifier = Modifier
        .fillMaxWidth(1f)
        .height(40.dp)
        .background(Color(0xffccccff)),
        contentAlignment = Alignment.Center
    ) {
        PageRound(
            current = current,
            ext = ext,
            totalDocs = totalDocs,
            pageSize = pageSize,
            onClick = { current = it },
            RoundButton = RoundButton,
            RoundInterval = RoundInterval
        )
    }

Done!

License

MIT

You might also like...
A demo project which demonstrates the work of javax.servlet.Filter  capable of escaping / modifying / removing a part of JSON request based on specified criteria.
A demo project which demonstrates the work of javax.servlet.Filter capable of escaping / modifying / removing a part of JSON request based on specified criteria.

Replace Filter Demo A demo project which demonstrates the work of javax.servlet.Filter capable of escaping / modifying / removing a part of JSON reque

Kafka-hot-and-cold-retries - Demo project for elaborating how hot and cold retries can be applied in Kafka
Kafka-hot-and-cold-retries - Demo project for elaborating how hot and cold retries can be applied in Kafka

Apache Kafka® - Hot and Cold Retries A demo project for elaborating how hot and

Android BlazePose demo by ncnn
Android BlazePose demo by ncnn

ncnn_Android_BlazePose Android BlazePose demo by ncnn this project is a ncnn Android demo for BlazePose, it depends on ncnn library and opencv. https:

Amazon IVS Live to VOD (DVR) Android demo
Amazon IVS Live to VOD (DVR) Android demo

A demo Android app showing how to implement a Live to VOD (DVR) experience using Amazon IVS and the auto-record-to-s3 feature using Amazon S3.

Repo: Programming problems with solutions in Kotlin to help avid Kotlin learners to get a strong hold on Kotlin programming.

Kotlin_practice_problems Repo: Programming problems with solutions in Kotlin to help avid Kotlin learners to get a strong hold on Kotlin programming.

Mocking for Kotlin/Native and Kotlin Multiplatform using the Kotlin Symbol Processing API (KSP)

Mockative Mocking for Kotlin/Native and Kotlin Multiplatform using the Kotlin Symbol Processing API (KSP). Installation Mockative uses KSP to generate

Kotlin-oop - Repositório criado para ser utilizado pelo projeto de Kotlin OOP desenvolvido em Kotlin nas aulas feitas através da plataforma Alura.

Projeto React OOP Repositório criado para ser utilizado pelo projeto de Kotlin OOP desenvolvido em Kotlin nas aulas feitas através da plataforma Alura

Kotlin-koans - Kotlin Koans are a series of exercises to get you familiar with the Kotlin Syntax

kotlin-koans-edu Kotlin Koans are a series of exercises to get you familiar with

Integration Testing Kotlin Multiplatform Kata for Kotlin Developers. The main goal is to practice integration testing using Ktor and Ktor Client Mock
Integration Testing Kotlin Multiplatform Kata for Kotlin Developers. The main goal is to practice integration testing using Ktor and Ktor Client Mock

This kata is a Kotlin multiplatform version of the kata KataTODOApiClientKotlin of Karumi. We are here to practice integration testing using HTTP stub

Owner
Hongyu You
Hongyu You
A login page where we have a designied login button

Googlesignin This is a login page where we have a designied login button ,when we click the button then it move to further process There will be autom

PRAVEEN R 1 Dec 12, 2021
Add page & limit as GET parameter to get all titans data in a paginated format

Add page & limit as GET parameter to get all titans data in a paginated format (default values : page=1 and limit=3). Here the page param is the page number which you require and limit is the maximum number of items per page. Sample Request :

krishna chaitanya 1 Jan 31, 2022
Kotlin TodoMVC – full-stack Kotlin application demo

Kotlin full stack TodoMVC This project is an example implementation of the TodoMVC app written in Kotlin. More specifically, it's the Kotlin port of t

Gyula Voros 22 Oct 3, 2022
TheMovies 🎬 A demo project for The Movie DB based on Kotlin MVVM architecture and material design & animations.

A simple project for The Movie DB based on Kotlin MVVM clean architecture and material design & animations. How to build on your environment

Jaewoong Eum 420 Nov 29, 2022
Demo Spting REST Service on Kotlin. Works with PostgreSQL via Spring Data. Data initialization provided by liquibase

Spring Boot REST API with Kotlin Spring Boot REST API service. Spring Data with PostgreSQL. Data initialization with Liquibase. Swagger UI Reference D

null 0 Jun 10, 2022
A simple demo project based on MVVM clean architecture and material design & animations.

GithubFollows A simple demo project based on MVVM clean architecture and material design & animations. Architecture Specs & Open-source libraries Mini

Jaewoong Eum 288 Dec 25, 2022
Android human matting demo infer by ncnn

ncnn_Android_modnet Android human matting demo infer by ncnn the model from MODNet: Trimap-Free Portrait Matting in Real Time support model 1.mobilene

FeiGeChuanShu 43 Jan 4, 2023
A seed and demo about how to do end-to-end testing of a Dataflow pipeline

dataflow-e2e-demo This is a demo and a seed project to show how you can end-to-end test a Dataflow pipeline. You can find more about by follwing this

null 0 Dec 18, 2021
Spring Boot KeyCloak Demo

Spring Boot(Kotlin) + Spring Security + Keycloak Demo Docker Keycloak + MariaDB 설정 및 기본 KeyCloak 사용법 Keycloak 이미지와 MariaDB 이미지를 다운 받는다. [root@~]# dock

null 0 Jan 4, 2022
Demo to show ongoing notification on Huawei P50 Pocket

Bali Demo Demo code to show different ongoing notification types on the Huawei P50 Pocket external screen. Currently the external screen provides THRE

minkiapps 0 Jan 14, 2022