/ToggleTab

Simple Tab bar like toggle

Primary LanguageKotlin

ToggleTab



License API


How to Use

Gradle

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

dependencies {
    implementation "com.github.ocetin00:ToggleTab:1.0.0"
}

Create ToggleTab

    @Preview
    @Composable
    fun ToggleTabPreview1() {
        Row(
            horizontalArrangement = Arrangement.Center,
            modifier = Modifier
                .padding(top = 10.dp)
                .fillMaxWidth()
        ) {
            ToggleTab(modifier = Modifier.fillMaxWidth(0.6f),titleList = listOf("Male", "Famele"), onTabSelected = {})
        }
    }

Create ToggleTab

You can create toggle-tab with selected color,container color and text style

Keep reading for more details
   @Preview
@Composable
fun ToggleTabPreview2() {
    var selectedPageIndex by remember {
        mutableStateOf(1)
    }

    Column(
        modifier = Modifier
            .fillMaxSize()
            .background(Color.White)
    ) {
        Row(
            modifier = Modifier
                .padding(vertical = 20.dp)
                .fillMaxWidth()
                .background(Color.White), horizontalArrangement = Arrangement.Center
        ) {
            ToggleTab(
                modifier = Modifier
                    .fillMaxWidth(fraction = 0.9f)
                    .clip(ShapeDefaults.ExtraLarge),
                onTabSelected = { index ->
                    selectedPageIndex = index
                },
                titleList = listOf("First", "Second", "Third"),
                tabItemTextStyle = TextStyle.Default.copy(
                    fontSize = 12.sp,
                    fontWeight = FontWeight.Bold
                )
            )
        }
        var backgroundColor: Color = when (selectedPageIndex) {
            0 -> Color.Green
            1 -> Color.Magenta
            2 -> Color.Cyan
            else -> {
                Color.Green
            }
        }
        Column(
            modifier = Modifier
                .padding(20.dp)
                .fillMaxSize()
                .background(backgroundColor)
        ) {

        }
    }
}

Find this library useful? ❤️

follow me on GitHub for my next creations!

License

Copyright 2019 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.