[SHARED] Code formatting
This commit is contained in:
+3
-2
@@ -41,10 +41,11 @@ actual class CpuDataNativeProvider actual constructor() : ICpuDataNativeProvider
|
||||
|
||||
actual external override fun getNumberOfCores(): Int
|
||||
|
||||
override fun getExtraItems(): List<ItemValue> = listOf(
|
||||
override fun getExtraItems(): List<ItemValue> =
|
||||
listOf(
|
||||
ItemValue.NameValueResource(
|
||||
name = Res.string.cpu_has_neon,
|
||||
value = if (hasArmNeon()) Res.string.yes else Res.string.no,
|
||||
),
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -18,10 +18,7 @@ package com.kgurgul.cpuinfo.domain.model
|
||||
import androidx.compose.runtime.Stable
|
||||
|
||||
@Stable
|
||||
data class CpuData(
|
||||
val cpuItems: List<ItemValue>,
|
||||
val frequencies: List<Frequency>,
|
||||
) {
|
||||
data class CpuData(val cpuItems: List<ItemValue>, val frequencies: List<Frequency>) {
|
||||
|
||||
data class Frequency(val min: Long, val max: Long, val current: Long)
|
||||
}
|
||||
|
||||
+1
-6
@@ -97,12 +97,7 @@ class CpuDataObservable(
|
||||
add(ItemValue.NameResource(Res.string.cpu_l4, l4Caches))
|
||||
}
|
||||
}
|
||||
emit(
|
||||
CpuData(
|
||||
cpuItems = cpuItems,
|
||||
frequencies = frequencies,
|
||||
)
|
||||
)
|
||||
emit(CpuData(cpuItems = cpuItems, frequencies = frequencies))
|
||||
delay(REFRESH_DELAY)
|
||||
}
|
||||
}
|
||||
|
||||
+12
-11
@@ -70,21 +70,18 @@ fun CpuInfoScreen(uiState: CpuInfoViewModel.UiState) {
|
||||
modifier = Modifier.fillMaxSize().testTag(CpuInfoScreenTestTags.LAZY_COLUMN),
|
||||
) {
|
||||
uiState.cpuData?.let { cpuData ->
|
||||
itemsIndexed(
|
||||
cpuData.cpuItems,
|
||||
key = { _, item -> item.getKey() },
|
||||
) { index, itemValue ->
|
||||
itemsIndexed(cpuData.cpuItems, key = { _, item -> item.getKey() }) {
|
||||
index,
|
||||
itemValue ->
|
||||
InformationRow(
|
||||
title = itemValue.getName(),
|
||||
value = itemValue.getValue(),
|
||||
isLastItem = index == cpuData.cpuItems.lastIndex
|
||||
&& cpuData.frequencies.isEmpty(),
|
||||
isLastItem =
|
||||
index == cpuData.cpuItems.lastIndex && cpuData.frequencies.isEmpty(),
|
||||
)
|
||||
}
|
||||
cpuData.frequencies.forEachIndexed { i, frequency ->
|
||||
item(key = "__frequency_$i") {
|
||||
FrequencyItem(index = i, frequency = frequency)
|
||||
}
|
||||
item(key = "__frequency_$i") { FrequencyItem(index = i, frequency = frequency) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,8 +135,12 @@ fun CpuInfoScreenPreview() {
|
||||
CpuInfoViewModel.UiState(
|
||||
cpuData =
|
||||
CpuData(
|
||||
cpuItems = listOf(
|
||||
ItemValue.NameResource(Res.string.cpu_soc_name, "processorName"),
|
||||
cpuItems =
|
||||
listOf(
|
||||
ItemValue.NameResource(
|
||||
Res.string.cpu_soc_name,
|
||||
"processorName",
|
||||
),
|
||||
ItemValue.Text("ABI", "abi"),
|
||||
ItemValue.Text("Cores", "1"),
|
||||
),
|
||||
|
||||
@@ -109,7 +109,8 @@ object TestData {
|
||||
|
||||
val cpuData =
|
||||
CpuData(
|
||||
cpuItems = listOf(
|
||||
cpuItems =
|
||||
listOf(
|
||||
ItemValue.NameResource(Res.string.cpu_soc_name, "CPU_NAME"),
|
||||
ItemValue.NameResource(Res.string.cpu_abi, "x64"),
|
||||
ItemValue.NameResource(Res.string.cpu_cores, "1"),
|
||||
|
||||
@@ -31,7 +31,8 @@ class CpuInfoScreenTest {
|
||||
@Test
|
||||
fun hasItems() = runComposeUiTest {
|
||||
setContent { CpuInfoScreen(uiState = CpuInfoViewModel.UiState(cpuData = TestData.cpuData)) }
|
||||
listOf("CPU_NAME", "x64", "1")
|
||||
.forEach { text -> onNodeWithText(text).performScrollTo().assertIsDisplayed() }
|
||||
listOf("CPU_NAME", "x64", "1").forEach { text ->
|
||||
onNodeWithText(text).performScrollTo().assertIsDisplayed()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-4
@@ -75,10 +75,7 @@ fun WearCpuInfoScreen(uiState: CpuInfoViewModel.UiState) {
|
||||
cpuData.frequencies.forEachIndexed { i, frequency ->
|
||||
item(key = "__frequency_$i") { FrequencyItem(index = i, frequency = frequency) }
|
||||
}
|
||||
items(
|
||||
cpuData.cpuItems,
|
||||
key = { it.getKey() },
|
||||
) { itemValue ->
|
||||
items(cpuData.cpuItems, key = { it.getKey() }) { itemValue ->
|
||||
WearCpuChip(
|
||||
label = itemValue.getName(),
|
||||
secondaryLabel = itemValue.getValue().replace("\n", ", "),
|
||||
|
||||
Reference in New Issue
Block a user