Contrast aan/uit: blauwe kaart = aan, grijze kaart = uit + contrastrijke switch-kleuren

This commit is contained in:
eddy 2026-10-14 20:45:28 +02:00
commit 15bd0cdbfb
5 changed files with 33 additions and 3 deletions

View file

@ -15,6 +15,7 @@ import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.lifecycle.lifecycleScope
import com.google.android.material.card.MaterialCardView
import kotlinx.coroutines.launch
import nl.eddydevink.buschauffeurswekker.core.AlarmScheduler
import nl.eddydevink.buschauffeurswekker.core.AlarmSpec
@ -126,11 +127,20 @@ class MainActivity : AppCompatActivity() {
val card = inflater.inflate(R.layout.item_alarm_card, container, false)
card.findViewById<TextView>(R.id.tv_day).text = dayLabel
card.findViewById<TextView>(R.id.tv_name).text = spec.name
card.findViewById<TextView>(R.id.tv_time).text = TIME.format(spec.time)
val timeView = card.findViewById<TextView>(R.id.tv_time)
timeView.text = TIME.format(spec.time)
val switch = card.findViewById<Switch>(R.id.switch_alarm)
switch.setOnCheckedChangeListener(null)
switch.isChecked = !disabled
card.alpha = if (disabled) 0.5f else 1f
// Helder onderscheid: blauw = aan, grijs = uit (zoals de systeemwekker).
val cardView = card as MaterialCardView
if (disabled) {
cardView.setCardBackgroundColor(ContextCompat.getColor(this, R.color.card_idle))
timeView.setTextColor(ContextCompat.getColor(this, R.color.text_muted))
} else {
cardView.setCardBackgroundColor(ContextCompat.getColor(this, R.color.card_active))
timeView.setTextColor(ContextCompat.getColor(this, R.color.text_bright))
}
switch.setOnCheckedChangeListener { _, checked ->
toggleAlarm(spec, checked)
renderStatus()

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- aan: donkere knop op witte track -->
<item android:state_checked="true" android:color="#0A0A0C" />
<!-- uit: lichte grijze knop op donkere track -->
<item android:color="#9AA0A6" />
</selector>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- helder: track wit als de wekker aan staat -->
<item android:state_checked="true" android:color="#FFFFFF" />
<!-- uit: donkergrijze track die op de grijze kaart nog zichtbaar is -->
<item android:color="#4A4A50" />
</selector>

View file

@ -59,6 +59,8 @@
android:id="@+id/switch_alarm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="Wekker aan of uit" />
android:contentDescription="Wekker aan of uit"
android:thumbTint="@color/switch_thumb"
android:trackTint="@color/switch_track" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>