commit 0648f78d41aa83ec2c4ef1696210d0db655e5372
parent 9bf1fee4a9b346823c663498f2ceffc857f5fd43
Author: MTRNord <MTRNord@users.noreply.github.com>
Date: Tue, 29 Jul 2025 19:55:38 +0200
Minor improvements to accessibility
Diffstat:
3 files changed, 43 insertions(+), 12 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -13,4 +13,5 @@
.externalNativeBuild
.cxx
local.properties
-.idea/
-\ No newline at end of file
+.idea/
+.kotlin/
+\ No newline at end of file
diff --git a/app/src/main/java/space/midnightthoughts/nordiccalendar/MainActivity.kt b/app/src/main/java/space/midnightthoughts/nordiccalendar/MainActivity.kt
@@ -25,7 +25,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material3.ExperimentalMaterial3Api
-import androidx.compose.material3.FloatingActionButton
+import androidx.compose.material3.ExtendedFloatingActionButton
import androidx.compose.material3.Icon
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
@@ -251,12 +251,20 @@ fun CalendarView(
selectedDestination = "calendar",
navController = navController,
floatingActionButton = {
- FloatingActionButton(onClick = { /* Event hinzufügen (später) */ }) {
- Icon(
- Icons.Default.Add,
- contentDescription = stringResource(R.string.event_add)
- )
- }
+ ExtendedFloatingActionButton(
+ onClick = { /* Event hinzufügen (später) */ },
+ icon = {
+ Icon(
+ Icons.Default.Add,
+ contentDescription = stringResource(R.string.event_add),
+ )
+ },
+ text = {
+ Text(
+ text = stringResource(R.string.event_add),
+ )
+ },
+ )
}
) { innerPadding ->
CalendarScreen(
diff --git a/app/src/main/java/space/midnightthoughts/nordiccalendar/screens/CalendarScreen.kt b/app/src/main/java/space/midnightthoughts/nordiccalendar/screens/CalendarScreen.kt
@@ -55,6 +55,12 @@ import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.semantics.CollectionInfo
+import androidx.compose.ui.semantics.CollectionItemInfo
+import androidx.compose.ui.semantics.collectionInfo
+import androidx.compose.ui.semantics.collectionItemInfo
+import androidx.compose.ui.semantics.heading
+import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.IntOffset
@@ -216,7 +222,16 @@ fun DayView(
val lineThickness = 4.dp
val lineColor = MaterialTheme.colorScheme.error
// Stunden-Divider
- Column(modifier = Modifier.fillMaxWidth()) {
+ Column(
+ modifier = Modifier
+ .fillMaxWidth()
+ .semantics {
+ collectionInfo = CollectionInfo(
+ rowCount = events.value.size,
+ columnCount = 1,
+ )
+ }
+ ) {
for (hour in 0..23) {
Row(
verticalAlignment = Alignment.CenterVertically,
@@ -447,7 +462,8 @@ fun EventCard(
event: Event,
isCompact: Boolean,
modifier: Modifier = Modifier,
- onClick: (() -> Unit)? = null
+ onClick: (() -> Unit)? = null,
+ index: Int = 0
) {
val appLocale = getCurrentAppLocale(LocalContext.current)
val hourFormat = DateTimeFormatter.ofPattern("HH:mm", appLocale)
@@ -462,6 +478,11 @@ fun EventCard(
modifier = modifier
.defaultMinSize(minHeight = 24.dp)
.padding(end = 8.dp)
+ .semantics {
+ collectionItemInfo = CollectionItemInfo(
+ index, 0, 0, 0,
+ )
+ }
.then(if (onClick != null) Modifier.clickable { onClick() } else Modifier),
colors = CardDefaults.outlinedCardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),
border = BorderStroke(
@@ -481,7 +502,8 @@ fun EventCard(
Text(
event.title,
overflow = TextOverflow.Ellipsis,
- style = if (isCompact) MaterialTheme.typography.bodySmall else MaterialTheme.typography.bodyLarge
+ style = if (isCompact) MaterialTheme.typography.bodySmall else MaterialTheme.typography.bodyLarge,
+ modifier = Modifier.semantics { heading() }
)
if (!isCompact) {
Spacer(modifier = Modifier.height(4.dp))