|
1 | | -package com.qrshield.android.ui.components |
| 1 | +package com.qrshield.ui.components |
2 | 2 |
|
3 | 3 | import androidx.compose.animation.core.* |
4 | 4 | import androidx.compose.foundation.Canvas |
5 | 5 | import androidx.compose.foundation.layout.* |
| 6 | +import androidx.compose.foundation.shape.RoundedCornerShape |
6 | 7 | import androidx.compose.material3.MaterialTheme |
| 8 | +import androidx.compose.material3.Surface |
7 | 9 | import androidx.compose.material3.Text |
8 | 10 | import androidx.compose.runtime.* |
9 | 11 | import androidx.compose.ui.Alignment |
10 | 12 | import androidx.compose.ui.Modifier |
11 | 13 | import androidx.compose.ui.geometry.Offset |
12 | 14 | import androidx.compose.ui.graphics.Color |
13 | | -import androidx.compose.ui.graphics.drawscope.DrawScope |
14 | 15 | import androidx.compose.ui.graphics.graphicsLayer |
15 | 16 | import androidx.compose.ui.semantics.contentDescription |
16 | 17 | import androidx.compose.ui.semantics.semantics |
17 | 18 | import androidx.compose.ui.unit.dp |
18 | | -import com.qrshield.android.ui.theme.QRShieldColors |
19 | | -import kotlinx.coroutines.launch |
20 | | -import kotlin.math.cos |
21 | 19 | import kotlin.math.sin |
22 | 20 | import kotlin.random.Random |
23 | 21 |
|
24 | 22 | /** |
25 | 23 | * A "Brain" visualization that lights up specific neural clusters based on detected signals. |
26 | 24 | * Designed for immediate visual feedback in the "Beat The Bot" game. |
27 | 25 | * |
| 26 | + * This component is shared between Android and Desktop (KMP). |
| 27 | + * |
28 | 28 | * @param detectedSignals List of signal strings (e.g. "TLD_ABUSE", "BRAND_IMPERSONATION") |
29 | 29 | * @param modifier Modifier for layout |
30 | 30 | */ |
31 | 31 | @Composable |
32 | | -fun BrainVisualizer( |
| 32 | +fun CommonBrainVisualizer( |
33 | 33 | detectedSignals: List<String>, |
34 | 34 | modifier: Modifier = Modifier |
35 | 35 | ) { |
@@ -91,9 +91,9 @@ private fun BrainCanvas( |
91 | 91 | mapSignalsToNodes(signals, nodes.size) |
92 | 92 | } |
93 | 93 |
|
94 | | - // Color definitions |
95 | | - val safeColor = QRShieldColors.Primary |
96 | | - val dangerColor = QRShieldColors.Red500 |
| 94 | + // Color definitions from Material Theme for KMP compatibility |
| 95 | + val safeColor = MaterialTheme.colorScheme.primary |
| 96 | + val dangerColor = MaterialTheme.colorScheme.error |
97 | 97 | val inactiveColor = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.3f) |
98 | 98 |
|
99 | 99 | Canvas(modifier = modifier) { |
@@ -176,24 +176,29 @@ private fun BrainCanvas( |
176 | 176 |
|
177 | 177 | @Composable |
178 | 178 | private fun DetectedSignalsBadges(signals: List<String>) { |
| 179 | + val errorColor = MaterialTheme.colorScheme.error |
| 180 | + |
| 181 | + // Use FlowRow if available in newer Compose, but Row is safer for older versions |
| 182 | + // For now, we'll wrap in a Row with horizontal scrolling if needed, or simple wrapping isn't easy without FlowRow |
| 183 | + // Let's use a simple Row for MVP centered |
179 | 184 | Row( |
180 | 185 | modifier = Modifier |
181 | 186 | .fillMaxWidth() |
182 | 187 | .padding(horizontal = 16.dp), |
183 | 188 | horizontalArrangement = Arrangement.Center |
184 | 189 | ) { |
185 | 190 | signals.forEach { signal -> |
186 | | - androidx.compose.material3.Surface( |
187 | | - color = QRShieldColors.Red500.copy(alpha = 0.1f), |
188 | | - shape = androidx.compose.foundation.shape.RoundedCornerShape(4.dp), |
189 | | - border = androidx.compose.foundation.BorderStroke(1.dp, QRShieldColors.Red500.copy(alpha = 0.3f)), |
| 191 | + Surface( |
| 192 | + color = errorColor.copy(alpha = 0.1f), |
| 193 | + shape = RoundedCornerShape(4.dp), |
| 194 | + border = androidx.compose.foundation.BorderStroke(1.dp, errorColor.copy(alpha = 0.3f)), |
190 | 195 | modifier = Modifier.padding(4.dp) |
191 | 196 | ) { |
192 | 197 | Text( |
193 | 198 | text = signal.replace("_", " "), |
194 | 199 | modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp), |
195 | 200 | style = MaterialTheme.typography.labelSmall, |
196 | | - color = QRShieldColors.Red500 |
| 201 | + color = errorColor |
197 | 202 | ) |
198 | 203 | } |
199 | 204 | } |
|
0 commit comments