Skip to content

Commit

Permalink
fix: Reset font size box when resetting to defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
jmir1 committed Oct 22, 2023
1 parent f35aafb commit f5436a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -193,7 +192,7 @@ fun OutlinedNumericChooser(
min: Int? = null,
onValueChanged: (Int) -> Unit,
) {
var currentValue by rememberSaveable { mutableStateOf(value) }
var currentValue = value

val updateValue: (Boolean) -> Unit = {
currentValue += if (it) step else -step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ private fun SubtitleFont(
) {
val boldSubtitles by screenModel.preferences.boldSubtitles().collectAsState()
val italicSubtitles by screenModel.preferences.italicSubtitles().collectAsState()
val subtitleFontSize by screenModel.preferences.subtitleFontSize().collectAsState()
val textColor by screenModel.preferences.textColorSubtitles().collectAsState()
val borderColor by screenModel.preferences.borderColorSubtitles().collectAsState()
val backgroundColor by screenModel.preferences.backgroundColorSubtitles().collectAsState()

val updateBold = {
val toBold = if (boldSubtitles) "no" else "yes"
Expand All @@ -56,10 +60,6 @@ private fun SubtitleFont(
MPVLib.setPropertyString("sub-italic", toItalicize)
}

val textColorPref = screenModel.preferences.textColorSubtitles()
val borderColorPref = screenModel.preferences.borderColorSubtitles()
val backgroundColorPref = screenModel.preferences.backgroundColorSubtitles()

val onSizeChanged: (Int) -> Unit = {
MPVLib.setPropertyInt("sub-font-size", it)
screenModel.preferences.subtitleFontSize().set(it)
Expand All @@ -84,7 +84,7 @@ private fun SubtitleFont(
label = stringResource(id = R.string.player_font_size_text_field),
placeholder = "55",
suffix = "",
value = screenModel.preferences.subtitleFontSize().get(),
value = subtitleFontSize,
step = 1,
min = 1,
onValueChanged = onSizeChanged,
Expand Down Expand Up @@ -112,11 +112,11 @@ private fun SubtitleFont(
}

SubtitlePreview(
isBold = screenModel.preferences.boldSubtitles().collectAsState().value,
isItalic = screenModel.preferences.italicSubtitles().collectAsState().value,
textColor = Color(textColorPref.collectAsState().value),
borderColor = Color(borderColorPref.collectAsState().value),
backgroundColor = Color(backgroundColorPref.collectAsState().value),
isBold = boldSubtitles,
isItalic = italicSubtitles,
textColor = Color(textColor),
borderColor = Color(borderColor),
backgroundColor = Color(backgroundColor),
)
}
}

0 comments on commit f5436a4

Please sign in to comment.