Skip to content

Instantly share code, notes, and snippets.

View MrNtlu's full-sized avatar
👨‍💻
Coding

Burak Fidan MrNtlu

👨‍💻
Coding
View GitHub Profile
@MrNtlu
MrNtlu / MainScreen.kt
Created December 11, 2022 13:34
TabRow P3
Column(
modifier = Modifier
.padding(contentPadding)
) {
TabRow(
//...
) {
//...
}
HorizontalPager(
@MrNtlu
MrNtlu / MainScreen.kt
Created December 11, 2022 13:29
TabRow P2
Column(
modifier = Modifier
.padding(contentPadding)
) {
TabRow(
//..
) {
tabRowItems.forEachIndexed { index, item ->
Tab(
selected = pagerState.currentPage == index,
@MrNtlu
MrNtlu / MainScreen.kt
Created December 11, 2022 13:28
TabRow P1
Column(
modifier = Modifier
.padding(contentPadding)
) {
TabRow(
selectedTabIndex = pagerState.currentPage,
indicator = { tabPositions ->
TabRowDefaults.Indicator(
Modifier.pagerTabIndicatorOffset(pagerState, tabPositions),
color = MaterialTheme.colors.secondary
val pagerState = rememberPagerState()
val coroutineScope = rememberCoroutineScope()
Column(
modifier = Modifier
.padding(contentPadding)
) {
TabRow(
selectedTabIndex = pagerState.currentPage,
indicator = { tabPositions ->
@Composable
fun TabScreen(
text: String,
) {
Box(
modifier = Modifier
.fillMaxSize(),
contentAlignment = Alignment.Center,
) {
Text(
@MrNtlu
MrNtlu / MainActivity.kt
Created December 10, 2022 13:44
Jetpack Compose Bottom App Bar
androidx.compose.material3.BottomAppBar(
containerColor = MaterialTheme.colors.primary,
actions = {
IconButton(onClick = { /* Check onClick */ }) {
Icon(Icons.Filled.Check, contentDescription = "", tint = Color.White)
}
IconButton(onClick = { /* Edit onClick */ }) {
Icon(
Icons.Filled.Edit, contentDescription = "", tint = Color.White)
}
@MrNtlu
MrNtlu / MainActivity.kt
Created December 10, 2022 13:13
Jetpack Compose Navigation Bar Alt
//Instead of backStackEntry
var selectedItem by remember { mutableStateOf(0) }
//Replace bottomNavItems.forEach with,
bottomNavItems.forEachIndexed { index, item ->
NavigationBarItem(
selected = selectedItem == index,
onClick = {
selectedItem = index
navController.navigate(item.route)
@MrNtlu
MrNtlu / MainActivity.kt
Created December 10, 2022 13:07
Jetpack Compose Navigation Bar
// NavController is passed via parameter
val backStackEntry = navController.currentBackStackEntryAsState()
Scaffold(
bottomBar = {
androidx.compose.material3.NavigationBar(
containerColor = MaterialTheme.colors.primary,
) {
bottomNavItems.forEach { item ->
val selected = item.route == backStackEntry.value?.destination?.route
Surface(
modifier = Modifier
.fillMaxWidth()
.height(56.dp),
) {
TextField(
modifier = Modifier
.fillMaxWidth(),
value = searchTextState,
onValueChange = {
Scaffold(
topBar = {
if (searchWidgetState == SearchWidgetState.OPENED) {
SearchAppBar()
} else {
TopAppBar(
//...
actions = {
IconButton(onClick = { searchWidgetState = SearchWidgetState.OPENED }) {
Icon(