Merge branch 'caption-text-refactoring' into 'master'

✂️ refactor caption text sytling into composable

See merge request fdroid/fdroidclient!1321
This commit is contained in:
Torsten Grote
2023-11-28 13:09:40 +00:00
2 changed files with 12 additions and 15 deletions

View File

@@ -143,9 +143,14 @@ object ComposeUtils {
}
/**
* reuse-able Modifier for making all captions in settings (and other places?) look the same
* Composable that mimics MDC TextView with `@style/CaptionText`
*/
fun Modifier.captionModifier() = this.then(
Modifier.padding(0.dp, 16.dp, 0.dp, 4.dp)
)
@Composable
fun CaptionText(text: String) {
Text(
text = text,
style = MaterialTheme.typography.caption,
modifier = Modifier.padding(0.dp, 16.dp, 0.dp, 4.dp)
)
}
}

View File

@@ -44,9 +44,9 @@ import androidx.lifecycle.Lifecycle
import org.fdroid.fdroid.IPreferencesIpfs
import org.fdroid.fdroid.Preferences
import org.fdroid.fdroid.R
import org.fdroid.fdroid.compose.ComposeUtils
import org.fdroid.fdroid.compose.ComposeUtils.FDroidContent
import org.fdroid.fdroid.compose.ComposeUtils.LifecycleEventListener
import org.fdroid.fdroid.compose.ComposeUtils.captionModifier
class IpfsGatewaySettingsActivity : ComponentActivity() {
@@ -139,11 +139,7 @@ fun DefaultGatewaysSettings(
var disabledDefaultGateways by remember { mutableStateOf(prefs.ipfsGwDisabledDefaults) }
Column {
Text(
text = stringResource(id = R.string.ipfsgw_caption_official_gateways),
style = MaterialTheme.typography.caption,
modifier = Modifier.captionModifier()
)
ComposeUtils.CaptionText(text = stringResource(id = R.string.ipfsgw_caption_official_gateways))
for (gatewayUrl in Preferences.DEFAULT_IPFS_GATEWAYS) {
Row(
modifier = Modifier
@@ -195,11 +191,7 @@ fun UserGatewaysSettings(
Column {
if (userGateways.isNotEmpty()) {
Text(
text = stringResource(id = R.string.ipfsgw_caption_custom_gateways),
style = MaterialTheme.typography.caption,
modifier = Modifier.captionModifier()
)
ComposeUtils.CaptionText(text = stringResource(id = R.string.ipfsgw_caption_custom_gateways))
}
for (gatewayUrl in userGateways) {
Row(