Skip to content

Commit

Permalink
Show selected color in color picker
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickunterwegs committed Dec 8, 2024
1 parent d39ba74 commit 8f4904a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ import androidx.compose.material.icons.outlined.FormatColorReset
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SmallFloatingActionButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import at.techbee.jtx.R
import com.github.skydoves.colorpicker.compose.AlphaSlider
import com.github.skydoves.colorpicker.compose.BrightnessSlider
import com.github.skydoves.colorpicker.compose.ColorPickerController
Expand Down Expand Up @@ -64,6 +67,35 @@ fun ColorSelector(
verticalArrangement = Arrangement.Center,
modifier = modifier
) {

Column (
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.fillMaxWidth().padding(8.dp)
) {
SmallFloatingActionButton(
modifier = Modifier
.padding(2.dp)
.border(
2.dp,
MaterialTheme.colorScheme.primary,
RoundedCornerShape(16.dp)
),
containerColor = colorPickerController.selectedColor.value,
onClick = { /* do nothing */ },
content = {
if (colorPickerController.selectedColor.value == Color.Unspecified)
Icon(Icons.Outlined.FormatColorReset, null)
}
)

Text(
text = stringResource(R.string.selected_color),
style = MaterialTheme.typography.labelMedium

)
}

LazyRow {
items(defaultColors) { color ->
SmallFloatingActionButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,10 @@ fun ListWidgetConfigGeneral(
)

Spacer(modifier = Modifier.weight(1f))
Text("System colors")
Text(
text = stringResource(R.string.system_colors),
style = MaterialTheme.typography.labelMedium
)
Switch(
checked = listSettings.widgetColor.value == null,
onCheckedChange = {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@
<string name="menu_collections_add_local">"Add local Collection"</string>
<string name="navigation_drawer_website_news">"News &amp; Release Notes"</string>
<string name="color">"Color"</string>
<string name="selected_color">"Selected color"</string>
<string name="system_colors">"System colors"</string>
<string name="priority_0_no_priority">"No priority"</string>
<string name="priority_1_highest">"1 - Highest"</string>
<string name="priority_2_higher">"2 - Higher"</string>
Expand Down

0 comments on commit 8f4904a

Please sign in to comment.