Skip to content

Commit

Permalink
add random color to palette selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Razeeman committed Apr 28, 2024
1 parent a390800 commit 15fcb7c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,9 @@ class ChangeRecordCore(
) {
binding.fieldChangeRecordTimeEnded.isVisible = isVisible
binding.containerChangeRecordTimeEndedAdjust.isVisible = isVisible

binding.fieldChangeRecordChangeCurrentPreviewTimeEnded.isVisible = isVisible
binding.btnChangeRecordChangeCurrentPreviewTimeStartedAdjust.isVisible = isVisible
binding.btnChangeRecordChangeCurrentPreviewTimeEndedAdjust.isVisible = isVisible
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
app:layout_constraintBottom_toTopOf="@id/dividerChangeRecordButton"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0"
tools:visibility="visible">
tools:visibility="gone">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -570,7 +570,7 @@
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/dividerChangeRecordButton"
app:layout_constraintTop_toBottomOf="@id/containerChangeRecordMain"
tools:visibility="gone">
tools:visibility="visible">

<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class ColorSelectionDialogFragment : BaseBottomSheetFragment<Binding>() {
.doAfterTextChanged { viewModel.onHSVFieldsChanged(it.toString(), HSVUpdate.V) }

btnColorSelectionSave.setOnClick(viewModel::onSaveClick)
btnColorSelectionRandom.setOnClick(viewModel::onRandomClick)
}

override fun initViewModel(): Unit = with(viewModel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ class ColorSelectionViewModel @Inject constructor() : ViewModel() {
getCurrentColorInt().let(colorSelected::set)
}

fun onRandomClick() {
colorRed = (0..255).random()
colorGreen = (0..255).random()
colorBlue = (0..255).random()

onRGBChanged()
}

private fun onHexChanged(@ColorInt newHexColor: Int) {
val hsv = FloatArray(3)
Color.colorToHSV(newHexColor, hsv)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,23 @@
<com.google.android.material.button.MaterialButton
android:id="@+id/btnColorSelectionSave"
style="@style/AppButtonActive"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_marginHorizontal="8dp"
android:text="@string/duration_dialog_save"
app:layout_constraintBottom_toBottomOf="parent" />
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/btnColorSelectionRandom"
app:layout_constraintStart_toStartOf="parent" />

<com.google.android.material.button.MaterialButton
android:id="@+id/btnColorSelectionRandom"
style="@style/AppButton"
android:layout_width="48dp"
android:layout_marginEnd="8dp"
app:icon="@drawable/ic_casino_24px"
app:iconGravity="textStart"
app:iconPadding="0dp"
app:iconTint="?appLightTextColor"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 15fcb7c

Please sign in to comment.