You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iceraven-browser/app/src/main/java/org/mozilla/fenix/compose/TabTitle.kt

54 lines
1.5 KiB
Kotlin

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.compose
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.sp
import org.mozilla.fenix.theme.FirefoxTheme
/**
* Default layout for a tab composable title.
*
* @param text Tab title
* @param maxLines Maximum number of lines for [text] to span, wrapping if necessary.
* If the text exceeds the given number of lines it will be ellipsized.
* @param modifier Optional [Modifier] to be applied to the layout.
*/
@Composable
fun TabTitle(
text: String,
maxLines: Int,
modifier: Modifier = Modifier
) {
Text(
modifier = modifier,
maxLines = maxLines,
text = text,
style = TextStyle(fontSize = 14.sp),
overflow = TextOverflow.Ellipsis,
color = FirefoxTheme.colors.textPrimary
)
}
@Composable
@Preview
private fun TabTitlePreview() {
FirefoxTheme {
Box(Modifier.background(FirefoxTheme.colors.layer2)) {
TabTitle(
"Awesome tab title",
2
)
}
}
}