Skip to content

Commit 07046ce

Browse files
Fix(Settings): Adjust font sizes for consistency
This commit refactors the font sizes across various composables in the settings UI to improve visual consistency. - Default font sizes for titles and descriptions have been reduced in several composables (`SettingsItem`, `TopMainHeader`, `TitleWithHtmlLink`, `TitleWithHtmlLinks`, `PageHeader`, `SwitchWithLabel`). - The `fontSizeSp` parameter in `SettingsItem` has been renamed to `titleFontSize` and its type changed to `TextUnit` to align with other composables. - Font size parameters (`titleFontSize`, `descriptionFontSize`) are now passed down from `SettingsFragment` to the relevant composables, ensuring a consistent look and feel.
1 parent c0f1d1d commit 07046ce

File tree

2 files changed

+33
-22
lines changed

2 files changed

+33
-22
lines changed

app/src/main/java/com/github/droidworksstudio/mlauncher/ui/SettingsFragment.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ class SettingsFragment : BaseFragment() {
362362
TopMainHeader(
363363
iconRes = R.drawable.app_launcher,
364364
title = getLocalizedString(R.string.settings_name),
365+
titleFontSize = titleFontSize,
366+
descriptionFontSize = descriptionFontSize,
365367
onIconClick = {
366368
dialogBuilder.showDeviceStatsBottomSheet(
367369
context = context,
@@ -2593,6 +2595,7 @@ class SettingsFragment : BaseFragment() {
25932595
PageHeader(
25942596
iconRes = R.drawable.ic_back,
25952597
title = getLocalizedString(R.string.about_settings_title, getLocalizedString(R.string.app_name)),
2598+
25962599
onClick = {
25972600
currentScreen = "main"
25982601
}
@@ -2603,14 +2606,18 @@ class SettingsFragment : BaseFragment() {
26032606
TopMainHeader(
26042607
iconRes = R.drawable.app_launcher,
26052608
title = getLocalizedString(R.string.app_name),
2606-
description = getLocalizedString(R.string.created_by)
2609+
description = getLocalizedString(R.string.created_by),
2610+
titleFontSize = titleFontSize,
2611+
descriptionFontSize = descriptionFontSize
26072612
)
26082613

26092614
Spacer(modifier = Modifier.height(16.dp))
26102615

26112616
TitleWithHtmlLink(
26122617
title = getLocalizedString(R.string.settings_source_code),
26132618
description = getLocalizedString(R.string.github_link),
2619+
titleFontSize = titleFontSize,
2620+
descriptionFontSize = descriptionFontSize
26142621
)
26152622

26162623
Spacer(modifier = Modifier.height(16.dp))
@@ -2621,7 +2628,9 @@ class SettingsFragment : BaseFragment() {
26212628
getLocalizedString(R.string.sponsor_link),
26222629
getLocalizedString(R.string.coffee_link),
26232630
getLocalizedString(R.string.libera_link)
2624-
)
2631+
),
2632+
titleFontSize = titleFontSize,
2633+
descriptionFontSize = descriptionFontSize
26252634
)
26262635

26272636
Spacer(modifier = Modifier.weight(1f))
@@ -2632,6 +2641,8 @@ class SettingsFragment : BaseFragment() {
26322641
getLocalizedString(R.string.weather_link),
26332642
getLocalizedString(R.string.forked_link),
26342643
),
2644+
titleFontSize = titleFontSize,
2645+
descriptionFontSize = descriptionFontSize,
26352646
columns = true
26362647
)
26372648

app/src/main/java/com/github/droidworksstudio/mlauncher/ui/compose/SettingsComposable.kt

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ object SettingsComposable {
5656
onClick: () -> Unit = {},
5757
iconSize: Dp = 24.dp,
5858
fontColor: Color = SettingsTheme.typography.title.color,
59-
fontSizeSp: Float = 24f
59+
titleFontSize: TextUnit = TextUnit.Unspecified
6060
) {
6161
Row(
6262
modifier = Modifier
@@ -81,7 +81,7 @@ object SettingsComposable {
8181
text = title
8282
setTextSize(
8383
TypedValue.COMPLEX_UNIT_SP,
84-
fontSizeSp
84+
if (titleFontSize != TextUnit.Unspecified) titleFontSize.value else 18f
8585
)
8686
setTextColor(fontColor.toArgb()) // Optional
8787
}
@@ -99,8 +99,8 @@ object SettingsComposable {
9999
title: String,
100100
description: String? = null,
101101
iconSize: Dp = 96.dp,
102-
titleFontSize: TextUnit = 24.sp,
103-
descriptionFontSize: TextUnit = 14.sp,
102+
titleFontSize: TextUnit = TextUnit.Unspecified,
103+
descriptionFontSize: TextUnit = TextUnit.Unspecified,
104104
fontColor: Color = SettingsTheme.typography.title.color,
105105
onIconClick: (() -> Unit)? = null // Optional click callback
106106
) {
@@ -127,7 +127,7 @@ object SettingsComposable {
127127
text = title
128128
setTextSize(
129129
TypedValue.COMPLEX_UNIT_SP,
130-
if (titleFontSize != TextUnit.Unspecified) titleFontSize.value else 24f
130+
if (titleFontSize != TextUnit.Unspecified) titleFontSize.value else 18f
131131
)
132132
setTextColor(fontColor.toArgb())
133133
setPadding(0, 0, 0, 24)
@@ -145,7 +145,7 @@ object SettingsComposable {
145145
setTextColor(fontColor.toArgb())
146146
setTextSize(
147147
TypedValue.COMPLEX_UNIT_SP,
148-
if (descriptionFontSize != TextUnit.Unspecified) descriptionFontSize.value else 14f
148+
if (descriptionFontSize != TextUnit.Unspecified) descriptionFontSize.value else 12f
149149
)
150150
movementMethod = LinkMovementMethod.getInstance()
151151
}
@@ -228,7 +228,7 @@ object SettingsComposable {
228228
setTextColor(fontColor.toArgb())
229229
setTextSize(
230230
TypedValue.COMPLEX_UNIT_SP,
231-
if (titleFontSize != TextUnit.Unspecified) titleFontSize.value else 16f
231+
if (titleFontSize != TextUnit.Unspecified) titleFontSize.value else 18f
232232
)
233233
}
234234
},
@@ -244,7 +244,7 @@ object SettingsComposable {
244244
setTextColor(fontColor.toArgb())
245245
setTextSize(
246246
TypedValue.COMPLEX_UNIT_SP,
247-
if (descriptionFontSize != TextUnit.Unspecified) descriptionFontSize.value else 14f
247+
if (descriptionFontSize != TextUnit.Unspecified) descriptionFontSize.value else 12f
248248
)
249249
}
250250
},
@@ -259,8 +259,8 @@ object SettingsComposable {
259259
fun TitleWithHtmlLink(
260260
title: String,
261261
description: String? = null,
262-
titleFontSize: TextUnit = 24.sp,
263-
descriptionFontSize: TextUnit = 18.sp,
262+
titleFontSize: TextUnit = TextUnit.Unspecified,
263+
descriptionFontSize: TextUnit = TextUnit.Unspecified,
264264
titleColor: Color = SettingsTheme.typography.title.color,
265265
descriptionColor: Color = SettingsTheme.typography.title.color
266266
) {
@@ -277,7 +277,7 @@ object SettingsComposable {
277277
setTextColor(titleColor.toArgb())
278278
setTextSize(
279279
TypedValue.COMPLEX_UNIT_SP,
280-
if (titleFontSize != TextUnit.Unspecified) titleFontSize.value else 24f
280+
if (titleFontSize != TextUnit.Unspecified) titleFontSize.value else 18f
281281
)
282282
movementMethod = LinkMovementMethod.getInstance()
283283
}
@@ -294,7 +294,7 @@ object SettingsComposable {
294294
setTextColor(descriptionColor.toArgb())
295295
setTextSize(
296296
TypedValue.COMPLEX_UNIT_SP,
297-
if (descriptionFontSize != TextUnit.Unspecified) descriptionFontSize.value else 14f
297+
if (descriptionFontSize != TextUnit.Unspecified) descriptionFontSize.value else 12f
298298
)
299299
movementMethod = LinkMovementMethod.getInstance()
300300
}
@@ -309,8 +309,8 @@ object SettingsComposable {
309309
fun TitleWithHtmlLinks(
310310
title: String,
311311
descriptions: List<String> = emptyList(),
312-
titleFontSize: TextUnit = 24.sp,
313-
descriptionFontSize: TextUnit = 18.sp,
312+
titleFontSize: TextUnit = TextUnit.Unspecified,
313+
descriptionFontSize: TextUnit = TextUnit.Unspecified,
314314
titleColor: Color = SettingsTheme.typography.title.color,
315315
descriptionColor: Color = SettingsTheme.typography.title.color,
316316
columns: Boolean = false // if true, use Column for links
@@ -329,15 +329,15 @@ object SettingsComposable {
329329
setTextColor(titleColor.toArgb())
330330
setTextSize(
331331
TypedValue.COMPLEX_UNIT_SP,
332-
if (titleFontSize != TextUnit.Unspecified) titleFontSize.value else 24f
332+
if (titleFontSize != TextUnit.Unspecified) titleFontSize.value else 18f
333333
)
334334
}
335335
},
336336
modifier = Modifier.wrapContentHeight()
337337
)
338338

339339
if (descriptions.isNotEmpty()) {
340-
Spacer(modifier = Modifier.height(4.dp))
340+
// Spacer(modifier = Modifier.height(4.dp))
341341

342342
if (columns) {
343343
// Use Column layout for links
@@ -352,7 +352,7 @@ object SettingsComposable {
352352
setTextColor(descriptionColor.toArgb())
353353
setTextSize(
354354
TypedValue.COMPLEX_UNIT_SP,
355-
if (descriptionFontSize != TextUnit.Unspecified) descriptionFontSize.value else 14f
355+
if (descriptionFontSize != TextUnit.Unspecified) descriptionFontSize.value else 12f
356356
)
357357
movementMethod = LinkMovementMethod.getInstance()
358358
}
@@ -378,7 +378,7 @@ object SettingsComposable {
378378
setTextColor(descriptionColor.toArgb())
379379
setTextSize(
380380
TypedValue.COMPLEX_UNIT_SP,
381-
if (descriptionFontSize != TextUnit.Unspecified) descriptionFontSize.value else 14f
381+
if (descriptionFontSize != TextUnit.Unspecified) descriptionFontSize.value else 12f
382382
)
383383
movementMethod = LinkMovementMethod.getInstance()
384384
}
@@ -401,7 +401,7 @@ object SettingsComposable {
401401
fontSize: TextUnit = TextUnit.Unspecified,
402402
onClick: () -> Unit = {}
403403
) {
404-
val resolvedFontSizeSp = if (fontSize != TextUnit.Unspecified) fontSize.value else 20f
404+
val resolvedFontSizeSp = if (fontSize != TextUnit.Unspecified) fontSize.value else 18f
405405
val fontColor = SettingsTheme.typography.header.color
406406

407407
AndroidView(
@@ -439,7 +439,7 @@ object SettingsComposable {
439439
var isChecked by remember { mutableStateOf(defaultState) }
440440

441441
// Extract font size and color from theme safely in composable scope
442-
val resolvedFontSizeSp = if (fontSize != TextUnit.Unspecified) fontSize.value else 16f
442+
val resolvedFontSizeSp = if (fontSize != TextUnit.Unspecified) fontSize.value else 14f
443443
val fontColor = SettingsTheme.typography.title.color
444444

445445
Row(

0 commit comments

Comments
 (0)