From fb4dec2b51c215c1967777daa4203ab176601d07 Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Mon, 3 Mar 2025 14:44:55 +0530 Subject: [PATCH] Created the Typography file to manage the Material design guidelines for our textView --- .../kiwix/kiwixmobile/core/ui/theme/Shape.kt | 20 ++++--- .../kiwix/kiwixmobile/core/ui/theme/Theme.kt | 3 +- .../kiwixmobile/core/ui/theme/Typography.kt | 55 +++++++++++++++++++ .../kiwixmobile/core/utils/ComposeDimens.kt | 23 ++++++-- 4 files changed, 88 insertions(+), 13 deletions(-) create mode 100644 core/src/main/java/org/kiwix/kiwixmobile/core/ui/theme/Typography.kt diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/ui/theme/Shape.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/ui/theme/Shape.kt index 470ee6ab6..ba3566057 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/ui/theme/Shape.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/ui/theme/Shape.kt @@ -21,18 +21,22 @@ package org.kiwix.kiwixmobile.core.ui.theme import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Shapes import androidx.compose.ui.unit.dp +import org.kiwix.kiwixmobile.core.utils.ComposeDimens.EXTRA_LARGE_ROUND_SHAPE_SIZE +import org.kiwix.kiwixmobile.core.utils.ComposeDimens.EXTRA_SMALL_ROUND_SHAPE_SIZE +import org.kiwix.kiwixmobile.core.utils.ComposeDimens.LARGE_ROUND_SHAPE_SIZE +import org.kiwix.kiwixmobile.core.utils.ComposeDimens.MEDIUM_ROUND_SHAPE_SIZE +import org.kiwix.kiwixmobile.core.utils.ComposeDimens.SMALL_ROUND_SHAPE_SIZE /** - * Most of the shares we are using in round corners. - * So we are defining the shapes here so that we can directly use these - * shapes in our code from Material theme. + * Defines the shape styles used throughout the app, primarily with rounded corners. + * These shapes are applied consistently via the Material theme to ensure uniformity. * * @see KiwixTheme */ val shapes = Shapes( - extraSmall = RoundedCornerShape(4.dp), - small = RoundedCornerShape(8.dp), - medium = RoundedCornerShape(16.dp), - large = RoundedCornerShape(24.dp), - extraLarge = RoundedCornerShape(32.dp) + extraSmall = RoundedCornerShape(EXTRA_SMALL_ROUND_SHAPE_SIZE), + small = RoundedCornerShape(SMALL_ROUND_SHAPE_SIZE), + medium = RoundedCornerShape(MEDIUM_ROUND_SHAPE_SIZE), + large = RoundedCornerShape(LARGE_ROUND_SHAPE_SIZE), + extraLarge = RoundedCornerShape(EXTRA_LARGE_ROUND_SHAPE_SIZE) ) diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/ui/theme/Theme.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/ui/theme/Theme.kt index a2ec42528..a1d18d025 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/ui/theme/Theme.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/ui/theme/Theme.kt @@ -63,6 +63,7 @@ fun KiwixTheme( MaterialTheme( colorScheme = colorScheme, content = content, - shapes = shapes + shapes = shapes, + typography = KiwixTypography ) } diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/ui/theme/Typography.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/ui/theme/Typography.kt new file mode 100644 index 000000000..71c0f26b6 --- /dev/null +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/ui/theme/Typography.kt @@ -0,0 +1,55 @@ +/* + * Kiwix Android + * Copyright (c) 2025 Kiwix + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +package org.kiwix.kiwixmobile.core.ui.theme + +import androidx.compose.material3.Typography +import androidx.compose.ui.text.TextStyle +import org.kiwix.kiwixmobile.core.utils.ComposeDimens.LARGE_BODY_TEXT_SIZE +import org.kiwix.kiwixmobile.core.utils.ComposeDimens.LARGE_HEADLINE_TEXT_SIZE +import org.kiwix.kiwixmobile.core.utils.ComposeDimens.LARGE_LABEL_TEXT_SIZE +import org.kiwix.kiwixmobile.core.utils.ComposeDimens.LARGE_TITLE_TEXT_SIZE +import org.kiwix.kiwixmobile.core.utils.ComposeDimens.MEDIUM_BODY_TEXT_SIZE +import org.kiwix.kiwixmobile.core.utils.ComposeDimens.MEDIUM_HEADLINE_TEXT_SIZE +import org.kiwix.kiwixmobile.core.utils.ComposeDimens.MEDIUM_LABEL_TEXT_SIZE +import org.kiwix.kiwixmobile.core.utils.ComposeDimens.MEDIUM_TITLE_TEXT_SIZE +import org.kiwix.kiwixmobile.core.utils.ComposeDimens.SMALL_BODY_TEXT_SIZE +import org.kiwix.kiwixmobile.core.utils.ComposeDimens.SMALL_HEADLINE_TEXT_SIZE +import org.kiwix.kiwixmobile.core.utils.ComposeDimens.SMALL_LABEL_TEXT_SIZE +import org.kiwix.kiwixmobile.core.utils.ComposeDimens.SMALL_TITLE_TEXT_SIZE + +/** + * Defines the typography styles used throughout the app. + * These text styles follow Material Design guidelines and ensure consistency in font sizes. + * + * @see KiwixTheme + */ +val KiwixTypography = Typography( + headlineLarge = TextStyle(fontSize = LARGE_HEADLINE_TEXT_SIZE), + headlineMedium = TextStyle(fontSize = MEDIUM_HEADLINE_TEXT_SIZE), + headlineSmall = TextStyle(fontSize = SMALL_HEADLINE_TEXT_SIZE), + titleLarge = TextStyle(fontSize = LARGE_TITLE_TEXT_SIZE), + titleMedium = TextStyle(fontSize = MEDIUM_TITLE_TEXT_SIZE), + titleSmall = TextStyle(fontSize = SMALL_TITLE_TEXT_SIZE), + bodyLarge = TextStyle(fontSize = LARGE_BODY_TEXT_SIZE), + bodyMedium = TextStyle(fontSize = MEDIUM_BODY_TEXT_SIZE), + bodySmall = TextStyle(fontSize = SMALL_BODY_TEXT_SIZE), + labelLarge = TextStyle(fontSize = LARGE_LABEL_TEXT_SIZE), + labelMedium = TextStyle(fontSize = MEDIUM_LABEL_TEXT_SIZE), + labelSmall = TextStyle(fontSize = SMALL_LABEL_TEXT_SIZE), +) diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/ComposeDimens.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/ComposeDimens.kt index 4e739e667..8925743f7 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/ComposeDimens.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/ComposeDimens.kt @@ -56,8 +56,23 @@ object ComposeDimens { val DEFAULT_LETTER_SPACING = 0.0333.em // Shape configuration sizes. See Shape.kt - val EXTRA_SMALL = 4.dp - val SMALL = 8.dp - val MEDIUM = 16.dp - val LARGE = 16.dp + val EXTRA_SMALL_ROUND_SHAPE_SIZE = 4.dp + val SMALL_ROUND_SHAPE_SIZE = 8.dp + val MEDIUM_ROUND_SHAPE_SIZE = 16.dp + val LARGE_ROUND_SHAPE_SIZE = 24.dp + val EXTRA_LARGE_ROUND_SHAPE_SIZE = 32.dp + + // Typography configuration sizes. See Typography.kt + val LARGE_HEADLINE_TEXT_SIZE = 32.sp + val MEDIUM_HEADLINE_TEXT_SIZE = 28.sp + val SMALL_HEADLINE_TEXT_SIZE = 24.sp + val LARGE_TITLE_TEXT_SIZE = 22.sp + val MEDIUM_TITLE_TEXT_SIZE = 18.sp + val SMALL_TITLE_TEXT_SIZE = 16.sp + val LARGE_BODY_TEXT_SIZE = 16.sp + val MEDIUM_BODY_TEXT_SIZE = 14.sp + val SMALL_BODY_TEXT_SIZE = 12.sp + val LARGE_LABEL_TEXT_SIZE = 14.sp + val MEDIUM_LABEL_TEXT_SIZE = 12.sp + val SMALL_LABEL_TEXT_SIZE = 10.sp }