A page step indicator for Android jetpack compose. If your project doesn't yet support Compose,
checkout the other page stepper for XML
layouts.
- Add it to your root build.gradle at the end of repositories:
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.devmike01:PageStepIndicator-Compose:alpha01'
}
dependencies {
implementation("com.github.devmike01:PageStepIndicator-Compose:1.0.1-alpha")
}
That's all you need to use the library.
Compiling...
val indicatorState = rememberIndicatorPropertyState(
IndicatorProperty(labels = listOf(IndicatorLabel("Rice"),
IndicatorLabel("Beans"), IndicatorLabel("Soda and Wine"),
IndicatorLabel("Soda"), IndicatorLabel("Beans and Rice")))
)
val pageState = rememberPagerState()
PageStepIndicator(
stepColor= IndicatorColor(
strokeActiveColor = android.graphics.Color.YELLOW,
activeColor = android.graphics.Color.GREEN,
inActiveColor = android.graphics.Color.YELLOW
),
propertyState =indicatorState,
indicatorState = rememberIndicatorState(),
pagerState = pageState){ indicatorState, pagerState ->
HorizontalPager(count = 5, state = pagerState) {
Column(modifier = Modifier
.fillMaxWidth()
.fillMaxHeight(),
horizontalAlignment = Alignment.CenterHorizontally) {
Box(modifier = Modifier.fillMaxWidth(fraction = 0.9f)
.fillMaxHeight()
.background(Color.Blue.copy(red = (pagerState.currentPage*0.2).toFloat())))
}
}
}
Copyright 2023 Oladipupo Gbenga
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.