MediaViewerView: move TopBar to Scaffold topbar
This commit is contained in:
parent
2c226c8de0
commit
24b0585747
1 changed files with 46 additions and 46 deletions
|
|
@ -121,6 +121,52 @@ fun MediaViewerView(
|
||||||
Scaffold(
|
Scaffold(
|
||||||
modifier,
|
modifier,
|
||||||
containerColor = Color.Transparent,
|
containerColor = Color.Transparent,
|
||||||
|
topBar = {
|
||||||
|
AnimatedVisibility(
|
||||||
|
visible = showOverlay,
|
||||||
|
enter = fadeIn(),
|
||||||
|
exit = fadeOut(),
|
||||||
|
) {
|
||||||
|
when (currentData) {
|
||||||
|
is MediaViewerPageData.MediaViewerData -> {
|
||||||
|
MediaViewerTopBar(
|
||||||
|
data = currentData,
|
||||||
|
canShowInfo = state.canShowInfo,
|
||||||
|
onBackClick = onBackClick,
|
||||||
|
onShareClick = {
|
||||||
|
state.eventSink(MediaViewerEvent.Share(currentData))
|
||||||
|
},
|
||||||
|
onSaveClick = {
|
||||||
|
state.eventSink(MediaViewerEvent.SaveOnDisk(currentData))
|
||||||
|
},
|
||||||
|
onInfoClick = {
|
||||||
|
state.eventSink(MediaViewerEvent.OpenInfo(currentData))
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
TopAppBar(
|
||||||
|
title = {
|
||||||
|
if (currentData is MediaViewerPageData.Loading) {
|
||||||
|
Text(
|
||||||
|
modifier = Modifier.semantics {
|
||||||
|
heading()
|
||||||
|
},
|
||||||
|
text = stringResource(id = CommonStrings.common_loading_more),
|
||||||
|
style = ElementTheme.typography.fontBodyMdMedium,
|
||||||
|
color = ElementTheme.colors.textPrimary,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
colors = TopAppBarDefaults.topAppBarColors(
|
||||||
|
containerColor = bgCanvasWithTransparency,
|
||||||
|
),
|
||||||
|
navigationIcon = { BackButton(onClick = onBackClick) },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
snackbarHost = { SnackbarHost(snackbarHostState) },
|
snackbarHost = { SnackbarHost(snackbarHostState) },
|
||||||
) {
|
) {
|
||||||
val pagerState = rememberPagerState(state.currentIndex, 0f) {
|
val pagerState = rememberPagerState(state.currentIndex, 0f) {
|
||||||
|
|
@ -131,52 +177,6 @@ fun MediaViewerView(
|
||||||
state.eventSink(MediaViewerEvent.OnNavigateTo(page))
|
state.eventSink(MediaViewerEvent.OnNavigateTo(page))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Top bar
|
|
||||||
AnimatedVisibility(
|
|
||||||
modifier = Modifier.zIndex(1f),
|
|
||||||
visible = showOverlay,
|
|
||||||
enter = fadeIn(),
|
|
||||||
exit = fadeOut(),
|
|
||||||
) {
|
|
||||||
when (currentData) {
|
|
||||||
is MediaViewerPageData.MediaViewerData -> {
|
|
||||||
MediaViewerTopBar(
|
|
||||||
data = currentData,
|
|
||||||
canShowInfo = state.canShowInfo,
|
|
||||||
onBackClick = onBackClick,
|
|
||||||
onShareClick = {
|
|
||||||
state.eventSink(MediaViewerEvent.Share(currentData))
|
|
||||||
},
|
|
||||||
onSaveClick = {
|
|
||||||
state.eventSink(MediaViewerEvent.SaveOnDisk(currentData))
|
|
||||||
},
|
|
||||||
onInfoClick = {
|
|
||||||
state.eventSink(MediaViewerEvent.OpenInfo(currentData))
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
TopAppBar(
|
|
||||||
title = {
|
|
||||||
if (currentData is MediaViewerPageData.Loading) {
|
|
||||||
Text(
|
|
||||||
modifier = Modifier.semantics {
|
|
||||||
heading()
|
|
||||||
},
|
|
||||||
text = stringResource(id = CommonStrings.common_loading_more),
|
|
||||||
style = ElementTheme.typography.fontBodyMdMedium,
|
|
||||||
color = ElementTheme.colors.textPrimary,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
colors = TopAppBarDefaults.topAppBarColors(
|
|
||||||
containerColor = bgCanvasWithTransparency,
|
|
||||||
),
|
|
||||||
navigationIcon = { BackButton(onClick = onBackClick) },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
HorizontalPager(
|
HorizontalPager(
|
||||||
state = pagerState,
|
state = pagerState,
|
||||||
modifier = Modifier,
|
modifier = Modifier,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue