Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add slider setting type #24

Merged
merged 2 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import dev.brahmkshatriya.echo.common.settings.SettingCategory
import dev.brahmkshatriya.echo.common.settings.SettingItem
import dev.brahmkshatriya.echo.common.settings.SettingList
import dev.brahmkshatriya.echo.common.settings.SettingMultipleChoice
import dev.brahmkshatriya.echo.common.settings.SettingSlider
import dev.brahmkshatriya.echo.common.settings.SettingSwitch
import dev.brahmkshatriya.echo.common.settings.SettingTextInput
import dev.brahmkshatriya.echo.plugger.ExtensionMetadata
Expand All @@ -24,6 +25,7 @@ import dev.brahmkshatriya.echo.plugger.TrackerExtension
import dev.brahmkshatriya.echo.plugger.getExtension
import dev.brahmkshatriya.echo.utils.prefs.MaterialListPreference
import dev.brahmkshatriya.echo.utils.prefs.MaterialMultipleChoicePreference
import dev.brahmkshatriya.echo.utils.prefs.MaterialSliderPreference
import dev.brahmkshatriya.echo.utils.prefs.MaterialTextInputPreference
import dev.brahmkshatriya.echo.viewmodels.ExtensionViewModel

Expand Down Expand Up @@ -184,6 +186,17 @@ class ExtensionFragment : BaseSettingsFragment() {
}
}

is SettingSlider -> {
MaterialSliderPreference(preferenceGroup.context, from, to, steps).also {
it.title = this.title
it.key = this.key
it.summary = this.summary

it.isIconSpaceReserved = false
preferenceGroup.addPreference(it)
}
}

else -> throw IllegalArgumentException("Unsupported setting type")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package dev.brahmkshatriya.echo.common.settings

data class SettingSlider (
override val title: String,
override val key: String,
val summary: String? = null,
val from: Int,
val to: Int,
val steps: Int? = null
) : Setting
Loading