Skip to content

Commit

Permalink
feat: update style items range
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaWei committed Nov 12, 2024
1 parent d2cf72b commit 1930025
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId = "jarvay.workpaper"
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.targetSdk.get().toInt()
versionCode = 14
versionName = "2.0.0"
versionCode = 15
versionName = "2.1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
23 changes: 19 additions & 4 deletions app/src/main/java/jarvay/workpaper/compose/style/StyleForm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.widthIn
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.HorizontalRule
import androidx.compose.material.icons.filled.Save
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
Expand All @@ -29,6 +31,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import jarvay.workpaper.R
import jarvay.workpaper.compose.components.CustomIconButton
import jarvay.workpaper.data.style.Style
import jarvay.workpaper.ui.theme.COLOR_FORM_LABEL
import jarvay.workpaper.ui.theme.SCREEN_HORIZONTAL_PADDING
Expand Down Expand Up @@ -114,7 +117,7 @@ fun StyleForm(
onValueChange = {
style = style.copy(brightness = it)
},
valueRange = 0f..100f
valueRange = -100f..200f
)

StyleFormItemSlider(
Expand All @@ -123,7 +126,7 @@ fun StyleForm(
onValueChange = {
style = style.copy(contrast = it)
},
valueRange = 0f..100f
valueRange = -100f..200f
)

StyleFormItemSlider(
Expand All @@ -132,7 +135,7 @@ fun StyleForm(
onValueChange = {
style = style.copy(saturation = it)
},
valueRange = 0f..100f
valueRange = -100f..200f
)
}
}
Expand Down Expand Up @@ -171,6 +174,12 @@ private fun StyleFormItemSlider(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically
) {
CustomIconButton(onClick = {
onValueChange(value - 1)
}, enabled = value > valueRange.start.toInt()) {
Icon(imageVector = Icons.Default.HorizontalRule, contentDescription = null)
}

Slider(
modifier = Modifier
.weight(1f),
Expand All @@ -182,10 +191,16 @@ private fun StyleFormItemSlider(
valueRange = valueRange
)

CustomIconButton(onClick = {
onValueChange(value + 1)
}, enabled = value < valueRange.endInclusive.toInt()) {
Icon(imageVector = Icons.Default.Add, contentDescription = null)
}

Text(
modifier = Modifier
.padding(start = 4.dp)
.widthIn(24.dp),
.widthIn(32.dp),
text = value.toString()
)
}
Expand Down

0 comments on commit 1930025

Please sign in to comment.