refactor: rename and refactor ButtonItem
This commit is contained in:
parent
69689b8be6
commit
0fa8041d5c
40 changed files with 316 additions and 415 deletions
|
|
@ -6,7 +6,11 @@
|
|||
|
||||
package ua.acclorite.book_story.presentation.browse.model
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import ua.acclorite.book_story.R
|
||||
|
||||
enum class BrowseLayout {
|
||||
LIST, GRID
|
||||
|
||||
enum class BrowseLayout(@StringRes val title: Int) {
|
||||
LIST(R.string.layout_list),
|
||||
GRID(R.string.layout_grid)
|
||||
}
|
||||
|
|
@ -6,7 +6,10 @@
|
|||
|
||||
package ua.acclorite.book_story.presentation.library.model
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import ua.acclorite.book_story.R
|
||||
|
||||
enum class LibraryLayout {
|
||||
GRID, LIST
|
||||
enum class LibraryLayout(@StringRes val title: Int) {
|
||||
GRID(R.string.layout_grid),
|
||||
LIST(R.string.layout_list)
|
||||
}
|
||||
|
|
@ -6,7 +6,12 @@
|
|||
|
||||
package ua.acclorite.book_story.presentation.library.model
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import ua.acclorite.book_story.R
|
||||
|
||||
enum class LibraryTitlePosition {
|
||||
OFF, BELOW, INSIDE
|
||||
|
||||
enum class LibraryTitlePosition(@StringRes val title: Int) {
|
||||
OFF(R.string.library_title_position_off),
|
||||
BELOW(R.string.library_title_position_below),
|
||||
INSIDE(R.string.library_title_position_inside)
|
||||
}
|
||||
|
|
@ -6,10 +6,12 @@
|
|||
|
||||
package ua.acclorite.book_story.presentation.reader.model
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import ua.acclorite.book_story.R
|
||||
|
||||
enum class ReaderColorEffects {
|
||||
OFF,
|
||||
GRAYSCALE,
|
||||
FONT,
|
||||
BACKGROUND
|
||||
enum class ReaderColorEffects(@StringRes val title: Int) {
|
||||
OFF(R.string.color_effects_off),
|
||||
GRAYSCALE(R.string.color_effects_grayscale),
|
||||
FONT(R.string.color_effects_font),
|
||||
BACKGROUND(R.string.color_effects_background)
|
||||
}
|
||||
|
|
@ -6,12 +6,14 @@
|
|||
|
||||
package ua.acclorite.book_story.presentation.reader.model
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import ua.acclorite.book_story.R
|
||||
|
||||
enum class ReaderFontThickness(val thickness: FontWeight) {
|
||||
THIN(FontWeight.Thin),
|
||||
EXTRA_LIGHT(FontWeight.ExtraLight),
|
||||
LIGHT(FontWeight.Light),
|
||||
NORMAL(FontWeight.Normal),
|
||||
MEDIUM(FontWeight.Medium)
|
||||
enum class ReaderFontThickness(val thickness: FontWeight, @StringRes val title: Int) {
|
||||
THIN(FontWeight.Thin, R.string.font_thickness_thin),
|
||||
EXTRA_LIGHT(FontWeight.ExtraLight, R.string.font_thickness_extra_light),
|
||||
LIGHT(FontWeight.Light, R.string.font_thickness_light),
|
||||
NORMAL(FontWeight.Normal, R.string.font_thickness_normal),
|
||||
MEDIUM(FontWeight.Medium, R.string.font_thickness_medium)
|
||||
}
|
||||
|
|
@ -6,9 +6,11 @@
|
|||
|
||||
package ua.acclorite.book_story.presentation.reader.model
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import ua.acclorite.book_story.R
|
||||
|
||||
enum class ReaderHorizontalGesture {
|
||||
OFF,
|
||||
ON,
|
||||
INVERSE
|
||||
enum class ReaderHorizontalGesture(@StringRes val title: Int) {
|
||||
OFF(R.string.horizontal_gesture_off),
|
||||
ON(R.string.horizontal_gesture_on),
|
||||
INVERSE(R.string.horizontal_gesture_inverse)
|
||||
}
|
||||
|
|
@ -6,8 +6,11 @@
|
|||
|
||||
package ua.acclorite.book_story.presentation.reader.model
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import ua.acclorite.book_story.R
|
||||
|
||||
enum class ReaderProgressCount {
|
||||
PERCENTAGE,
|
||||
QUANTITY
|
||||
|
||||
enum class ReaderProgressCount(@StringRes val title: Int) {
|
||||
PERCENTAGE(R.string.progress_count_percentage),
|
||||
QUANTITY(R.string.progress_count_quantity)
|
||||
}
|
||||
|
|
@ -7,12 +7,32 @@
|
|||
package ua.acclorite.book_story.presentation.reader.model
|
||||
|
||||
import android.content.pm.ActivityInfo
|
||||
import androidx.annotation.StringRes
|
||||
import ua.acclorite.book_story.R
|
||||
|
||||
enum class ReaderScreenOrientation(val code: Int) {
|
||||
DEFAULT(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED),
|
||||
FREE(ActivityInfo.SCREEN_ORIENTATION_USER),
|
||||
PORTRAIT(ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT),
|
||||
LANDSCAPE(ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE),
|
||||
LOCKED_PORTRAIT(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT),
|
||||
LOCKED_LANDSCAPE(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE),
|
||||
enum class ReaderScreenOrientation(val code: Int, @StringRes val title: Int) {
|
||||
DEFAULT(
|
||||
ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED,
|
||||
R.string.default_string
|
||||
),
|
||||
FREE(
|
||||
ActivityInfo.SCREEN_ORIENTATION_USER,
|
||||
R.string.screen_orientation_free
|
||||
),
|
||||
PORTRAIT(
|
||||
ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT,
|
||||
R.string.screen_orientation_portrait
|
||||
),
|
||||
LANDSCAPE(
|
||||
ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE,
|
||||
R.string.screen_orientation_landscape
|
||||
),
|
||||
LOCKED_PORTRAIT(
|
||||
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT,
|
||||
R.string.screen_orientation_locked_portrait
|
||||
),
|
||||
LOCKED_LANDSCAPE(
|
||||
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE,
|
||||
R.string.screen_orientation_locked_landscape
|
||||
)
|
||||
}
|
||||
|
|
@ -6,11 +6,13 @@
|
|||
|
||||
package ua.acclorite.book_story.presentation.reader.model
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import ua.acclorite.book_story.R
|
||||
|
||||
enum class ReaderTextAlignment(val textAlignment: TextAlign) {
|
||||
START(TextAlign.Start),
|
||||
JUSTIFY(TextAlign.Justify),
|
||||
CENTER(TextAlign.Center),
|
||||
END(TextAlign.End)
|
||||
enum class ReaderTextAlignment(val textAlignment: TextAlign, @StringRes val title: Int) {
|
||||
START(TextAlign.Start, R.string.alignment_start),
|
||||
JUSTIFY(TextAlign.Justify, R.string.alignment_justify),
|
||||
CENTER(TextAlign.Center, R.string.alignment_center),
|
||||
END(TextAlign.End, R.string.alignment_end)
|
||||
}
|
||||
|
|
@ -12,7 +12,6 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import kotlinx.parcelize.IgnoredOnParcel
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
|
@ -25,7 +24,7 @@ import ua.acclorite.book_story.presentation.settings.SettingsEvent
|
|||
import ua.acclorite.book_story.presentation.settings.SettingsModel
|
||||
import ua.acclorite.book_story.ui.common.helpers.LocalActivity
|
||||
import ua.acclorite.book_story.ui.common.helpers.LocalSettings
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
import ua.acclorite.book_story.ui.navigator.LocalNavigator
|
||||
import ua.acclorite.book_story.ui.start.StartContent
|
||||
|
||||
|
|
@ -60,10 +59,9 @@ object StartScreen : Screen, Parcelable {
|
|||
|
||||
val languages = remember(settings.language.value) {
|
||||
CoreData.languages.sortedBy { it.second }.map {
|
||||
ButtonItem(
|
||||
id = it.first,
|
||||
ListItem(
|
||||
item = it.first,
|
||||
title = it.second,
|
||||
textStyle = TextStyle(),
|
||||
selected = it.first == settings.language.lastValue
|
||||
)
|
||||
}.sortedBy { it.title }
|
||||
|
|
|
|||
|
|
@ -19,20 +19,17 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import ua.acclorite.book_story.ui.common.components.common.StyledText
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
import ua.acclorite.book_story.ui.settings.components.SettingsSubcategoryTitle
|
||||
|
||||
/**
|
||||
* Chips with title. Use list of [ButtonItem]s to display chips.
|
||||
*/
|
||||
@Composable
|
||||
fun ChipsWithTitle(
|
||||
fun <T> ChipsWithTitle(
|
||||
modifier: Modifier = Modifier,
|
||||
title: String,
|
||||
chips: List<ButtonItem>,
|
||||
chips: List<ListItem<T>>,
|
||||
horizontalPadding: Dp = 18.dp,
|
||||
verticalPadding: Dp = 8.dp,
|
||||
onClick: (ButtonItem) -> Unit
|
||||
onClick: (T) -> Unit
|
||||
) {
|
||||
Column(
|
||||
modifier
|
||||
|
|
@ -53,14 +50,14 @@ fun ChipsWithTitle(
|
|||
label = {
|
||||
StyledText(
|
||||
text = item.title,
|
||||
style = item.textStyle,
|
||||
style = item.textStyle(),
|
||||
maxLines = 1
|
||||
)
|
||||
},
|
||||
onClick = { onClick(item) },
|
||||
)
|
||||
}
|
||||
},
|
||||
onClick = { onClick(item.item) },
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -44,31 +44,18 @@ import androidx.compose.ui.unit.dp
|
|||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.ui.common.components.common.AnimatedVisibility
|
||||
import ua.acclorite.book_story.ui.common.components.common.StyledText
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
import ua.acclorite.book_story.ui.settings.components.SettingsSubcategoryTitle
|
||||
|
||||
/**
|
||||
* Segmented Button with Title.
|
||||
* Uses custom implementation(material3 one has many flaws).
|
||||
* Contains [buttons].
|
||||
*
|
||||
* @param modifier Modifier.
|
||||
* @param title Title of the buttons.
|
||||
* @param buttons [ButtonItem]s.
|
||||
* @param enabled Whether button is enabled.
|
||||
* @param horizontalPadding Horizontal item padding.
|
||||
* @param verticalPadding Vertical item padding.
|
||||
* @param onClick OnClick callback.
|
||||
*/
|
||||
@Composable
|
||||
fun SegmentedButtonWithTitle(
|
||||
fun <T> SegmentedButtonWithTitle(
|
||||
modifier: Modifier = Modifier,
|
||||
title: String,
|
||||
buttons: List<ButtonItem>,
|
||||
buttons: List<ListItem<T>>,
|
||||
enabled: Boolean = true,
|
||||
horizontalPadding: Dp = 18.dp,
|
||||
verticalPadding: Dp = 8.dp,
|
||||
onClick: (ButtonItem) -> Unit
|
||||
onClick: (T) -> Unit
|
||||
) {
|
||||
Column(
|
||||
modifier
|
||||
|
|
@ -91,9 +78,9 @@ fun SegmentedButtonWithTitle(
|
|||
)
|
||||
.padding(0.5.dp)
|
||||
) {
|
||||
buttons.forEachIndexed { index, buttonItem ->
|
||||
buttons.forEachIndexed { index, item ->
|
||||
SegmentedButton(
|
||||
button = buttonItem,
|
||||
button = item,
|
||||
enabled = enabled,
|
||||
shape = when (index) {
|
||||
buttons.lastIndex -> RoundedCornerShape(
|
||||
|
|
@ -108,7 +95,7 @@ fun SegmentedButtonWithTitle(
|
|||
|
||||
else -> RoundedCornerShape(0)
|
||||
},
|
||||
onClick = { onClick(buttonItem) }
|
||||
onClick = { onClick(item.item) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -117,19 +104,9 @@ fun SegmentedButtonWithTitle(
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom Segmented button.
|
||||
* Adjusts width based on component name.
|
||||
*
|
||||
* @param button [ButtonItem].
|
||||
* @param enabled Whether can be clicked.
|
||||
* @param shape Shape of the button. For proper implementation should have 100% corners on first and last buttons(start and end).
|
||||
* @param colors [SegmentedButtonColors].
|
||||
* @param onClick OnClick callback.
|
||||
*/
|
||||
@Composable
|
||||
private fun SegmentedButton(
|
||||
button: ButtonItem,
|
||||
private fun <T> SegmentedButton(
|
||||
button: ListItem<T>,
|
||||
enabled: Boolean,
|
||||
shape: RoundedCornerShape,
|
||||
colors: SegmentedButtonColors = SegmentedButtonDefaults.colors(),
|
||||
|
|
@ -181,7 +158,7 @@ private fun SegmentedButton(
|
|||
|
||||
StyledText(
|
||||
text = button.title,
|
||||
style = button.textStyle.copy(
|
||||
style = button.textStyle().copy(
|
||||
color = if (button.selected) colors.activeContentColor
|
||||
else colors.inactiveContentColor
|
||||
)
|
||||
|
|
|
|||
|
|
@ -33,20 +33,6 @@ import ua.acclorite.book_story.ui.common.components.common.StyledText
|
|||
import ua.acclorite.book_story.ui.settings.components.SettingsSubcategoryTitle
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
/**
|
||||
* Slider with title.
|
||||
*
|
||||
* @param modifier Modifier.
|
||||
* @param value Value to be displayed, in pair with [String] which is the type of value(e.g. "pt")
|
||||
* @param valuePlaceholder Placeholder of the value(e.g. "Default", instead of the "1pt")
|
||||
* @param showPlaceholder Whether placeholder should be shown.
|
||||
* @param fromValue From where user can pick value.
|
||||
* @param toValue To where user can pick value.
|
||||
* @param title Title of this slider.
|
||||
* @param horizontalPadding Horizontal item padding.
|
||||
* @param verticalPadding Vertical item padding.
|
||||
* @param onValueChange Callback when value changes.
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun SliderWithTitle(
|
||||
|
|
@ -127,19 +113,6 @@ fun SliderWithTitle(
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Slider with title.
|
||||
*
|
||||
* @param modifier Modifier.
|
||||
* @param value Value to be displayed, in pair with [String] which is the type of value(e.g. "pt")
|
||||
* @param valuePlaceholder Placeholder of the value(e.g. "Default", instead of the "1pt")
|
||||
* @param showPlaceholder Whether placeholder should be shown.
|
||||
* @param toValue To where user can pick value.
|
||||
* @param title Title of this slider.
|
||||
* @param horizontalPadding Horizontal item padding.
|
||||
* @param verticalPadding Vertical item padding.
|
||||
* @param onValueChange Callback when value changes.
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun SliderWithTitle(
|
||||
|
|
|
|||
|
|
@ -25,16 +25,6 @@ import androidx.compose.ui.unit.Dp
|
|||
import androidx.compose.ui.unit.dp
|
||||
import ua.acclorite.book_story.ui.common.components.common.StyledText
|
||||
|
||||
/**
|
||||
* Checkbox with title.
|
||||
*
|
||||
* @param selected Whether [Switch] has checked state.
|
||||
* @param title Title.
|
||||
* @param description Optional description.
|
||||
* @param horizontalPadding Horizontal padding.
|
||||
* @param verticalPadding Vertical padding.
|
||||
* @param onClick Triggers when user clicks anywhere on this composable.
|
||||
*/
|
||||
@Composable
|
||||
fun SwitchWithTitle(
|
||||
modifier: Modifier = Modifier,
|
||||
|
|
|
|||
|
|
@ -6,13 +6,15 @@
|
|||
|
||||
package ua.acclorite.book_story.ui.common.model
|
||||
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
|
||||
@Immutable
|
||||
data class ButtonItem(
|
||||
val id: String,
|
||||
data class ListItem<T>(
|
||||
val item: T,
|
||||
val title: String,
|
||||
val textStyle: TextStyle,
|
||||
val textStyle: @Composable () -> TextStyle = { MaterialTheme.typography.labelLarge },
|
||||
val selected: Boolean
|
||||
)
|
||||
|
|
@ -6,13 +6,12 @@
|
|||
|
||||
package ua.acclorite.book_story.ui.settings.appearance.theme_preferences.components
|
||||
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.ui.common.components.settings.SegmentedButtonWithTitle
|
||||
import ua.acclorite.book_story.ui.common.helpers.LocalSettings
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
import ua.acclorite.book_story.ui.theme.model.DarkTheme
|
||||
|
||||
@Composable
|
||||
|
|
@ -21,19 +20,15 @@ fun DarkThemeOption() {
|
|||
|
||||
SegmentedButtonWithTitle(
|
||||
title = stringResource(id = R.string.dark_theme_option),
|
||||
buttons = DarkTheme.entries.map {
|
||||
ButtonItem(
|
||||
it.name,
|
||||
title = when (it) {
|
||||
DarkTheme.OFF -> stringResource(id = R.string.dark_theme_off)
|
||||
DarkTheme.ON -> stringResource(id = R.string.dark_theme_on)
|
||||
DarkTheme.FOLLOW_SYSTEM -> stringResource(id = R.string.dark_theme_follow_system)
|
||||
buttons = DarkTheme.entries.map { item ->
|
||||
ListItem(
|
||||
item = item,
|
||||
title = stringResource(id = item.title),
|
||||
selected = item == settings.darkTheme.value
|
||||
)
|
||||
},
|
||||
textStyle = MaterialTheme.typography.labelLarge,
|
||||
selected = it == settings.darkTheme.value
|
||||
onClick = { item ->
|
||||
settings.darkTheme.update(item)
|
||||
}
|
||||
)
|
||||
}
|
||||
) {
|
||||
settings.darkTheme.update(DarkTheme.valueOf(it.id))
|
||||
}
|
||||
}
|
||||
|
|
@ -6,13 +6,12 @@
|
|||
|
||||
package ua.acclorite.book_story.ui.settings.appearance.theme_preferences.components
|
||||
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.ui.common.components.settings.SegmentedButtonWithTitle
|
||||
import ua.acclorite.book_story.ui.common.helpers.LocalSettings
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
import ua.acclorite.book_story.ui.theme.ExpandingTransition
|
||||
import ua.acclorite.book_story.ui.theme.model.PureDark
|
||||
|
||||
|
|
@ -23,20 +22,16 @@ fun PureDarkOption() {
|
|||
ExpandingTransition(visible = settings.darkTheme.value.isDark()) {
|
||||
SegmentedButtonWithTitle(
|
||||
title = stringResource(id = R.string.pure_dark_option),
|
||||
buttons = PureDark.entries.map {
|
||||
ButtonItem(
|
||||
id = it.toString(),
|
||||
title = when (it) {
|
||||
PureDark.OFF -> stringResource(id = R.string.pure_dark_off)
|
||||
PureDark.ON -> stringResource(id = R.string.pure_dark_on)
|
||||
PureDark.SAVER -> stringResource(id = R.string.pure_dark_power_saver)
|
||||
buttons = PureDark.entries.map { item ->
|
||||
ListItem(
|
||||
item = item,
|
||||
title = stringResource(id = item.title),
|
||||
selected = item == settings.pureDark.value
|
||||
)
|
||||
},
|
||||
textStyle = MaterialTheme.typography.labelLarge,
|
||||
selected = it == settings.pureDark.value
|
||||
onClick = { item ->
|
||||
settings.pureDark.update(item)
|
||||
}
|
||||
)
|
||||
}
|
||||
) {
|
||||
settings.pureDark.update(PureDark.valueOf(it.id))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
package ua.acclorite.book_story.ui.settings.appearance.theme_preferences.components
|
||||
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
|
|
@ -16,7 +15,7 @@ import androidx.compose.ui.res.stringResource
|
|||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.ui.common.components.settings.SegmentedButtonWithTitle
|
||||
import ua.acclorite.book_story.ui.common.helpers.LocalSettings
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
import ua.acclorite.book_story.ui.theme.BookStoryTheme
|
||||
import ua.acclorite.book_story.ui.theme.ExpandingTransition
|
||||
import ua.acclorite.book_story.ui.theme.model.ThemeContrast
|
||||
|
|
@ -42,21 +41,17 @@ fun ThemeContrastOption() {
|
|||
SegmentedButtonWithTitle(
|
||||
title = stringResource(id = R.string.theme_contrast_option),
|
||||
enabled = settings.theme.value.hasThemeContrast,
|
||||
buttons = ThemeContrast.entries.map {
|
||||
ButtonItem(
|
||||
id = it.toString(),
|
||||
title = when (it) {
|
||||
ThemeContrast.STANDARD -> stringResource(id = R.string.theme_contrast_standard)
|
||||
ThemeContrast.MEDIUM -> stringResource(id = R.string.theme_contrast_medium)
|
||||
ThemeContrast.HIGH -> stringResource(id = R.string.theme_contrast_high)
|
||||
buttons = ThemeContrast.entries.map { item ->
|
||||
ListItem(
|
||||
item = item,
|
||||
title = stringResource(id = item.title),
|
||||
selected = item == settings.themeContrast.value
|
||||
)
|
||||
},
|
||||
textStyle = MaterialTheme.typography.labelLarge,
|
||||
selected = it == settings.themeContrast.value
|
||||
onClick = { item ->
|
||||
settings.themeContrast.update(item)
|
||||
}
|
||||
)
|
||||
}
|
||||
) {
|
||||
settings.themeContrast.update(ThemeContrast.valueOf(it.id))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,14 +6,13 @@
|
|||
|
||||
package ua.acclorite.book_story.ui.settings.browse.display.components
|
||||
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.browse.model.BrowseLayout
|
||||
import ua.acclorite.book_story.ui.common.components.settings.SegmentedButtonWithTitle
|
||||
import ua.acclorite.book_story.ui.common.helpers.LocalSettings
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
|
||||
@Composable
|
||||
fun BrowseLayoutOption() {
|
||||
|
|
@ -21,18 +20,15 @@ fun BrowseLayoutOption() {
|
|||
|
||||
SegmentedButtonWithTitle(
|
||||
title = stringResource(id = R.string.layout_option),
|
||||
buttons = BrowseLayout.entries.map {
|
||||
ButtonItem(
|
||||
it.toString(),
|
||||
when (it) {
|
||||
BrowseLayout.LIST -> stringResource(id = R.string.layout_list)
|
||||
BrowseLayout.GRID -> stringResource(id = R.string.layout_grid)
|
||||
buttons = BrowseLayout.entries.map { item ->
|
||||
ListItem(
|
||||
item = item,
|
||||
title = stringResource(id = item.title),
|
||||
selected = item == settings.browseLayout.value
|
||||
)
|
||||
},
|
||||
MaterialTheme.typography.labelLarge,
|
||||
it == settings.browseLayout.value
|
||||
onClick = { item ->
|
||||
settings.browseLayout.update(item)
|
||||
}
|
||||
)
|
||||
}
|
||||
) {
|
||||
settings.browseLayout.update(BrowseLayout.valueOf(it.id))
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
package ua.acclorite.book_story.ui.settings.general.components
|
||||
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
|
|
@ -16,7 +15,7 @@ import ua.acclorite.book_story.presentation.settings.SettingsEvent
|
|||
import ua.acclorite.book_story.presentation.settings.SettingsModel
|
||||
import ua.acclorite.book_story.ui.common.components.settings.ChipsWithTitle
|
||||
import ua.acclorite.book_story.ui.common.helpers.LocalSettings
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
|
||||
@Composable
|
||||
fun AppLanguageOption() {
|
||||
|
|
@ -25,15 +24,15 @@ fun AppLanguageOption() {
|
|||
|
||||
ChipsWithTitle(
|
||||
title = stringResource(id = R.string.language_option),
|
||||
chips = CoreData.languages.sortedBy { it.second }.map {
|
||||
ButtonItem(
|
||||
it.first,
|
||||
it.second,
|
||||
MaterialTheme.typography.labelLarge,
|
||||
it.first == settings.language.value
|
||||
chips = CoreData.languages.sortedBy { it.second }.map { item ->
|
||||
ListItem(
|
||||
item = item.first,
|
||||
title = item.second,
|
||||
selected = item.first == settings.language.value
|
||||
)
|
||||
},
|
||||
onClick = { item ->
|
||||
settingsModel.onEvent(SettingsEvent.OnUpdateLanguage(item))
|
||||
}
|
||||
)
|
||||
}
|
||||
) {
|
||||
settingsModel.onEvent(SettingsEvent.OnUpdateLanguage(it.id))
|
||||
}
|
||||
}
|
||||
|
|
@ -6,14 +6,13 @@
|
|||
|
||||
package ua.acclorite.book_story.ui.settings.library.display.components
|
||||
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.library.model.LibraryLayout
|
||||
import ua.acclorite.book_story.ui.common.components.settings.SegmentedButtonWithTitle
|
||||
import ua.acclorite.book_story.ui.common.helpers.LocalSettings
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
|
||||
@Composable
|
||||
fun LibraryLayoutOption() {
|
||||
|
|
@ -21,18 +20,15 @@ fun LibraryLayoutOption() {
|
|||
|
||||
SegmentedButtonWithTitle(
|
||||
title = stringResource(id = R.string.layout_option),
|
||||
buttons = LibraryLayout.entries.map {
|
||||
ButtonItem(
|
||||
it.toString(),
|
||||
when (it) {
|
||||
LibraryLayout.LIST -> stringResource(id = R.string.layout_list)
|
||||
LibraryLayout.GRID -> stringResource(id = R.string.layout_grid)
|
||||
buttons = LibraryLayout.entries.map { item ->
|
||||
ListItem(
|
||||
item = item,
|
||||
title = stringResource(id = item.title),
|
||||
selected = item == settings.libraryLayout.value
|
||||
)
|
||||
},
|
||||
MaterialTheme.typography.labelLarge,
|
||||
it == settings.libraryLayout.value
|
||||
onClick = { item ->
|
||||
settings.libraryLayout.update(item)
|
||||
}
|
||||
)
|
||||
}
|
||||
) {
|
||||
settings.libraryLayout.update(LibraryLayout.valueOf(it.id))
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
package ua.acclorite.book_story.ui.settings.library.display.components
|
||||
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import ua.acclorite.book_story.R
|
||||
|
|
@ -14,7 +13,7 @@ import ua.acclorite.book_story.presentation.library.model.LibraryLayout
|
|||
import ua.acclorite.book_story.presentation.library.model.LibraryTitlePosition
|
||||
import ua.acclorite.book_story.ui.common.components.settings.ChipsWithTitle
|
||||
import ua.acclorite.book_story.ui.common.helpers.LocalSettings
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
import ua.acclorite.book_story.ui.theme.ExpandingTransition
|
||||
|
||||
@Composable
|
||||
|
|
@ -24,20 +23,16 @@ fun LibraryTitlePositionOption() {
|
|||
ExpandingTransition(visible = settings.libraryLayout.value == LibraryLayout.GRID) {
|
||||
ChipsWithTitle(
|
||||
title = stringResource(id = R.string.title_position_option),
|
||||
chips = LibraryTitlePosition.entries.map {
|
||||
ButtonItem(
|
||||
it.name,
|
||||
when (it) {
|
||||
LibraryTitlePosition.OFF -> stringResource(id = R.string.library_title_position_off)
|
||||
LibraryTitlePosition.BELOW -> stringResource(id = R.string.library_title_position_below)
|
||||
LibraryTitlePosition.INSIDE -> stringResource(id = R.string.library_title_position_inside)
|
||||
chips = LibraryTitlePosition.entries.map { item ->
|
||||
ListItem(
|
||||
item = item,
|
||||
title = stringResource(id = item.title),
|
||||
selected = item == settings.libraryTitlePosition.value
|
||||
)
|
||||
},
|
||||
MaterialTheme.typography.labelLarge,
|
||||
it == settings.libraryTitlePosition.value
|
||||
onClick = { item ->
|
||||
settings.libraryTitlePosition.update(item)
|
||||
}
|
||||
)
|
||||
}
|
||||
) {
|
||||
settings.libraryTitlePosition.update(LibraryTitlePosition.valueOf(it.id))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,14 +6,13 @@
|
|||
|
||||
package ua.acclorite.book_story.ui.settings.reader.chapters.components
|
||||
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.reader.model.ReaderTextAlignment
|
||||
import ua.acclorite.book_story.ui.common.components.settings.SegmentedButtonWithTitle
|
||||
import ua.acclorite.book_story.ui.common.helpers.LocalSettings
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
|
||||
@Composable
|
||||
fun ChapterTitleAlignmentOption() {
|
||||
|
|
@ -21,21 +20,15 @@ fun ChapterTitleAlignmentOption() {
|
|||
|
||||
SegmentedButtonWithTitle(
|
||||
title = stringResource(id = R.string.chapter_title_alignment_option),
|
||||
buttons = ReaderTextAlignment.entries.map {
|
||||
ButtonItem(
|
||||
id = it.toString(),
|
||||
title = when (it) {
|
||||
ReaderTextAlignment.START -> stringResource(id = R.string.alignment_start)
|
||||
ReaderTextAlignment.JUSTIFY -> stringResource(id = R.string.alignment_justify)
|
||||
ReaderTextAlignment.CENTER -> stringResource(id = R.string.alignment_center)
|
||||
ReaderTextAlignment.END -> stringResource(id = R.string.alignment_end)
|
||||
},
|
||||
textStyle = MaterialTheme.typography.labelLarge,
|
||||
selected = it == settings.chapterTitleAlignment.value
|
||||
buttons = ReaderTextAlignment.entries.map { item ->
|
||||
ListItem(
|
||||
item = item,
|
||||
title = stringResource(id = item.title),
|
||||
selected = item == settings.chapterTitleAlignment.value
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
settings.chapterTitleAlignment.update(ReaderTextAlignment.valueOf(it.id))
|
||||
onClick = { item ->
|
||||
settings.chapterTitleAlignment.update(item)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ import androidx.compose.ui.res.stringResource
|
|||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.ui.common.components.settings.ChipsWithTitle
|
||||
import ua.acclorite.book_story.ui.common.helpers.LocalSettings
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
import ua.acclorite.book_story.ui.reader.data.ReaderData
|
||||
|
||||
@Composable
|
||||
|
|
@ -21,21 +21,20 @@ fun FontFamilyOption() {
|
|||
|
||||
ChipsWithTitle(
|
||||
title = stringResource(id = R.string.font_family_option),
|
||||
chips = ReaderData.fonts.map {
|
||||
ButtonItem(
|
||||
id = it.id,
|
||||
title = it.fontName.asString(),
|
||||
textStyle = MaterialTheme.typography.labelLarge.copy(
|
||||
fontFamily = it.font
|
||||
),
|
||||
selected = it == settings.fontFamily.value
|
||||
chips = ReaderData.fonts.map { item ->
|
||||
ListItem(
|
||||
item = item,
|
||||
title = item.fontName.asString(),
|
||||
textStyle = {
|
||||
MaterialTheme.typography.labelLarge.copy(
|
||||
fontFamily = item.font
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
settings.fontFamily.update(
|
||||
ReaderData.fonts.find { font -> font.id == it.id }
|
||||
?: ReaderData.fonts[0]
|
||||
selected = item == settings.fontFamily.value
|
||||
)
|
||||
},
|
||||
onClick = { item ->
|
||||
settings.fontFamily.update(item)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@ import androidx.compose.ui.text.font.FontStyle
|
|||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.ui.common.components.settings.SegmentedButtonWithTitle
|
||||
import ua.acclorite.book_story.ui.common.helpers.LocalSettings
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
|
||||
@Composable
|
||||
fun FontStyleOption() {
|
||||
|
|
@ -22,32 +22,31 @@ fun FontStyleOption() {
|
|||
SegmentedButtonWithTitle(
|
||||
title = stringResource(id = R.string.font_style_option),
|
||||
buttons = listOf(
|
||||
ButtonItem(
|
||||
id = "normal",
|
||||
ListItem(
|
||||
item = false,
|
||||
title = stringResource(id = R.string.font_style_normal),
|
||||
textStyle = MaterialTheme.typography.labelLarge.copy(
|
||||
textStyle = {
|
||||
MaterialTheme.typography.labelLarge.copy(
|
||||
fontFamily = settings.fontFamily.value.font,
|
||||
fontStyle = FontStyle.Normal
|
||||
),
|
||||
)
|
||||
},
|
||||
selected = !settings.italic.value
|
||||
),
|
||||
ButtonItem(
|
||||
id = "italic",
|
||||
ListItem(
|
||||
item = true,
|
||||
title = stringResource(id = R.string.font_style_italic),
|
||||
textStyle = MaterialTheme.typography.labelLarge.copy(
|
||||
textStyle = {
|
||||
MaterialTheme.typography.labelLarge.copy(
|
||||
fontFamily = settings.fontFamily.value.font,
|
||||
fontStyle = FontStyle.Italic
|
||||
),
|
||||
)
|
||||
},
|
||||
selected = settings.italic.value
|
||||
)
|
||||
),
|
||||
onClick = {
|
||||
settings.italic.update(
|
||||
when (it.id) {
|
||||
"italic" -> true
|
||||
else -> false
|
||||
}
|
||||
)
|
||||
onClick = { item ->
|
||||
settings.italic.update(item)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@ import ua.acclorite.book_story.R
|
|||
import ua.acclorite.book_story.presentation.reader.model.ReaderFontThickness
|
||||
import ua.acclorite.book_story.ui.common.components.settings.ChipsWithTitle
|
||||
import ua.acclorite.book_story.ui.common.helpers.LocalSettings
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
|
||||
@Composable
|
||||
fun FontThicknessOption() {
|
||||
|
|
@ -21,25 +21,21 @@ fun FontThicknessOption() {
|
|||
|
||||
ChipsWithTitle(
|
||||
title = stringResource(id = R.string.font_thickness_option),
|
||||
chips = ReaderFontThickness.entries.map {
|
||||
ButtonItem(
|
||||
id = it.toString(),
|
||||
title = when (it) {
|
||||
ReaderFontThickness.THIN -> stringResource(id = R.string.font_thickness_thin)
|
||||
ReaderFontThickness.EXTRA_LIGHT -> stringResource(id = R.string.font_thickness_extra_light)
|
||||
ReaderFontThickness.LIGHT -> stringResource(id = R.string.font_thickness_light)
|
||||
ReaderFontThickness.NORMAL -> stringResource(id = R.string.font_thickness_normal)
|
||||
ReaderFontThickness.MEDIUM -> stringResource(id = R.string.font_thickness_medium)
|
||||
},
|
||||
textStyle = MaterialTheme.typography.labelLarge.copy(
|
||||
chips = ReaderFontThickness.entries.map { item ->
|
||||
ListItem(
|
||||
item = item,
|
||||
title = stringResource(id = item.title),
|
||||
textStyle = {
|
||||
MaterialTheme.typography.labelLarge.copy(
|
||||
fontFamily = settings.fontFamily.value.font,
|
||||
fontWeight = it.thickness
|
||||
),
|
||||
selected = it == settings.fontThickness.value
|
||||
fontWeight = item.thickness
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
settings.fontThickness.update(ReaderFontThickness.valueOf(it.id))
|
||||
selected = item == settings.fontThickness.value
|
||||
)
|
||||
},
|
||||
onClick = { item ->
|
||||
settings.fontThickness.update(item)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -6,13 +6,12 @@
|
|||
|
||||
package ua.acclorite.book_story.ui.settings.reader.images.components
|
||||
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.ui.common.components.settings.SegmentedButtonWithTitle
|
||||
import ua.acclorite.book_story.ui.common.helpers.LocalSettings
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
import ua.acclorite.book_story.ui.theme.ExpandingTransition
|
||||
import ua.acclorite.book_story.ui.theme.model.HorizontalAlignment
|
||||
|
||||
|
|
@ -23,20 +22,15 @@ fun ImagesAlignmentOption() {
|
|||
ExpandingTransition(visible = settings.images.value) {
|
||||
SegmentedButtonWithTitle(
|
||||
title = stringResource(id = R.string.images_alignment_option),
|
||||
buttons = HorizontalAlignment.entries.map {
|
||||
ButtonItem(
|
||||
id = it.name,
|
||||
title = when (it) {
|
||||
HorizontalAlignment.START -> stringResource(id = R.string.alignment_start)
|
||||
HorizontalAlignment.CENTER -> stringResource(id = R.string.alignment_center)
|
||||
HorizontalAlignment.END -> stringResource(id = R.string.alignment_end)
|
||||
},
|
||||
textStyle = MaterialTheme.typography.labelLarge,
|
||||
selected = it == settings.imagesAlignment.value
|
||||
buttons = HorizontalAlignment.entries.map { item ->
|
||||
ListItem(
|
||||
item = item,
|
||||
title = stringResource(id = item.title),
|
||||
selected = item == settings.imagesAlignment.value
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
settings.imagesAlignment.update(HorizontalAlignment.valueOf(it.id))
|
||||
onClick = { item ->
|
||||
settings.imagesAlignment.update(item)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,14 +6,13 @@
|
|||
|
||||
package ua.acclorite.book_story.ui.settings.reader.images.components
|
||||
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.reader.model.ReaderColorEffects
|
||||
import ua.acclorite.book_story.ui.common.components.settings.ChipsWithTitle
|
||||
import ua.acclorite.book_story.ui.common.helpers.LocalSettings
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
import ua.acclorite.book_story.ui.theme.ExpandingTransition
|
||||
|
||||
@Composable
|
||||
|
|
@ -23,21 +22,15 @@ fun ImagesColorEffectsOption() {
|
|||
ExpandingTransition(visible = settings.images.value) {
|
||||
ChipsWithTitle(
|
||||
title = stringResource(id = R.string.images_color_effects_option),
|
||||
chips = ReaderColorEffects.entries.map {
|
||||
ButtonItem(
|
||||
id = it.name,
|
||||
title = when (it) {
|
||||
ReaderColorEffects.OFF -> stringResource(R.string.color_effects_off)
|
||||
ReaderColorEffects.GRAYSCALE -> stringResource(R.string.color_effects_grayscale)
|
||||
ReaderColorEffects.FONT -> stringResource(R.string.color_effects_font)
|
||||
ReaderColorEffects.BACKGROUND -> stringResource(R.string.color_effects_background)
|
||||
},
|
||||
textStyle = MaterialTheme.typography.labelLarge,
|
||||
selected = it == settings.imagesColorEffects.value
|
||||
chips = ReaderColorEffects.entries.map { item ->
|
||||
ListItem(
|
||||
item = item,
|
||||
title = stringResource(id = item.title),
|
||||
selected = item == settings.imagesColorEffects.value
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
settings.imagesColorEffects.update(ReaderColorEffects.valueOf(it.id))
|
||||
onClick = { item ->
|
||||
settings.imagesColorEffects.update(item)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,13 +6,12 @@
|
|||
|
||||
package ua.acclorite.book_story.ui.settings.reader.progress.components
|
||||
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.ui.common.components.settings.SegmentedButtonWithTitle
|
||||
import ua.acclorite.book_story.ui.common.helpers.LocalSettings
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
import ua.acclorite.book_story.ui.theme.ExpandingTransition
|
||||
import ua.acclorite.book_story.ui.theme.model.HorizontalAlignment
|
||||
|
||||
|
|
@ -23,20 +22,15 @@ fun ProgressBarAlignmentOption() {
|
|||
ExpandingTransition(visible = settings.progressBar.value) {
|
||||
SegmentedButtonWithTitle(
|
||||
title = stringResource(id = R.string.progress_bar_alignment_option),
|
||||
buttons = HorizontalAlignment.entries.map {
|
||||
ButtonItem(
|
||||
id = it.name,
|
||||
title = when (it) {
|
||||
HorizontalAlignment.START -> stringResource(id = R.string.alignment_start)
|
||||
HorizontalAlignment.CENTER -> stringResource(id = R.string.alignment_center)
|
||||
HorizontalAlignment.END -> stringResource(id = R.string.alignment_end)
|
||||
},
|
||||
textStyle = MaterialTheme.typography.labelLarge,
|
||||
selected = it == settings.progressBarAlignment.value
|
||||
buttons = HorizontalAlignment.entries.map { item ->
|
||||
ListItem(
|
||||
item = item,
|
||||
title = stringResource(id = item.title),
|
||||
selected = item == settings.progressBarAlignment.value
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
settings.progressBarAlignment.update(HorizontalAlignment.valueOf(it.id))
|
||||
onClick = { item ->
|
||||
settings.progressBarAlignment.update(item)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,14 +6,13 @@
|
|||
|
||||
package ua.acclorite.book_story.ui.settings.reader.progress.components
|
||||
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.reader.model.ReaderProgressCount
|
||||
import ua.acclorite.book_story.ui.common.components.settings.SegmentedButtonWithTitle
|
||||
import ua.acclorite.book_story.ui.common.helpers.LocalSettings
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
|
||||
@Composable
|
||||
fun ProgressCountOption() {
|
||||
|
|
@ -21,19 +20,15 @@ fun ProgressCountOption() {
|
|||
|
||||
SegmentedButtonWithTitle(
|
||||
title = stringResource(id = R.string.progress_count_option),
|
||||
buttons = ReaderProgressCount.entries.map {
|
||||
ButtonItem(
|
||||
id = it.name,
|
||||
title = when (it) {
|
||||
ReaderProgressCount.PERCENTAGE -> stringResource(id = R.string.progress_count_percentage)
|
||||
ReaderProgressCount.QUANTITY -> stringResource(id = R.string.progress_count_quantity)
|
||||
},
|
||||
textStyle = MaterialTheme.typography.labelLarge,
|
||||
selected = it == settings.progressCount.value
|
||||
buttons = ReaderProgressCount.entries.map { item ->
|
||||
ListItem(
|
||||
item = item,
|
||||
title = stringResource(id = item.title),
|
||||
selected = item == settings.progressCount.value
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
settings.progressCount.update(ReaderProgressCount.valueOf(it.id))
|
||||
onClick = { item ->
|
||||
settings.progressCount.update(item)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -6,14 +6,13 @@
|
|||
|
||||
package ua.acclorite.book_story.ui.settings.reader.reading_mode.components
|
||||
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.reader.model.ReaderHorizontalGesture
|
||||
import ua.acclorite.book_story.ui.common.components.settings.ChipsWithTitle
|
||||
import ua.acclorite.book_story.ui.common.helpers.LocalSettings
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
|
||||
@Composable
|
||||
fun HorizontalGestureOption() {
|
||||
|
|
@ -21,20 +20,15 @@ fun HorizontalGestureOption() {
|
|||
|
||||
ChipsWithTitle(
|
||||
title = stringResource(id = R.string.horizontal_gesture_option),
|
||||
chips = ReaderHorizontalGesture.entries.map {
|
||||
ButtonItem(
|
||||
id = it.name,
|
||||
title = when (it) {
|
||||
ReaderHorizontalGesture.OFF -> stringResource(R.string.horizontal_gesture_off)
|
||||
ReaderHorizontalGesture.ON -> stringResource(R.string.horizontal_gesture_on)
|
||||
ReaderHorizontalGesture.INVERSE -> stringResource(R.string.horizontal_gesture_inverse)
|
||||
},
|
||||
textStyle = MaterialTheme.typography.labelLarge,
|
||||
selected = it == settings.horizontalGesture.value
|
||||
chips = ReaderHorizontalGesture.entries.map { item ->
|
||||
ListItem(
|
||||
item = item,
|
||||
title = stringResource(id = item.title),
|
||||
selected = item == settings.horizontalGesture.value
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
settings.horizontalGesture.update(ReaderHorizontalGesture.valueOf(it.id))
|
||||
onClick = { item ->
|
||||
settings.horizontalGesture.update(item)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -6,14 +6,13 @@
|
|||
|
||||
package ua.acclorite.book_story.ui.settings.reader.system.components
|
||||
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.reader.model.ReaderScreenOrientation
|
||||
import ua.acclorite.book_story.ui.common.components.settings.ChipsWithTitle
|
||||
import ua.acclorite.book_story.ui.common.helpers.LocalSettings
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
|
||||
@Composable
|
||||
fun ScreenOrientationOption() {
|
||||
|
|
@ -21,23 +20,15 @@ fun ScreenOrientationOption() {
|
|||
|
||||
ChipsWithTitle(
|
||||
title = stringResource(id = R.string.screen_orientation_option),
|
||||
chips = ReaderScreenOrientation.entries.map {
|
||||
ButtonItem(
|
||||
id = it.name,
|
||||
title = when (it) {
|
||||
ReaderScreenOrientation.FREE -> stringResource(id = R.string.screen_orientation_free)
|
||||
ReaderScreenOrientation.PORTRAIT -> stringResource(id = R.string.screen_orientation_portrait)
|
||||
ReaderScreenOrientation.LANDSCAPE -> stringResource(id = R.string.screen_orientation_landscape)
|
||||
ReaderScreenOrientation.LOCKED_PORTRAIT -> stringResource(id = R.string.screen_orientation_locked_portrait)
|
||||
ReaderScreenOrientation.LOCKED_LANDSCAPE -> stringResource(id = R.string.screen_orientation_locked_landscape)
|
||||
else -> stringResource(id = R.string.default_string)
|
||||
},
|
||||
textStyle = MaterialTheme.typography.labelLarge,
|
||||
selected = it == settings.screenOrientation.value
|
||||
chips = ReaderScreenOrientation.entries.map { item ->
|
||||
ListItem(
|
||||
item = item,
|
||||
title = stringResource(id = item.title),
|
||||
selected = item == settings.screenOrientation.value
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
settings.screenOrientation.update(ReaderScreenOrientation.valueOf(it.id))
|
||||
onClick = { item ->
|
||||
settings.screenOrientation.update(item)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -6,14 +6,13 @@
|
|||
|
||||
package ua.acclorite.book_story.ui.settings.reader.text.components
|
||||
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.reader.model.ReaderTextAlignment
|
||||
import ua.acclorite.book_story.ui.common.components.settings.SegmentedButtonWithTitle
|
||||
import ua.acclorite.book_story.ui.common.helpers.LocalSettings
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
|
||||
@Composable
|
||||
fun TextAlignmentOption() {
|
||||
|
|
@ -21,21 +20,15 @@ fun TextAlignmentOption() {
|
|||
|
||||
SegmentedButtonWithTitle(
|
||||
title = stringResource(id = R.string.text_alignment_option),
|
||||
buttons = ReaderTextAlignment.entries.map {
|
||||
ButtonItem(
|
||||
id = it.toString(),
|
||||
title = when (it) {
|
||||
ReaderTextAlignment.START -> stringResource(id = R.string.alignment_start)
|
||||
ReaderTextAlignment.JUSTIFY -> stringResource(id = R.string.alignment_justify)
|
||||
ReaderTextAlignment.CENTER -> stringResource(id = R.string.alignment_center)
|
||||
ReaderTextAlignment.END -> stringResource(id = R.string.alignment_end)
|
||||
},
|
||||
textStyle = MaterialTheme.typography.labelLarge,
|
||||
selected = it == settings.textAlignment.value
|
||||
buttons = ReaderTextAlignment.entries.map { item ->
|
||||
ListItem(
|
||||
item = item,
|
||||
title = stringResource(id = item.title),
|
||||
selected = item == settings.textAlignment.value
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
settings.textAlignment.update(ReaderTextAlignment.valueOf(it.id))
|
||||
onClick = { item ->
|
||||
settings.textAlignment.update(item)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -12,13 +12,13 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.ui.Modifier
|
||||
import ua.acclorite.book_story.presentation.navigator.StackEvent
|
||||
import ua.acclorite.book_story.presentation.start.StartScreen
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
|
||||
@Composable
|
||||
fun StartContent(
|
||||
currentPage: Int,
|
||||
stackEvent: StackEvent,
|
||||
languages: List<ButtonItem>,
|
||||
languages: List<ListItem<String>>,
|
||||
updateLanguage: (String) -> Unit,
|
||||
navigateForward: () -> Unit,
|
||||
navigateBack: () -> Unit,
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ package ua.acclorite.book_story.ui.start
|
|||
import androidx.compose.runtime.Composable
|
||||
import ua.acclorite.book_story.presentation.navigator.StackEvent
|
||||
import ua.acclorite.book_story.presentation.start.StartScreen
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
|
||||
@Composable
|
||||
fun StartSettings(
|
||||
currentPage: Int,
|
||||
stackEvent: StackEvent,
|
||||
languages: List<ButtonItem>,
|
||||
languages: List<ListItem<String>>,
|
||||
updateLanguage: (String) -> Unit,
|
||||
navigateForward: () -> Unit
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@ import androidx.compose.ui.res.stringResource
|
|||
import androidx.compose.ui.unit.dp
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.ui.common.components.dialog.SelectableDialogItem
|
||||
import ua.acclorite.book_story.ui.common.model.ButtonItem
|
||||
import ua.acclorite.book_story.ui.common.model.ListItem
|
||||
import ua.acclorite.book_story.ui.settings.components.SettingsSubcategoryTitle
|
||||
|
||||
fun LazyListScope.StartSettingsLayoutGeneral(
|
||||
languages: List<ButtonItem>,
|
||||
languages: List<ListItem<String>>,
|
||||
updateLanguage: (String) -> Unit,
|
||||
) {
|
||||
item {
|
||||
|
|
@ -34,13 +34,13 @@ fun LazyListScope.StartSettingsLayoutGeneral(
|
|||
Spacer(modifier = Modifier.height(12.dp))
|
||||
}
|
||||
|
||||
items(languages, key = { it.id }) {
|
||||
items(languages, key = { it.item }) {
|
||||
SelectableDialogItem(
|
||||
selected = it.selected,
|
||||
title = it.title,
|
||||
horizontalPadding = 18.dp
|
||||
) {
|
||||
updateLanguage(it.id)
|
||||
updateLanguage(it.item)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,13 +6,15 @@
|
|||
|
||||
package ua.acclorite.book_story.ui.theme.model
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import ua.acclorite.book_story.R
|
||||
|
||||
enum class DarkTheme {
|
||||
FOLLOW_SYSTEM,
|
||||
OFF,
|
||||
ON;
|
||||
enum class DarkTheme(@StringRes val title: Int) {
|
||||
FOLLOW_SYSTEM(R.string.dark_theme_follow_system),
|
||||
OFF(R.string.dark_theme_off),
|
||||
ON(R.string.dark_theme_on);
|
||||
|
||||
@Composable
|
||||
fun isDark(): Boolean {
|
||||
|
|
|
|||
|
|
@ -6,10 +6,12 @@
|
|||
|
||||
package ua.acclorite.book_story.ui.theme.model
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.ui.Alignment
|
||||
import ua.acclorite.book_story.R
|
||||
|
||||
enum class HorizontalAlignment(val alignment: Alignment) {
|
||||
START(Alignment.Companion.CenterStart),
|
||||
CENTER(Alignment.Companion.Center),
|
||||
END(Alignment.Companion.CenterEnd)
|
||||
enum class HorizontalAlignment(val alignment: Alignment, @StringRes val title: Int) {
|
||||
START(Alignment.Companion.CenterStart, R.string.alignment_start),
|
||||
CENTER(Alignment.Companion.Center, R.string.alignment_center),
|
||||
END(Alignment.Companion.CenterEnd, R.string.alignment_end)
|
||||
}
|
||||
|
|
@ -8,12 +8,14 @@ package ua.acclorite.book_story.ui.theme.model
|
|||
|
||||
import android.content.Context
|
||||
import android.os.PowerManager
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.runtime.Composable
|
||||
import ua.acclorite.book_story.R
|
||||
|
||||
enum class PureDark {
|
||||
OFF,
|
||||
ON,
|
||||
SAVER;
|
||||
enum class PureDark(@StringRes val title: Int) {
|
||||
OFF(R.string.pure_dark_off),
|
||||
ON(R.string.pure_dark_on),
|
||||
SAVER(R.string.pure_dark_power_saver);
|
||||
|
||||
@Composable
|
||||
fun isPureDark(context: Context): Boolean {
|
||||
|
|
|
|||
|
|
@ -6,9 +6,12 @@
|
|||
|
||||
package ua.acclorite.book_story.ui.theme.model
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import ua.acclorite.book_story.R
|
||||
|
||||
enum class ThemeContrast {
|
||||
STANDARD,
|
||||
MEDIUM,
|
||||
HIGH
|
||||
|
||||
enum class ThemeContrast(@StringRes val title: Int) {
|
||||
STANDARD(R.string.theme_contrast_standard),
|
||||
MEDIUM(R.string.theme_contrast_medium),
|
||||
HIGH(R.string.theme_contrast_high)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue