Skip to content

Commit

Permalink
feat: make fonts and mpv conf settings clearable
Browse files Browse the repository at this point in the history
  • Loading branch information
abdallahmehiz committed Aug 15, 2024
1 parent 4f653fc commit b143f3e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.Clear
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
Expand Down Expand Up @@ -45,6 +46,7 @@ import me.zhanghai.compose.preference.Preference
import me.zhanghai.compose.preference.ProvidePreferenceLocals
import me.zhanghai.compose.preference.TextFieldPreference
import me.zhanghai.compose.preference.preference
import me.zhanghai.compose.preference.twoTargetIconButtonPreference
import org.koin.compose.koinInject
import kotlin.io.path.deleteIfExists
import kotlin.io.path.outputStream
Expand Down Expand Up @@ -89,16 +91,20 @@ object AdvancedPreferencesScreen : Screen() {
.fillMaxSize()
.padding(padding),
) {
preference(
twoTargetIconButtonPreference(
"mpv_storage_location",
title = { Text(stringResource(R.string.pref_advanced_mpv_conf_storage_location)) },
summary = {
if (mpvConfStorageLocation.isNotBlank()) {
Text(getSimplifiedPathFromUri(mpvConfStorageLocation))
}
},
onClick = {
locationPicker.launch(null)
onClick = { locationPicker.launch(null) },
iconButtonIcon = {
Icon(Icons.Default.Clear, null)
},
onIconButtonClick = {
preferences.mpvConfStorageUri.delete()
},
)
item {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
import androidx.compose.material.icons.filled.Clear
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
Expand All @@ -29,8 +30,8 @@ import live.mehiz.mpvkt.preferences.SubtitlesPreferences
import live.mehiz.mpvkt.preferences.preference.collectAsState
import live.mehiz.mpvkt.presentation.Screen
import me.zhanghai.compose.preference.ProvidePreferenceLocals
import me.zhanghai.compose.preference.preference
import me.zhanghai.compose.preference.textFieldPreference
import me.zhanghai.compose.preference.twoTargetIconButtonPreference
import org.koin.compose.koinInject

object SubtitlesPreferencesScreen : Screen() {
Expand Down Expand Up @@ -88,13 +89,19 @@ object SubtitlesPreferencesScreen : Screen() {
}
},
)
preference(
twoTargetIconButtonPreference(
preferences.fontsFolder.key(),
title = { Text(stringResource(R.string.pref_subtitles_fonts_dir)) },
onClick = { locationPicker.launch(null) },
summary = {
if (fontsFolder.isBlank()) return@preference
if (fontsFolder.isBlank()) return@twoTargetIconButtonPreference
Text(getSimplifiedPathFromUri(fontsFolder))
},
iconButtonIcon = {
Icon(Icons.Default.Clear, null)
},
onIconButtonClick = {
preferences.fontsFolder.delete()
}
)
}
Expand Down

0 comments on commit b143f3e

Please sign in to comment.