mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-08 19:38:39 +01:00
refactor: remove :unit:choosefont dialogs (#63)
* remove :unit:choosefont module and all its dialogs * update usages in ConfigureContentViewScreen
This commit is contained in:
parent
75e39eeae8
commit
a8921b46da
@ -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:ban` contains the modal bottom sheet used to ban a user from a community
|
||||||
- `:unit:chat` contains the chat conversation screen
|
- `:unit:chat` contains the chat conversation screen
|
||||||
- `:unit:choosecolor` contains the dialogs and bottom sheets used for theme/color selection
|
- `: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:communitydetail` contains the community detail screen
|
||||||
- `:unit:communityinfo` contains the community info bottom sheet accessible from community detail
|
- `:unit:communityinfo` contains the community info bottom sheet accessible from community detail
|
||||||
- `:unit:configureswipeactions` contains the screen and bottom sheets to configure swipe actions
|
- `:unit:configureswipeactions` contains the screen and bottom sheets to configure swipe actions
|
||||||
|
@ -66,7 +66,6 @@ kotlin {
|
|||||||
implementation(projects.unit.accountsettings)
|
implementation(projects.unit.accountsettings)
|
||||||
implementation(projects.unit.manageban)
|
implementation(projects.unit.manageban)
|
||||||
implementation(projects.unit.choosecolor)
|
implementation(projects.unit.choosecolor)
|
||||||
implementation(projects.unit.choosefont)
|
|
||||||
implementation(projects.unit.configureswipeactions)
|
implementation(projects.unit.configureswipeactions)
|
||||||
implementation(projects.unit.configurenavbar)
|
implementation(projects.unit.configurenavbar)
|
||||||
implementation(projects.unit.configurecontentview)
|
implementation(projects.unit.configurecontentview)
|
||||||
|
@ -247,7 +247,6 @@
|
|||||||
"$(SRCROOT)/../unit/ban/build/fat-framework/debug",
|
"$(SRCROOT)/../unit/ban/build/fat-framework/debug",
|
||||||
"$(SRCROOT)/../unit/chat/build/fat-framework/debug",
|
"$(SRCROOT)/../unit/chat/build/fat-framework/debug",
|
||||||
"$(SRCROOT)/../unit/choosecolor/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/communitydetail/build/fat-framework/debug",
|
||||||
"$(SRCROOT)/../unit/communityinfo/build/fat-framework/debug",
|
"$(SRCROOT)/../unit/communityinfo/build/fat-framework/debug",
|
||||||
"$(SRCROOT)/../unit/configurecontentview/build/fat-framework/debug",
|
"$(SRCROOT)/../unit/configurecontentview/build/fat-framework/debug",
|
||||||
@ -385,7 +384,6 @@
|
|||||||
"$(SRCROOT)/../unit/ban/build/fat-framework/release",
|
"$(SRCROOT)/../unit/ban/build/fat-framework/release",
|
||||||
"$(SRCROOT)/../unit/chat/build/fat-framework/release",
|
"$(SRCROOT)/../unit/chat/build/fat-framework/release",
|
||||||
"$(SRCROOT)/../unit/choosecolor/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/communitydetail/build/fat-framework/release",
|
||||||
"$(SRCROOT)/../unit/communityinfo/build/fat-framework/release",
|
"$(SRCROOT)/../unit/communityinfo/build/fat-framework/release",
|
||||||
"$(SRCROOT)/../unit/configurecontentview/build/fat-framework/release",
|
"$(SRCROOT)/../unit/configurecontentview/build/fat-framework/release",
|
||||||
|
@ -57,7 +57,6 @@ include(":unit:accountsettings")
|
|||||||
include(":unit:ban")
|
include(":unit:ban")
|
||||||
include(":unit:chat")
|
include(":unit:chat")
|
||||||
include(":unit:choosecolor")
|
include(":unit:choosecolor")
|
||||||
include(":unit:choosefont")
|
|
||||||
include(":unit:communitydetail")
|
include(":unit:communitydetail")
|
||||||
include(":unit:communityinfo")
|
include(":unit:communityinfo")
|
||||||
include(":unit:configurecontentview")
|
include(":unit:configurecontentview")
|
||||||
|
@ -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()
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" ?>
|
|
||||||
<SmellBaseline>
|
|
||||||
<ManuallySuppressedIssues></ManuallySuppressedIssues>
|
|
||||||
<CurrentIssues>
|
|
||||||
<ID>LongMethod:FontFamilyBottomSheet.kt$FontFamilyBottomSheet$@Composable override fun Content()</ID>
|
|
||||||
<ID>LongMethod:FontScaleBottomSheet.kt$FontScaleBottomSheet$@Composable override fun Content()</ID>
|
|
||||||
</CurrentIssues>
|
|
||||||
</SmellBaseline>
|
|
@ -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<Int> =
|
|
||||||
listOf(
|
|
||||||
UiFontFamily.Poppins,
|
|
||||||
UiFontFamily.NotoSans,
|
|
||||||
UiFontFamily.CharisSIL,
|
|
||||||
UiFontFamily.Default,
|
|
||||||
).map { it.toInt() }
|
|
||||||
|
|
||||||
class FontFamilyBottomSheet(
|
|
||||||
private val values: List<Int> = 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,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<Float> =
|
|
||||||
listOf(
|
|
||||||
FontScale.Largest,
|
|
||||||
FontScale.Larger,
|
|
||||||
FontScale.Large,
|
|
||||||
FontScale.Normal,
|
|
||||||
FontScale.Small,
|
|
||||||
FontScale.Smaller,
|
|
||||||
FontScale.Smallest,
|
|
||||||
).map { it.scaleFactor }
|
|
||||||
|
|
||||||
class FontScaleBottomSheet(
|
|
||||||
private val values: List<Float> = 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,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -55,8 +55,6 @@ kotlin {
|
|||||||
implementation(projects.domain.identity)
|
implementation(projects.domain.identity)
|
||||||
implementation(projects.domain.lemmy.data)
|
implementation(projects.domain.lemmy.data)
|
||||||
implementation(projects.domain.lemmy.repository)
|
implementation(projects.domain.lemmy.repository)
|
||||||
|
|
||||||
implementation(projects.unit.choosefont)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val commonTest by getting {
|
val commonTest by getting {
|
||||||
@ -69,8 +67,14 @@ kotlin {
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "com.livefast.eattrash.raccoonforlemmy.unit.configurecontentview"
|
namespace = "com.livefast.eattrash.raccoonforlemmy.unit.configurecontentview"
|
||||||
compileSdk = libs.versions.android.targetSdk.get().toInt()
|
compileSdk =
|
||||||
|
libs.versions.android.targetSdk
|
||||||
|
.get()
|
||||||
|
.toInt()
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
minSdk =
|
||||||
|
libs.versions.android.minSdk
|
||||||
|
.get()
|
||||||
|
.toInt()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,10 +34,15 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import cafe.adriel.voyager.core.screen.Screen
|
import cafe.adriel.voyager.core.screen.Screen
|
||||||
import cafe.adriel.voyager.koin.getScreenModel
|
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.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.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.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.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.repository.ContentFontClass
|
||||||
import com.livefast.eattrash.raccoonforlemmy.core.appearance.theme.Spacing
|
import com.livefast.eattrash.raccoonforlemmy.core.appearance.theme.Spacing
|
||||||
import com.livefast.eattrash.raccoonforlemmy.core.commonui.lemmyui.SettingsHeader
|
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.navigation.di.getNavigationCoordinator
|
||||||
import com.livefast.eattrash.raccoonforlemmy.core.notifications.NotificationCenterEvent
|
import com.livefast.eattrash.raccoonforlemmy.core.notifications.NotificationCenterEvent
|
||||||
import com.livefast.eattrash.raccoonforlemmy.core.notifications.di.getNotificationCenter
|
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 {
|
class ConfigureContentViewScreen : Screen {
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@ -68,6 +71,8 @@ class ConfigureContentViewScreen : Screen {
|
|||||||
val scrollState = rememberScrollState()
|
val scrollState = rememberScrollState()
|
||||||
var voteFormatBottomSheetOpened by remember { mutableStateOf(false) }
|
var voteFormatBottomSheetOpened by remember { mutableStateOf(false) }
|
||||||
var postLayoutBottomSheetOpened by remember { mutableStateOf(false) }
|
var postLayoutBottomSheetOpened by remember { mutableStateOf(false) }
|
||||||
|
var fontFamilyBottomSheetOpened by remember { mutableStateOf(false) }
|
||||||
|
var fontScaleClassBottomSheet by remember { mutableStateOf<ContentFontClass?>(null) }
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
modifier =
|
modifier =
|
||||||
@ -122,8 +127,7 @@ class ConfigureContentViewScreen : Screen {
|
|||||||
title = LocalStrings.current.settingsContentFontFamily,
|
title = LocalStrings.current.settingsContentFontFamily,
|
||||||
value = uiState.contentFontFamily.toReadableName(),
|
value = uiState.contentFontFamily.toReadableName(),
|
||||||
onTap = {
|
onTap = {
|
||||||
val sheet = FontFamilyBottomSheet(content = true)
|
fontFamilyBottomSheetOpened = true
|
||||||
navigationCoordinator.showBottomSheet(sheet)
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -135,8 +139,7 @@ class ConfigureContentViewScreen : Screen {
|
|||||||
.toFontScale()
|
.toFontScale()
|
||||||
.toReadableName(),
|
.toReadableName(),
|
||||||
onTap = {
|
onTap = {
|
||||||
val sheet = FontScaleBottomSheet(contentClass = ContentFontClass.Title)
|
fontScaleClassBottomSheet = ContentFontClass.Title
|
||||||
navigationCoordinator.showBottomSheet(sheet)
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
@ -146,8 +149,7 @@ class ConfigureContentViewScreen : Screen {
|
|||||||
.toFontScale()
|
.toFontScale()
|
||||||
.toReadableName(),
|
.toReadableName(),
|
||||||
onTap = {
|
onTap = {
|
||||||
val sheet = FontScaleBottomSheet(contentClass = ContentFontClass.Body)
|
fontScaleClassBottomSheet = ContentFontClass.Body
|
||||||
navigationCoordinator.showBottomSheet(sheet)
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
@ -157,9 +159,7 @@ class ConfigureContentViewScreen : Screen {
|
|||||||
.toFontScale()
|
.toFontScale()
|
||||||
.toReadableName(),
|
.toReadableName(),
|
||||||
onTap = {
|
onTap = {
|
||||||
val sheet =
|
fontScaleClassBottomSheet = ContentFontClass.Comment
|
||||||
FontScaleBottomSheet(contentClass = ContentFontClass.Comment)
|
|
||||||
navigationCoordinator.showBottomSheet(sheet)
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
@ -169,9 +169,7 @@ class ConfigureContentViewScreen : Screen {
|
|||||||
.toFontScale()
|
.toFontScale()
|
||||||
.toReadableName(),
|
.toReadableName(),
|
||||||
onTap = {
|
onTap = {
|
||||||
val sheet =
|
fontScaleClassBottomSheet = ContentFontClass.AncillaryText
|
||||||
FontScaleBottomSheet(contentClass = ContentFontClass.AncillaryText)
|
|
||||||
navigationCoordinator.showBottomSheet(sheet)
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -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,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user