Skip to content

ocetin00/PageIndicator

Repository files navigation

Page-Indicator



License API


How to Use

Gradle

Add it in your root module's build.gradle at the end of repositories

allprojects {
	repositories {
		maven { url 'https://jitpack.io' }
	}
}

Add the dependency below to your module's build.gradle file:

dependencies {
     implementation "com.github.ocetin00:PageIndicator:1.1"
}

Create Page-Indicator

@OptIn(ExperimentalMaterial3Api::class)
@Preview
@Composable
fun PageIndicatorPreview(
    pageIndicatorState: PageIndicatorState = rememberPageIndicatorState(
        listOf(
            "First",
            "Second",
            "Third",
            "Fourth"
        )
    )

) {
    Column(
        modifier = Modifier.fillMaxSize(),
    ) {
      
        PageIndicator(
            pageIndicatorState = pageIndicatorState,
            indicatorColor = MaterialTheme.colorScheme.primary,
            onIndicatorColor = MaterialTheme.colorScheme.onPrimary,
        )
        Row(){
            Button(onClick = { pageIndicatorState.onPrevious() }) {
                Text("Previous")
            }
            Button(onClick = { pageIndicatorState.onNext() }) {
                Text("Next")
            }

        }

        Text("current page: ${pageIndicatorState.current+1}")
    }

}

Find this library useful? ❤️

follow me on GitHub for my next creations!

License

Copyright 2023 ocetin00 (Oğuzhan Çetin)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.