Skip to content

Commit

Permalink
put title in topbar
Browse files Browse the repository at this point in the history
  • Loading branch information
aualbert committed Jul 8, 2024
1 parent 8183417 commit bdfffee
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 16 deletions.
16 changes: 15 additions & 1 deletion app/src/main/java/me/ash/reader/ui/component/base/RYScaffold.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import me.ash.reader.ui.ext.roundClick
import me.ash.reader.ui.ext.surfaceColorAtElevation
import me.ash.reader.ui.theme.palette.onDark

Expand All @@ -21,6 +24,8 @@ fun RYScaffold(
topBarTonalElevation: Dp = 0.dp,
containerTonalElevation: Dp = 0.dp,
navigationIcon: (@Composable () -> Unit)? = null,
title: String = "",
onTitleClick: (() -> Unit)? = null,
actions: (@Composable RowScope.() -> Unit)? = null,
bottomBar: (@Composable () -> Unit)? = null,
floatingActionButton: (@Composable () -> Unit)? = null,
Expand All @@ -41,7 +46,16 @@ fun RYScaffold(
topBar = {
if (navigationIcon != null || actions != null) {
TopAppBar(
title = {},
title = {Text(
modifier = Modifier
.roundClick(enabled = onTitleClick != null) { onTitleClick?.invoke() }
.padding(8.dp),
text = title,
style = MaterialTheme.typography.titleLarge,
color = MaterialTheme.colorScheme.onSurface,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)},
navigationIcon = { navigationIcon?.invoke() },
actions = { actions?.invoke(this) },
colors = TopAppBarDefaults.topAppBarColors(
Expand Down
14 changes: 8 additions & 6 deletions app/src/main/java/me/ash/reader/ui/page/home/feeds/FeedsPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ fun FeedsPage(
}
}
},
title = feedsUiState.account?.name ?: "",
onTitleClick = { accountTabVisible = true },
actions = {
FeedbackIconButton(
modifier = Modifier.rotate(if (isSyncing) angle else 0f),
Expand All @@ -234,12 +236,12 @@ fun FeedsPage(
LazyColumn (
state = listState
) {
item {
DisplayText(
text = feedsUiState.account?.name ?: "",
desc = if (isSyncing) stringResource(R.string.syncing) else "",
) { accountTabVisible = true }
}
// item {
// DisplayText(
// text = feedsUiState.account?.name ?: "",
// desc = if (isSyncing) stringResource(R.string.syncing) else "",
// ) { accountTabVisible = true }
// }
item {
Banner(
title = filterUiState.filter.toName(),
Expand Down
23 changes: 14 additions & 9 deletions app/src/main/java/me/ash/reader/ui/page/home/flow/FlowPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ fun FlowPage(
}
}
},
title = when {
filterUiState.group != null -> filterUiState.group.name
filterUiState.feed != null -> filterUiState.feed.name
else -> filterUiState.filter.toName()
},
actions = {
RYExtensibleVisibility(visible = !filterUiState.filter.isStarred()) {
FeedbackIconButton(
Expand Down Expand Up @@ -257,15 +262,15 @@ fun FlowPage(
state = listState,
) {
item {
DisplayText(
modifier = Modifier.padding(start = if (articleListFeedIcon.value) 30.dp else 0.dp),
text = when {
filterUiState.group != null -> filterUiState.group.name
filterUiState.feed != null -> filterUiState.feed.name
else -> filterUiState.filter.toName()
},
desc = if (isSyncing) stringResource(R.string.syncing) else "",
)
// DisplayText(
// modifier = Modifier.padding(start = if (articleListFeedIcon.value) 30.dp else 0.dp),
// text = when {
// filterUiState.group != null -> filterUiState.group.name
// filterUiState.feed != null -> filterUiState.feed.name
// else -> filterUiState.filter.toName()
// },
// desc = if (isSyncing) stringResource(R.string.syncing) else "",
// )
RYExtensibleVisibility(visible = markAsRead) {
Spacer(modifier = Modifier.height((56 + 24 + 10).dp))
}
Expand Down

0 comments on commit bdfffee

Please sign in to comment.