Skip to content

Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.

feat: enhance LegalConsentDialog with expandable document sections for improved readability

Durganshu Mishra49192dd81656
diff --git a/app/src/main/java/com/gotcha/LegalConsentDialog.kt b/app/src/main/java/com/gotcha/LegalConsentDialog.kt
index 3116190..7eaeda1 100644
--- a/app/src/main/java/com/gotcha/LegalConsentDialog.kt
+++ b/app/src/main/java/com/gotcha/LegalConsentDialog.kt
@@ -1,6 +1,7 @@
package com.gotcha
import android.content.Context
+import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
@@ -10,8 +11,12 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.selection.toggleable
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.ExpandLess
+import androidx.compose.material.icons.filled.ExpandMore
import androidx.compose.material3.Checkbox
import androidx.compose.material3.HorizontalDivider
+import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
@@ -172,12 +177,16 @@ fun LegalConsentDialog(
}
/**
- * One legal document inline: section title plus its rendered Markdown body.
- * Sits in a soft surface card so the eye picks it out from the surrounding
- * summary text, which uses the default background.
+ * One legal document inline: a tappable header (title + chevron) that
+ * expands to reveal the rendered Markdown body. Starts collapsed — these
+ * documents are long, and showing all three fully expanded by default would
+ * turn the dialog into a wall of text the user has to scroll past rather
+ * than one they can selectively dig into.
*/
@Composable
private fun DocumentBlock(title: String, body: String?, loadingLabel: String) {
+ var expanded by remember { mutableStateOf(false) }
+
Surface(
shape = RoundedCornerShape(8.dp),
color = MaterialTheme.colorScheme.surfaceVariant,
@@ -189,17 +198,33 @@ private fun DocumentBlock(title: String, body: String?, loadingLabel: String) {
.padding(horizontal = 12.dp, vertical = 10.dp),
verticalArrangement = Arrangement.spacedBy(6.dp)
) {
- Text(
- text = title,
- style = MaterialTheme.typography.titleSmall,
- fontWeight = FontWeight.SemiBold,
- color = MaterialTheme.colorScheme.onSurfaceVariant
- )
- Text(
- text = renderLegalMarkdown(body ?: loadingLabel),
- style = MaterialTheme.typography.bodySmall,
- color = MaterialTheme.colorScheme.onSurfaceVariant
- )
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .clickable { expanded = !expanded },
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Text(
+ text = title,
+ style = MaterialTheme.typography.titleSmall,
+ fontWeight = FontWeight.SemiBold,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ modifier = Modifier.weight(1f)
+ )
+ Icon(
+ imageVector = if (expanded) Icons.Default.ExpandLess else Icons.Default.ExpandMore,
+ contentDescription = null,
+ tint = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ }
+ if (expanded) {
+ Text(
+ text = renderLegalMarkdown(body ?: loadingLabel),
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ }
}
}
}