Skip to content

Commit

Permalink
add topbar
Browse files Browse the repository at this point in the history
  • Loading branch information
makeevrserg committed Oct 15, 2023
1 parent e322527 commit e3ee079
Showing 1 changed file with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package com.makeevrserg.empireprojekt.mobile.core.ui.components.topbar

import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ChevronLeft
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.makeevrserg.empireprojekt.mobile.core.ui.theme.AppTheme

@Composable
fun AstraCenterAlignedTopAppBar(
title: String = "",
onBackClicked: (() -> Unit)? = null,
actions: @Composable RowScope.() -> Unit = {}
) {
AstraCenterAlignedTopAppBar(
onBackClicked = onBackClicked,
actions = actions,
title = {
Text(
text = title,
style = AppTheme.typography.body1,
color = AppTheme.materialColor.onPrimary,
textAlign = TextAlign.Center,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
)
},
)
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AstraCenterAlignedTopAppBar(
title: @Composable () -> Unit,
onBackClicked: (() -> Unit)? = null,
actions: @Composable RowScope.() -> Unit = {}
) {
CenterAlignedTopAppBar(
actions = actions,
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
containerColor = Color.Transparent,
),
title = title,
navigationIcon = {
onBackClicked?.let {
IconButton(onClick = it) {
Icon(
imageVector = Icons.Default.ChevronLeft,
contentDescription = null,
tint = AppTheme.materialColor.onPrimary,
modifier = Modifier.size(24.dp)
)
}
}
}
)
}

0 comments on commit e3ee079

Please sign in to comment.