diff --git a/docs/tech_manual/module_structure.md b/docs/tech_manual/module_structure.md index 440e7f0b7..098f43cbb 100644 --- a/docs/tech_manual/module_structure.md +++ b/docs/tech_manual/module_structure.md @@ -81,7 +81,6 @@ Here is a list of the main unit modules and their purpose: - `:unit:ban` contains the modal bottom sheet used to ban a user from a community - `:unit:chat` contains the chat conversation screen - `:unit:choosecolor` contains the dialogs and bottom sheets used for theme/color selection -- `:unit:choosefont` contains the bottom sheets used for font selection - `:unit:communitydetail` contains the community detail screen - `:unit:communityinfo` contains the community info bottom sheet accessible from community detail - `:unit:configureswipeactions` contains the screen and bottom sheets to configure swipe actions diff --git a/feature/settings/build.gradle.kts b/feature/settings/build.gradle.kts index 9c75c08ca..f3eb41aa5 100644 --- a/feature/settings/build.gradle.kts +++ b/feature/settings/build.gradle.kts @@ -66,7 +66,6 @@ kotlin { implementation(projects.unit.accountsettings) implementation(projects.unit.manageban) implementation(projects.unit.choosecolor) - implementation(projects.unit.choosefont) implementation(projects.unit.configureswipeactions) implementation(projects.unit.configurenavbar) implementation(projects.unit.configurecontentview) diff --git a/iosApp/iosApp.xcodeproj/project.pbxproj b/iosApp/iosApp.xcodeproj/project.pbxproj index df17f8f22..f1460880a 100644 --- a/iosApp/iosApp.xcodeproj/project.pbxproj +++ b/iosApp/iosApp.xcodeproj/project.pbxproj @@ -247,7 +247,6 @@ "$(SRCROOT)/../unit/ban/build/fat-framework/debug", "$(SRCROOT)/../unit/chat/build/fat-framework/debug", "$(SRCROOT)/../unit/choosecolor/build/fat-framework/debug", - "$(SRCROOT)/../unit/choosefont/build/fat-framework/debug", "$(SRCROOT)/../unit/communitydetail/build/fat-framework/debug", "$(SRCROOT)/../unit/communityinfo/build/fat-framework/debug", "$(SRCROOT)/../unit/configurecontentview/build/fat-framework/debug", @@ -385,7 +384,6 @@ "$(SRCROOT)/../unit/ban/build/fat-framework/release", "$(SRCROOT)/../unit/chat/build/fat-framework/release", "$(SRCROOT)/../unit/choosecolor/build/fat-framework/release", - "$(SRCROOT)/../unit/choosefont/build/fat-framework/release", "$(SRCROOT)/../unit/communitydetail/build/fat-framework/release", "$(SRCROOT)/../unit/communityinfo/build/fat-framework/release", "$(SRCROOT)/../unit/configurecontentview/build/fat-framework/release", diff --git a/settings.gradle.kts b/settings.gradle.kts index f67f53848..919311d63 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -57,7 +57,6 @@ include(":unit:accountsettings") include(":unit:ban") include(":unit:chat") include(":unit:choosecolor") -include(":unit:choosefont") include(":unit:communitydetail") include(":unit:communityinfo") include(":unit:configurecontentview") diff --git a/unit/choosefont/build.gradle.kts b/unit/choosefont/build.gradle.kts deleted file mode 100644 index 512ca5a25..000000000 --- a/unit/choosefont/build.gradle.kts +++ /dev/null @@ -1,64 +0,0 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget - -plugins { - alias(libs.plugins.kotlin.multiplatform) - alias(libs.plugins.android.library) - alias(libs.plugins.jetbrains.compose) - alias(libs.plugins.compose.compiler) - alias(libs.plugins.detekt) -} - -@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class) -kotlin { - applyDefaultHierarchyTemplate() - androidTarget { - compilerOptions { - jvmTarget.set(JvmTarget.JVM_1_8) - } - } - listOf( - iosX64(), - iosArm64(), - iosSimulatorArm64(), - ).forEach { - it.binaries.framework { - baseName = "unit.choosefont" - isStatic = true - } - } - - sourceSets { - val commonMain by getting { - dependencies { - implementation(compose.runtime) - implementation(compose.foundation) - implementation(compose.material) - implementation(compose.material3) - implementation(compose.materialIconsExtended) - - implementation(libs.voyager.navigator) - - implementation(projects.core.appearance) - implementation(projects.core.commonui.components) - implementation(projects.core.l10n) - implementation(projects.core.navigation) - implementation(projects.core.notifications) - implementation(projects.core.resources) - implementation(projects.core.utils) - } - } - val commonTest by getting { - dependencies { - implementation(kotlin("test")) - } - } - } -} - -android { - namespace = "com.livefast.eattrash.raccoonforlemmy.unit.choosefont" - compileSdk = libs.versions.android.targetSdk.get().toInt() - defaultConfig { - minSdk = libs.versions.android.minSdk.get().toInt() - } -} diff --git a/unit/choosefont/detekt-baseline.xml b/unit/choosefont/detekt-baseline.xml deleted file mode 100644 index 8c7b36f65..000000000 --- a/unit/choosefont/detekt-baseline.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - LongMethod:FontFamilyBottomSheet.kt$FontFamilyBottomSheet$@Composable override fun Content() - LongMethod:FontScaleBottomSheet.kt$FontScaleBottomSheet$@Composable override fun Content() - - diff --git a/unit/choosefont/src/commonMain/kotlin/com/livefast/eattrash/raccoonforlemmy/unit/choosefont/FontFamilyBottomSheet.kt b/unit/choosefont/src/commonMain/kotlin/com/livefast/eattrash/raccoonforlemmy/unit/choosefont/FontFamilyBottomSheet.kt deleted file mode 100644 index 583f4ed9a..000000000 --- a/unit/choosefont/src/commonMain/kotlin/com/livefast/eattrash/raccoonforlemmy/unit/choosefont/FontFamilyBottomSheet.kt +++ /dev/null @@ -1,107 +0,0 @@ -package com.livefast.eattrash.raccoonforlemmy.unit.choosefont - -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember -import androidx.compose.ui.Modifier -import androidx.compose.ui.text.font.FontFamily -import cafe.adriel.voyager.core.screen.Screen -import com.livefast.eattrash.raccoonforlemmy.core.appearance.data.UiFontFamily -import com.livefast.eattrash.raccoonforlemmy.core.appearance.data.toInt -import com.livefast.eattrash.raccoonforlemmy.core.appearance.data.toReadableName -import com.livefast.eattrash.raccoonforlemmy.core.appearance.data.toUiFontFamily -import com.livefast.eattrash.raccoonforlemmy.core.appearance.theme.Spacing -import com.livefast.eattrash.raccoonforlemmy.core.commonui.components.BottomSheetHeader -import com.livefast.eattrash.raccoonforlemmy.core.l10n.messages.LocalStrings -import com.livefast.eattrash.raccoonforlemmy.core.navigation.di.getNavigationCoordinator -import com.livefast.eattrash.raccoonforlemmy.core.notifications.NotificationCenterEvent -import com.livefast.eattrash.raccoonforlemmy.core.notifications.di.getNotificationCenter -import com.livefast.eattrash.raccoonforlemmy.core.resources.di.getCoreResources -import com.livefast.eattrash.raccoonforlemmy.core.utils.compose.onClick - -private val defaultChoices: List = - listOf( - UiFontFamily.Poppins, - UiFontFamily.NotoSans, - UiFontFamily.CharisSIL, - UiFontFamily.Default, - ).map { it.toInt() } - -class FontFamilyBottomSheet( - private val values: List = defaultChoices, - private val content: Boolean = false, -) : Screen { - @Composable - override fun Content() { - val navigationCoordinator = remember { getNavigationCoordinator() } - val notificationCenter = remember { getNotificationCenter() } - val coreResources = remember { getCoreResources() } - - Column( - modifier = - Modifier - .padding( - top = Spacing.s, - start = Spacing.s, - end = Spacing.s, - bottom = Spacing.m, - ), - verticalArrangement = Arrangement.spacedBy(Spacing.s), - ) { - BottomSheetHeader(LocalStrings.current.settingsUiFontFamily) - Column( - modifier = Modifier.fillMaxWidth().verticalScroll(rememberScrollState()), - verticalArrangement = Arrangement.spacedBy(Spacing.xxs), - ) { - for (value in values) { - val family = value.toUiFontFamily() - Row( - modifier = - Modifier - .padding( - horizontal = Spacing.s, - vertical = Spacing.s, - ) - .fillMaxWidth() - .onClick( - onClick = { - val event = - if (content) { - NotificationCenterEvent.ChangeContentFontFamily(family) - } else { - NotificationCenterEvent.ChangeFontFamily(family) - } - notificationCenter.send(event) - navigationCoordinator.hideBottomSheet() - }, - ), - ) { - val fontFamily = - when (family) { - UiFontFamily.NotoSans -> coreResources.notoSans - UiFontFamily.CharisSIL -> coreResources.charisSil - UiFontFamily.Poppins -> coreResources.poppins - else -> FontFamily.Default - } - Text( - text = family.toReadableName(), - style = - MaterialTheme.typography.bodyLarge.copy( - fontFamily = fontFamily, - ), - color = MaterialTheme.colorScheme.onBackground, - ) - } - } - } - } - } -} diff --git a/unit/choosefont/src/commonMain/kotlin/com/livefast/eattrash/raccoonforlemmy/unit/choosefont/FontScaleBottomSheet.kt b/unit/choosefont/src/commonMain/kotlin/com/livefast/eattrash/raccoonforlemmy/unit/choosefont/FontScaleBottomSheet.kt deleted file mode 100644 index ad1eba43d..000000000 --- a/unit/choosefont/src/commonMain/kotlin/com/livefast/eattrash/raccoonforlemmy/unit/choosefont/FontScaleBottomSheet.kt +++ /dev/null @@ -1,123 +0,0 @@ -package com.livefast.eattrash.raccoonforlemmy.unit.choosefont - -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember -import androidx.compose.ui.Modifier -import cafe.adriel.voyager.core.screen.Screen -import com.livefast.eattrash.raccoonforlemmy.core.appearance.data.FontScale -import com.livefast.eattrash.raccoonforlemmy.core.appearance.data.scaleFactor -import com.livefast.eattrash.raccoonforlemmy.core.appearance.data.toFontScale -import com.livefast.eattrash.raccoonforlemmy.core.appearance.data.toReadableName -import com.livefast.eattrash.raccoonforlemmy.core.appearance.repository.ContentFontClass -import com.livefast.eattrash.raccoonforlemmy.core.appearance.theme.Spacing -import com.livefast.eattrash.raccoonforlemmy.core.commonui.components.BottomSheetHeader -import com.livefast.eattrash.raccoonforlemmy.core.l10n.messages.LocalStrings -import com.livefast.eattrash.raccoonforlemmy.core.navigation.di.getNavigationCoordinator -import com.livefast.eattrash.raccoonforlemmy.core.notifications.NotificationCenterEvent -import com.livefast.eattrash.raccoonforlemmy.core.notifications.di.getNotificationCenter -import com.livefast.eattrash.raccoonforlemmy.core.utils.compose.onClick - -private val defaultChoices: List = - listOf( - FontScale.Largest, - FontScale.Larger, - FontScale.Large, - FontScale.Normal, - FontScale.Small, - FontScale.Smaller, - FontScale.Smallest, - ).map { it.scaleFactor } - -class FontScaleBottomSheet( - private val values: List = defaultChoices, - private val contentClass: ContentFontClass? = null, -) : Screen { - @Composable - override fun Content() { - val navigationCoordinator = remember { getNavigationCoordinator() } - val notificationCenter = remember { getNotificationCenter() } - Column( - modifier = - Modifier - .padding( - top = Spacing.s, - start = Spacing.s, - end = Spacing.s, - bottom = Spacing.m, - ), - verticalArrangement = Arrangement.spacedBy(Spacing.s), - ) { - val title = - when (contentClass) { - ContentFontClass.Title -> LocalStrings.current.settingsTitleFontScale - ContentFontClass.Body -> LocalStrings.current.settingsContentFontScale - ContentFontClass.Comment -> LocalStrings.current.settingsCommentFontScale - ContentFontClass.AncillaryText -> LocalStrings.current.settingsAncillaryFontScale - else -> LocalStrings.current.settingsUiFontScale - } - BottomSheetHeader(title) - Text( - modifier = - Modifier.padding( - start = Spacing.s, - top = Spacing.s, - end = Spacing.s, - ), - text = title, - style = MaterialTheme.typography.titleMedium, - color = MaterialTheme.colorScheme.onBackground, - ) - Column( - modifier = Modifier.fillMaxWidth().verticalScroll(rememberScrollState()), - verticalArrangement = Arrangement.spacedBy(Spacing.xxs), - ) { - for (value in values) { - val fontScale = value.toFontScale() - Row( - modifier = - Modifier - .padding( - horizontal = Spacing.s, - vertical = Spacing.s, - ) - .fillMaxWidth() - .onClick( - onClick = { - notificationCenter.send( - if (contentClass != null) { - NotificationCenterEvent.ChangeContentFontSize( - value = value, - contentClass = contentClass, - ) - } else { - NotificationCenterEvent.ChangeUiFontSize(value) - }, - ) - navigationCoordinator.hideBottomSheet() - }, - ), - ) { - val originalFontSize = MaterialTheme.typography.bodyLarge.fontSize - Text( - text = fontScale.toReadableName(), - style = - MaterialTheme.typography.bodyLarge.copy( - fontSize = originalFontSize * value, - ), - color = MaterialTheme.colorScheme.onBackground, - ) - } - } - } - } - } -} diff --git a/unit/configurecontentview/build.gradle.kts b/unit/configurecontentview/build.gradle.kts index b6bcb609a..c4258fd4f 100644 --- a/unit/configurecontentview/build.gradle.kts +++ b/unit/configurecontentview/build.gradle.kts @@ -55,8 +55,6 @@ kotlin { implementation(projects.domain.identity) implementation(projects.domain.lemmy.data) implementation(projects.domain.lemmy.repository) - - implementation(projects.unit.choosefont) } } val commonTest by getting { @@ -69,8 +67,14 @@ kotlin { android { namespace = "com.livefast.eattrash.raccoonforlemmy.unit.configurecontentview" - compileSdk = libs.versions.android.targetSdk.get().toInt() + compileSdk = + libs.versions.android.targetSdk + .get() + .toInt() defaultConfig { - minSdk = libs.versions.android.minSdk.get().toInt() + minSdk = + libs.versions.android.minSdk + .get() + .toInt() } } diff --git a/unit/configurecontentview/src/commonMain/kotlin/com/livefast/eattrash/raccoonforlemmy/unit/configurecontentview/ConfigureContentViewScreen.kt b/unit/configurecontentview/src/commonMain/kotlin/com/livefast/eattrash/raccoonforlemmy/unit/configurecontentview/ConfigureContentViewScreen.kt index 6dfda545d..b2bf3defa 100644 --- a/unit/configurecontentview/src/commonMain/kotlin/com/livefast/eattrash/raccoonforlemmy/unit/configurecontentview/ConfigureContentViewScreen.kt +++ b/unit/configurecontentview/src/commonMain/kotlin/com/livefast/eattrash/raccoonforlemmy/unit/configurecontentview/ConfigureContentViewScreen.kt @@ -34,10 +34,15 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.input.nestedscroll.nestedScroll import cafe.adriel.voyager.core.screen.Screen import cafe.adriel.voyager.koin.getScreenModel +import com.livefast.eattrash.raccoonforlemmy.core.appearance.data.FontScale import com.livefast.eattrash.raccoonforlemmy.core.appearance.data.PostLayout +import com.livefast.eattrash.raccoonforlemmy.core.appearance.data.UiFontFamily import com.livefast.eattrash.raccoonforlemmy.core.appearance.data.VoteFormat +import com.livefast.eattrash.raccoonforlemmy.core.appearance.data.scaleFactor import com.livefast.eattrash.raccoonforlemmy.core.appearance.data.toFontScale +import com.livefast.eattrash.raccoonforlemmy.core.appearance.data.toInt import com.livefast.eattrash.raccoonforlemmy.core.appearance.data.toReadableName +import com.livefast.eattrash.raccoonforlemmy.core.appearance.data.toUiFontFamily import com.livefast.eattrash.raccoonforlemmy.core.appearance.repository.ContentFontClass import com.livefast.eattrash.raccoonforlemmy.core.appearance.theme.Spacing import com.livefast.eattrash.raccoonforlemmy.core.commonui.lemmyui.SettingsHeader @@ -52,8 +57,6 @@ import com.livefast.eattrash.raccoonforlemmy.core.l10n.messages.LocalStrings import com.livefast.eattrash.raccoonforlemmy.core.navigation.di.getNavigationCoordinator import com.livefast.eattrash.raccoonforlemmy.core.notifications.NotificationCenterEvent import com.livefast.eattrash.raccoonforlemmy.core.notifications.di.getNotificationCenter -import com.livefast.eattrash.raccoonforlemmy.unit.choosefont.FontFamilyBottomSheet -import com.livefast.eattrash.raccoonforlemmy.unit.choosefont.FontScaleBottomSheet class ConfigureContentViewScreen : Screen { @OptIn(ExperimentalMaterial3Api::class) @@ -68,6 +71,8 @@ class ConfigureContentViewScreen : Screen { val scrollState = rememberScrollState() var voteFormatBottomSheetOpened by remember { mutableStateOf(false) } var postLayoutBottomSheetOpened by remember { mutableStateOf(false) } + var fontFamilyBottomSheetOpened by remember { mutableStateOf(false) } + var fontScaleClassBottomSheet by remember { mutableStateOf(null) } Scaffold( modifier = @@ -122,8 +127,7 @@ class ConfigureContentViewScreen : Screen { title = LocalStrings.current.settingsContentFontFamily, value = uiState.contentFontFamily.toReadableName(), onTap = { - val sheet = FontFamilyBottomSheet(content = true) - navigationCoordinator.showBottomSheet(sheet) + fontFamilyBottomSheetOpened = true }, ) @@ -135,8 +139,7 @@ class ConfigureContentViewScreen : Screen { .toFontScale() .toReadableName(), onTap = { - val sheet = FontScaleBottomSheet(contentClass = ContentFontClass.Title) - navigationCoordinator.showBottomSheet(sheet) + fontScaleClassBottomSheet = ContentFontClass.Title }, ) SettingsRow( @@ -146,8 +149,7 @@ class ConfigureContentViewScreen : Screen { .toFontScale() .toReadableName(), onTap = { - val sheet = FontScaleBottomSheet(contentClass = ContentFontClass.Body) - navigationCoordinator.showBottomSheet(sheet) + fontScaleClassBottomSheet = ContentFontClass.Body }, ) SettingsRow( @@ -157,9 +159,7 @@ class ConfigureContentViewScreen : Screen { .toFontScale() .toReadableName(), onTap = { - val sheet = - FontScaleBottomSheet(contentClass = ContentFontClass.Comment) - navigationCoordinator.showBottomSheet(sheet) + fontScaleClassBottomSheet = ContentFontClass.Comment }, ) SettingsRow( @@ -169,9 +169,7 @@ class ConfigureContentViewScreen : Screen { .toFontScale() .toReadableName(), onTap = { - val sheet = - FontScaleBottomSheet(contentClass = ContentFontClass.AncillaryText) - navigationCoordinator.showBottomSheet(sheet) + fontScaleClassBottomSheet = ContentFontClass.AncillaryText }, ) @@ -347,5 +345,65 @@ class ConfigureContentViewScreen : Screen { }, ) } + + if (fontFamilyBottomSheetOpened) { + val items = + listOf( + UiFontFamily.Poppins, + UiFontFamily.NotoSans, + UiFontFamily.CharisSIL, + UiFontFamily.Default, + ).map { it.toInt() } + CustomModalBottomSheet( + title = LocalStrings.current.settingsUiFontFamily, + items = + items.map { fontFamily -> + CustomModalBottomSheetItem( + label = fontFamily.toUiFontFamily().toReadableName(), + ) + }, + onSelected = { index -> + fontFamilyBottomSheetOpened = false + if (index != null) { + notificationCenter.send( + NotificationCenterEvent.ChangeContentFontFamily(items[index].toUiFontFamily()), + ) + } + }, + ) + } + + fontScaleClassBottomSheet?.also { contentClass -> + val items = + listOf( + FontScale.Largest, + FontScale.Larger, + FontScale.Large, + FontScale.Normal, + FontScale.Small, + FontScale.Smaller, + FontScale.Smallest, + ).map { it.scaleFactor } + CustomModalBottomSheet( + title = LocalStrings.current.settingsUiFontScale, + items = + items.map { font -> + CustomModalBottomSheetItem( + label = font.toFontScale().toReadableName(), + ) + }, + onSelected = { index -> + fontScaleClassBottomSheet = null + if (index != null) { + notificationCenter.send( + NotificationCenterEvent.ChangeContentFontSize( + value = items[index], + contentClass = contentClass, + ), + ) + } + }, + ) + } } }