Initial Setting Pager (#854)
* Update Compose Snapshot * Initial SettingsPager * Cleanup * Fix inactive color * Sync container color with BSheet --------- Co-authored-by: GG Bond <whatever@tagkong.com>
This commit is contained in:
1 parent
47be2754e5
commit
af32d7eea7
3 files changed
+50
-1
No files matched your search
@@ -3,6 +3,7 @@ package com.hippo.ehviewer.ui.reader
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.navigationBarsPadding
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.foundation.pager.rememberPagerState
|
||||
@@ -94,8 +95,10 @@ fun ReaderScreen(info: BaseGalleryInfo, page: Int = -1, navigator: DestinationsN
|
||||
ModalBottomSheet(
|
||||
onDismissRequest = { dispose() },
|
||||
sheetState = state,
|
||||
dragHandle = null,
|
||||
windowInsets = WindowInsets(0),
|
||||
) {
|
||||
SettingsPager(modifier = Modifier.fillMaxWidth())
|
||||
Spacer(modifier = Modifier.navigationBarsPadding())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.hippo.ehviewer.ui.reader
|
||||
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.pager.HorizontalPager
|
||||
import androidx.compose.foundation.pager.rememberPagerState
|
||||
import androidx.compose.material3.BottomSheetDefaults
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.PrimaryTabRow
|
||||
import androidx.compose.material3.Tab
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.hippo.ehviewer.R
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
private val tabs = arrayOf(
|
||||
R.string.pref_category_reading_mode,
|
||||
R.string.pref_category_general,
|
||||
R.string.custom_filter,
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun SettingsPager(modifier: Modifier = Modifier) {
|
||||
val pagerState = rememberPagerState { tabs.size }
|
||||
val scope = rememberCoroutineScope()
|
||||
PrimaryTabRow(
|
||||
selectedTabIndex = pagerState.currentPage,
|
||||
containerColor = BottomSheetDefaults.ContainerColor,
|
||||
) {
|
||||
tabs.forEachIndexed { index, res ->
|
||||
Tab(
|
||||
selected = pagerState.currentPage == index,
|
||||
onClick = { scope.launch { pagerState.animateScrollToPage(index) } },
|
||||
text = { Text(text = stringResource(id = res)) },
|
||||
unselectedContentColor = MaterialTheme.colorScheme.onSurface,
|
||||
)
|
||||
}
|
||||
}
|
||||
HorizontalPager(modifier = modifier, state = pagerState) {
|
||||
Spacer(modifier = Modifier.size(200.dp))
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -13,7 +13,7 @@ dependencyResolutionManagement {
|
||||
mavenCentral()
|
||||
maven("https://jitpack.io")
|
||||
maven("https://androidx.dev/storage/compose-compiler/repository/")
|
||||
maven("https://androidx.dev/snapshots/builds/11509867/artifacts/repository")
|
||||
maven("https://androidx.dev/snapshots/builds/11527796/artifacts/repository")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user