
* Remove detekt (mihonapp/mihon#1130) Annoying. More annoying in this project. (cherry picked from commit 777ae2461e1eb277a3aa0c998ff69e4f100387a1) * Add spotless (with ktlint) (mihonapp/mihon#1136) (cherry picked from commit 5ae8095ef1ed2ae9f98486f9148e933c77a28692) * Address spotless lint errors (mihonapp/mihon#1138) * Add spotless (with ktlint) * Run spotlessApply * screaming case screaming case screaming case * Update PagerViewerAdapter.kt * Update ReaderTransitionView.kt (cherry picked from commit d6252ab7703d52ecf9f43de3ee36fd63e665a31f) * Generate locales_config.xml in build dir (cherry picked from commit ac41bffdc97b4cfed923de6b9e8e01cccf3eb6eb) * Address more spotless lint errors in SY * some more missed * more missed * still missing, not sure while it won't report error when running locally * one more * more * more * correct comment --------- Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
108 lines
3.8 KiB
Kotlin
108 lines
3.8 KiB
Kotlin
package eu.kanade.presentation.components
|
|
|
|
import androidx.compose.animation.animateContentSize
|
|
import androidx.compose.foundation.layout.Box
|
|
import androidx.compose.foundation.layout.Column
|
|
import androidx.compose.foundation.layout.ColumnScope
|
|
import androidx.compose.foundation.layout.Row
|
|
import androidx.compose.foundation.layout.wrapContentSize
|
|
import androidx.compose.foundation.pager.HorizontalPager
|
|
import androidx.compose.foundation.pager.PagerState
|
|
import androidx.compose.foundation.pager.rememberPagerState
|
|
import androidx.compose.material.icons.Icons
|
|
import androidx.compose.material.icons.filled.MoreVert
|
|
import androidx.compose.material3.HorizontalDivider
|
|
import androidx.compose.material3.Icon
|
|
import androidx.compose.material3.IconButton
|
|
import androidx.compose.material3.MaterialTheme
|
|
import androidx.compose.material3.PrimaryTabRow
|
|
import androidx.compose.material3.Tab
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.runtime.getValue
|
|
import androidx.compose.runtime.mutableStateOf
|
|
import androidx.compose.runtime.remember
|
|
import androidx.compose.runtime.rememberCoroutineScope
|
|
import androidx.compose.runtime.setValue
|
|
import androidx.compose.ui.Alignment
|
|
import androidx.compose.ui.Modifier
|
|
import androidx.compose.ui.unit.dp
|
|
import androidx.compose.ui.util.fastForEachIndexed
|
|
import kotlinx.collections.immutable.ImmutableList
|
|
import kotlinx.coroutines.launch
|
|
import tachiyomi.i18n.MR
|
|
import tachiyomi.presentation.core.components.material.TabText
|
|
import tachiyomi.presentation.core.i18n.stringResource
|
|
|
|
object TabbedDialogPaddings {
|
|
val Horizontal = 24.dp
|
|
val Vertical = 8.dp
|
|
}
|
|
|
|
@Composable
|
|
fun TabbedDialog(
|
|
onDismissRequest: () -> Unit,
|
|
tabTitles: ImmutableList<String>,
|
|
modifier: Modifier = Modifier,
|
|
tabOverflowMenuContent: (@Composable ColumnScope.(() -> Unit) -> Unit)? = null,
|
|
pagerState: PagerState = rememberPagerState { tabTitles.size },
|
|
content: @Composable (Int) -> Unit,
|
|
) {
|
|
AdaptiveSheet(
|
|
modifier = modifier,
|
|
onDismissRequest = onDismissRequest,
|
|
) {
|
|
val scope = rememberCoroutineScope()
|
|
|
|
Column {
|
|
Row {
|
|
PrimaryTabRow(
|
|
modifier = Modifier.weight(1f),
|
|
selectedTabIndex = pagerState.currentPage,
|
|
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh,
|
|
divider = {},
|
|
) {
|
|
tabTitles.fastForEachIndexed { index, tab ->
|
|
Tab(
|
|
selected = pagerState.currentPage == index,
|
|
onClick = { scope.launch { pagerState.animateScrollToPage(index) } },
|
|
text = { TabText(text = tab) },
|
|
unselectedContentColor = MaterialTheme.colorScheme.onSurface,
|
|
)
|
|
}
|
|
}
|
|
|
|
tabOverflowMenuContent?.let { MoreMenu(it) }
|
|
}
|
|
HorizontalDivider()
|
|
|
|
HorizontalPager(
|
|
modifier = Modifier.animateContentSize(),
|
|
state = pagerState,
|
|
verticalAlignment = Alignment.Top,
|
|
pageContent = { page -> content(page) },
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
@Composable
|
|
private fun MoreMenu(
|
|
content: @Composable ColumnScope.(() -> Unit) -> Unit,
|
|
) {
|
|
var expanded by remember { mutableStateOf(false) }
|
|
Box(modifier = Modifier.wrapContentSize(Alignment.TopStart)) {
|
|
IconButton(onClick = { expanded = true }) {
|
|
Icon(
|
|
imageVector = Icons.Default.MoreVert,
|
|
contentDescription = stringResource(MR.strings.label_more),
|
|
)
|
|
}
|
|
DropdownMenu(
|
|
expanded = expanded,
|
|
onDismissRequest = { expanded = false },
|
|
) {
|
|
content { expanded = false }
|
|
}
|
|
}
|
|
}
|