2022-08-29 17:18:06 -04:00
|
|
|
package eu.kanade.presentation.components
|
|
|
|
|
|
|
|
import androidx.compose.foundation.isSystemInDarkTheme
|
|
|
|
import androidx.compose.foundation.layout.Row
|
2022-09-11 17:59:08 -04:00
|
|
|
import androidx.compose.foundation.layout.padding
|
2022-08-29 17:18:06 -04:00
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
|
import androidx.compose.material3.TabPosition
|
|
|
|
import androidx.compose.material3.TabRowDefaults
|
|
|
|
import androidx.compose.material3.TabRowDefaults.tabIndicatorOffset
|
|
|
|
import androidx.compose.material3.Text
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.ui.Alignment
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
import androidx.compose.ui.draw.clip
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
fun TabIndicator(currentTabPosition: TabPosition) {
|
|
|
|
TabRowDefaults.Indicator(
|
|
|
|
Modifier
|
|
|
|
.tabIndicatorOffset(currentTabPosition)
|
2022-09-11 17:59:08 -04:00
|
|
|
.padding(horizontal = 8.dp)
|
2022-08-29 17:18:06 -04:00
|
|
|
.clip(RoundedCornerShape(topStart = 3.dp, topEnd = 3.dp)),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
fun TabText(
|
|
|
|
text: String,
|
|
|
|
badgeCount: Int? = null,
|
|
|
|
isCurrentPage: Boolean,
|
|
|
|
) {
|
|
|
|
val pillAlpha = if (isSystemInDarkTheme()) 0.12f else 0.08f
|
|
|
|
|
|
|
|
Row(
|
|
|
|
verticalAlignment = Alignment.CenterVertically,
|
|
|
|
) {
|
|
|
|
Text(
|
|
|
|
text = text,
|
|
|
|
color = if (isCurrentPage) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onBackground,
|
|
|
|
)
|
|
|
|
if (badgeCount != null) {
|
|
|
|
Pill(
|
|
|
|
text = "$badgeCount",
|
|
|
|
color = MaterialTheme.colorScheme.onBackground.copy(alpha = pillAlpha),
|
|
|
|
fontSize = 10.sp,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|