Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework fontsize, better defaults #1452

Merged
merged 4 commits into from Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/main/java/com/jerboa/Utils.kt
Expand Up @@ -1552,4 +1552,4 @@ fun Context.getVersionCode(): Int =
getPackageInfo().versionCode
}

fun Int.toBool() = if (this > 0) true else false
fun Int.toBool() = this > 0
Expand Up @@ -695,7 +695,7 @@ fun PostAndCommunityContextHeader(
) {
Text(
text = post.name,
style = MaterialTheme.typography.titleLarge,
style = MaterialTheme.typography.titleSmall,
modifier = Modifier.clickable { onPostClick(post.id) },
)
Row(
Expand Down
36 changes: 35 additions & 1 deletion app/src/main/java/com/jerboa/ui/components/common/AppBars.kt
Expand Up @@ -51,6 +51,7 @@ import androidx.compose.ui.unit.dp
import com.jerboa.R
import com.jerboa.datatypes.UserViewType
import com.jerboa.datatypes.VoteDisplayMode
import com.jerboa.datatypes.data
import com.jerboa.datatypes.samplePerson
import com.jerboa.datatypes.samplePost
import com.jerboa.db.entity.Account
Expand All @@ -63,6 +64,7 @@ import com.jerboa.siFormat
import com.jerboa.ui.components.home.NavTab
import com.jerboa.ui.components.person.PersonProfileLink
import com.jerboa.ui.theme.*
import it.vercruysse.lemmyapi.dto.SortType
import it.vercruysse.lemmyapi.v0x19.datatypes.CommunityModeratorView
import it.vercruysse.lemmyapi.v0x19.datatypes.Person
import it.vercruysse.lemmyapi.v0x19.datatypes.PersonId
Expand Down Expand Up @@ -562,7 +564,7 @@ fun Sidebar(
title?.also {
Text(
text = it,
style = MaterialTheme.typography.titleLarge,
style = MaterialTheme.typography.titleMedium,
)
}
TimeAgo(
Expand Down Expand Up @@ -811,3 +813,35 @@ fun ActionTopBar(
},
)
}

@Composable
fun DualHeaderTitle(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx for extracting this.

topText: String,
bottomText: String,
@SuppressLint("ModifierParameter") topModifier: Modifier = Modifier,
) {
Column {
Text(
text = topText,
maxLines = 1,
style = MaterialTheme.typography.titleSmall,
modifier = topModifier,
)
Text(
text = bottomText,
maxLines = 1,
style = MaterialTheme.typography.labelSmall,
)
}
}

@Composable
fun DualHeaderTitle(
topText: String,
selectedSortType: SortType,
@SuppressLint("ModifierParameter") topModifier: Modifier = Modifier,
) = DualHeaderTitle(
topText = topText,
bottomText = stringResource(selectedSortType.data.shortForm),
topModifier = topModifier,
)
Expand Up @@ -195,7 +195,7 @@ fun CreateLinkDialog(
) {
Text(
text = stringResource(R.string.input_fields_insert_link),
style = MaterialTheme.typography.titleLarge,
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.onSurface,
)
OutlinedTextField(
Expand Down
@@ -1,6 +1,5 @@
package com.jerboa.ui.components.community

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand Down Expand Up @@ -40,16 +39,15 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import com.jerboa.PostViewMode
import com.jerboa.R
import com.jerboa.datatypes.data
import com.jerboa.datatypes.sampleCommunityView
import com.jerboa.feat.BlurNSFW
import com.jerboa.feat.needBlur
import com.jerboa.ui.components.common.DualHeaderTitle
import com.jerboa.ui.components.common.LargerCircularIcon
import com.jerboa.ui.components.common.PictrsBannerImage
import com.jerboa.ui.components.common.SortOptionsDropdown
Expand Down Expand Up @@ -100,7 +98,7 @@ fun CommunityTopSection(
) {
Text(
text = communityView.community.title,
style = MaterialTheme.typography.titleLarge,
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.onSurface,
)
}
Expand Down Expand Up @@ -185,9 +183,10 @@ fun CommunityHeader(
TopAppBar(
scrollBehavior = scrollBehavior,
title = {
CommunityHeaderTitle(
communityName = communityName,
DualHeaderTitle(
topText = communityName,
selectedSortType = selectedSortType,
topModifier = Modifier.customMarquee(),
)
},
navigationIcon = {
Expand Down Expand Up @@ -245,27 +244,6 @@ fun CommunityHeader(
)
}

@OptIn(ExperimentalFoundationApi::class)
@Composable
fun CommunityHeaderTitle(
communityName: String,
selectedSortType: SortType,
) {
val ctx = LocalContext.current
Column {
Text(
text = communityName,
style = MaterialTheme.typography.titleLarge,
maxLines = 1,
modifier = Modifier.customMarquee(),
)
Text(
text = ctx.getString(selectedSortType.data.shortForm),
style = MaterialTheme.typography.titleMedium,
)
}
}

@Composable
fun CommunityMoreDropdown(
expanded: Boolean,
Expand Down
Expand Up @@ -135,7 +135,7 @@ fun CommunityLinkLarger(
CommunityLink(
community = community,
color = MaterialTheme.colorScheme.onSurface,
style = MaterialTheme.typography.titleLarge,
style = MaterialTheme.typography.titleMedium,
size = LINK_ICON_SIZE,
thumbnailSize = LARGER_ICON_THUMBNAIL_SIZE,
spacing = DRAWER_ITEM_SPACING,
Expand Down Expand Up @@ -169,7 +169,7 @@ fun CommunityLinkLargerWithUserCount(
Modifier
.padding(LARGE_PADDING)
.fillMaxWidth(),
style = MaterialTheme.typography.titleLarge,
style = MaterialTheme.typography.titleMedium,
onClick = onClick,
showDefaultIcon = showDefaultIcon,
blurNSFW = blurNSFW,
Expand Down
25 changes: 4 additions & 21 deletions app/src/main/java/com/jerboa/ui/components/home/Home.kt
Expand Up @@ -40,8 +40,8 @@ import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.compose.ui.tooling.preview.Preview
import com.jerboa.PostViewMode
import com.jerboa.R
import com.jerboa.datatypes.data
import com.jerboa.datatypes.getLocalizedListingTypeName
import com.jerboa.ui.components.common.DualHeaderTitle
import com.jerboa.ui.components.common.MenuItem
import com.jerboa.ui.components.common.MyMarkdownText
import com.jerboa.ui.components.common.SortOptionsDropdown
Expand All @@ -51,24 +51,6 @@ import it.vercruysse.lemmyapi.dto.SortType
import it.vercruysse.lemmyapi.v0x19.datatypes.Tagline
import me.saket.cascade.CascadeDropdownMenu

@Composable
fun HomeHeaderTitle(
selectedSortType: SortType,
selectedListingType: ListingType,
) {
val ctx = LocalContext.current
Column {
Text(
text = getLocalizedListingTypeName(ctx, selectedListingType),
style = MaterialTheme.typography.titleLarge,
)
Text(
text = ctx.getString(selectedSortType.data.shortForm),
style = MaterialTheme.typography.titleMedium,
)
}
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun HomeHeader(
Expand All @@ -83,16 +65,17 @@ fun HomeHeader(
onClickSiteInfo: () -> Unit,
scrollBehavior: TopAppBarScrollBehavior,
) {
val ctx = LocalContext.current
var showSortOptions by remember { mutableStateOf(false) }
var showListingTypeOptions by remember { mutableStateOf(false) }
var showMoreOptions by remember { mutableStateOf(false) }

TopAppBar(
scrollBehavior = scrollBehavior,
title = {
HomeHeaderTitle(
DualHeaderTitle(
selectedSortType = selectedSortType,
selectedListingType = selectedListingType,
topText = getLocalizedListingTypeName(ctx, selectedListingType),
)
},
navigationIcon = {
Expand Down
20 changes: 5 additions & 15 deletions app/src/main/java/com/jerboa/ui/components/inbox/Inbox.kt
@@ -1,16 +1,13 @@
package com.jerboa.ui.components.inbox

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.DoneAll
import androidx.compose.material.icons.outlined.FilterList
import androidx.compose.material.icons.outlined.Menu
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarScrollBehavior
import androidx.compose.runtime.Composable
Expand All @@ -23,6 +20,7 @@ import androidx.compose.ui.res.stringResource
import com.jerboa.R
import com.jerboa.UnreadOrAll
import com.jerboa.datatypes.getLocalizedUnreadOrAllName
import com.jerboa.ui.components.common.DualHeaderTitle
import com.jerboa.ui.components.common.UnreadOrAllOptionsDropDown

@OptIn(ExperimentalMaterial3Api::class)
Expand Down Expand Up @@ -90,19 +88,11 @@ fun InboxHeaderTitle(
selectedUnreadOrAll: UnreadOrAll,
unreadCount: Long? = null,
) {
var title = stringResource(R.string.inbox_inbox)
val ctx = LocalContext.current
var title = stringResource(R.string.inbox_inbox)

if (unreadCount != null && unreadCount > 0) {
title = "$title ($unreadCount)"
}
Column {
Text(
text = title,
style = MaterialTheme.typography.titleLarge,
)
Text(
text = getLocalizedUnreadOrAllName(ctx, selectedUnreadOrAll),
style = MaterialTheme.typography.titleMedium,
)
title += " ($unreadCount)"
}
DualHeaderTitle(topText = title, bottomText = getLocalizedUnreadOrAllName(ctx, selectedUnreadOrAll))
}
Expand Up @@ -41,10 +41,10 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import com.jerboa.R
import com.jerboa.datatypes.data
import com.jerboa.datatypes.samplePersonView
import com.jerboa.feat.openMatrix
import com.jerboa.ui.components.common.DotSpacer
import com.jerboa.ui.components.common.DualHeaderTitle
import com.jerboa.ui.components.common.LargerCircularIcon
import com.jerboa.ui.components.common.MenuItem
import com.jerboa.ui.components.common.MyMarkdownText
Expand Down Expand Up @@ -103,7 +103,7 @@ fun PersonProfileTopSection(
) {
PersonName(
person = personView.person,
style = MaterialTheme.typography.titleLarge,
style = MaterialTheme.typography.titleMedium,
)

TimeAgo(
Expand Down Expand Up @@ -181,8 +181,8 @@ fun PersonProfileHeader(
TopAppBar(
scrollBehavior = scrollBehavior,
title = {
PersonProfileHeaderTitle(
personName = personName,
DualHeaderTitle(
topText = personName,
selectedSortType = selectedSortType,
)
},
Expand Down Expand Up @@ -270,23 +270,6 @@ fun PersonProfileHeader(
)
}

@Composable
fun PersonProfileHeaderTitle(
personName: String,
selectedSortType: SortType,
) {
Column {
Text(
text = personName,
style = MaterialTheme.typography.titleLarge,
)
Text(
text = LocalContext.current.getString(selectedSortType.data.shortForm),
style = MaterialTheme.typography.titleMedium,
)
}
}

@Composable
fun PersonProfileMoreDropdown(
personName: String,
Expand Down
23 changes: 4 additions & 19 deletions app/src/main/java/com/jerboa/ui/components/post/PostActivity.kt
Expand Up @@ -20,10 +20,8 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.rememberTopAppBarState
Expand Down Expand Up @@ -83,6 +81,7 @@ import com.jerboa.ui.components.comment.reply.CommentReplyReturn
import com.jerboa.ui.components.common.ApiErrorText
import com.jerboa.ui.components.common.CommentNavigationBottomAppBar
import com.jerboa.ui.components.common.CommentSortOptionsDropdown
import com.jerboa.ui.components.common.DualHeaderTitle
import com.jerboa.ui.components.common.JerboaPullRefreshIndicator
import com.jerboa.ui.components.common.JerboaSnackbarHost
import com.jerboa.ui.components.common.LoadingBar
Expand Down Expand Up @@ -115,21 +114,6 @@ object PostViewReturn {
const val POST_VIEW = "post-view::return(post-view)"
}

@Composable
fun CommentsHeaderTitle(selectedSortType: CommentSortType) {
val ctx = LocalContext.current
Column {
Text(
text = stringResource(R.string.post_activity_comments),
style = MaterialTheme.typography.titleLarge,
)
Text(
text = getLocalizedCommentSortTypeName(ctx, selectedSortType),
style = MaterialTheme.typography.titleMedium,
)
}
}

@OptIn(
ExperimentalMaterial3Api::class,
ExperimentalComposeUiApi::class,
Expand Down Expand Up @@ -246,8 +230,9 @@ fun PostActivity(
Column {
TopAppBar(
title = {
CommentsHeaderTitle(
selectedSortType = selectedSortType,
DualHeaderTitle(
topText = stringResource(R.string.post_activity_comments),
bottomText = getLocalizedCommentSortTypeName(ctx, selectedSortType),
)
},
navigationIcon = {
Expand Down