Skip to content

Commit d6ed2a4

Browse files
committed
Extract colors to avoid duplication and for more clarity.
1 parent f55cfd1 commit d6ed2a4

File tree

1 file changed

+14
-9
lines changed
  • features/viewfolder/impl/src/main/kotlin/io/element/android/features/viewfolder/impl/file

1 file changed

+14
-9
lines changed

features/viewfolder/impl/src/main/kotlin/io/element/android/features/viewfolder/impl/file/ViewFileView.kt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -218,25 +218,30 @@ private fun LineRow(
218218
private fun String.toColor(colorationMode: ColorationMode): Color {
219219
return when (colorationMode) {
220220
ColorationMode.Logcat -> when (getOrNull(31)) {
221-
'D' -> Color(0xFF299999)
222-
'I' -> Color(0xFFABC023)
223-
'W' -> Color(0xFFBBB529)
224-
'E' -> Color(0xFFFF6B68)
225-
'A' -> Color(0xFFFF6B68)
221+
'D' -> colorDebug
222+
'I' -> colorInfo
223+
'W' -> colorWarning
224+
'E' -> colorError
225+
'A' -> colorError
226226
else -> ElementTheme.colors.textPrimary
227227
}
228228
ColorationMode.RustLogs -> when (getOrNull(32)) {
229229
'E' -> ElementTheme.colors.textPrimary
230-
'G' -> Color(0xFF299999)
231-
'0' -> Color(0xFFABC023)
232-
'N' -> Color(0xFFBBB529)
233-
'R' -> Color(0xFFFF6B68)
230+
'G' -> colorDebug
231+
'0' -> colorInfo
232+
'N' -> colorWarning
233+
'R' -> colorError
234234
else -> ElementTheme.colors.textPrimary
235235
}
236236
ColorationMode.None -> ElementTheme.colors.textPrimary
237237
}
238238
}
239239

240+
private val colorDebug = Color(0xFF299999)
241+
private val colorInfo = Color(0xFFABC023)
242+
private val colorWarning = Color(0xFFBBB529)
243+
private val colorError = Color(0xFFFF6B68)
244+
240245
@PreviewsDayNight
241246
@Composable
242247
internal fun ViewFileViewPreview(@PreviewParameter(ViewFileStateProvider::class) state: ViewFileState) = ElementPreview {

0 commit comments

Comments
 (0)