fix: 从通知打开消息页面布局异常
This commit is contained in:
parent
9382e30885
commit
625a9b9ff8
|
|
@ -35,6 +35,7 @@ import com.ramcosta.composedestinations.annotation.Destination
|
||||||
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
|
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
@Destination(
|
@Destination(
|
||||||
deepLinks = [
|
deepLinks = [
|
||||||
DeepLink(uriPattern = "tblite://notifications/{initialTab}")
|
DeepLink(uriPattern = "tblite://notifications/{initialTab}")
|
||||||
|
|
@ -45,8 +46,21 @@ fun NotificationsPage(
|
||||||
navigator: DestinationsNavigator,
|
navigator: DestinationsNavigator,
|
||||||
initialTab: Int = 0,
|
initialTab: Int = 0,
|
||||||
) {
|
) {
|
||||||
|
val pages = listOf<Pair<String, (@Composable () -> Unit)>>(
|
||||||
|
stringResource(id = R.string.title_reply_me) to @Composable {
|
||||||
|
NotificationsListPage(type = NotificationsType.ReplyMe)
|
||||||
|
},
|
||||||
|
stringResource(id = R.string.title_at_me) to @Composable {
|
||||||
|
NotificationsListPage(type = NotificationsType.AtMe)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
val pagerState = rememberPagerState(
|
||||||
|
initialPage = initialTab,
|
||||||
|
) { pages.size }
|
||||||
|
val coroutineScope = rememberCoroutineScope()
|
||||||
ProvideNavigator(navigator = navigator) {
|
ProvideNavigator(navigator = navigator) {
|
||||||
MyScaffold(
|
MyScaffold(
|
||||||
|
backgroundColor = Color.Transparent,
|
||||||
topBar = {
|
topBar = {
|
||||||
TitleCentredToolbar(
|
TitleCentredToolbar(
|
||||||
title = { Text(text = stringResource(id = R.string.title_notifications)) },
|
title = { Text(text = stringResource(id = R.string.title_notifications)) },
|
||||||
|
|
@ -55,11 +69,45 @@ fun NotificationsPage(
|
||||||
navigator.navigateUp()
|
navigator.navigateUp()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
) {
|
||||||
|
TabRow(
|
||||||
|
selectedTabIndex = pagerState.currentPage,
|
||||||
|
indicator = { tabPositions ->
|
||||||
|
PagerTabIndicator(
|
||||||
|
pagerState = pagerState,
|
||||||
|
tabPositions = tabPositions
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
modifier = Modifier.fillMaxSize(),
|
divider = {},
|
||||||
|
backgroundColor = Color.Transparent,
|
||||||
|
contentColor = ExtendedTheme.colors.onTopBar,
|
||||||
) {
|
) {
|
||||||
NotificationsPage(initialTab = initialTab)
|
pages.forEachIndexed { index, pair ->
|
||||||
|
Tab(
|
||||||
|
text = { Text(text = pair.first) },
|
||||||
|
selected = pagerState.currentPage == index,
|
||||||
|
onClick = {
|
||||||
|
coroutineScope.launch {
|
||||||
|
pagerState.animateScrollToPage(index)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
modifier = Modifier.fillMaxSize(),
|
||||||
|
) { paddingValues ->
|
||||||
|
LazyLoadHorizontalPager(
|
||||||
|
state = pagerState,
|
||||||
|
contentPadding = paddingValues,
|
||||||
|
key = { pages[it].first },
|
||||||
|
modifier = Modifier.fillMaxSize(),
|
||||||
|
verticalAlignment = Alignment.Top,
|
||||||
|
userScrollEnabled = true,
|
||||||
|
) {
|
||||||
|
pages[it].second()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue