|
|
@ -5,6 +5,7 @@
|
|
|
|
package org.mozilla.fenix.perf
|
|
|
|
package org.mozilla.fenix.perf
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.StringRes
|
|
|
|
import androidx.annotation.StringRes
|
|
|
|
|
|
|
|
import androidx.compose.foundation.background
|
|
|
|
import androidx.compose.foundation.clickable
|
|
|
|
import androidx.compose.foundation.clickable
|
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
@ -15,19 +16,22 @@ import androidx.compose.foundation.layout.padding
|
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
|
import androidx.compose.material.Card
|
|
|
|
import androidx.compose.material.Card
|
|
|
|
import androidx.compose.material.CircularProgressIndicator
|
|
|
|
import androidx.compose.material.CircularProgressIndicator
|
|
|
|
import androidx.compose.material.RadioButton
|
|
|
|
|
|
|
|
import androidx.compose.material.Text
|
|
|
|
import androidx.compose.material.Text
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.runtime.MutableState
|
|
|
|
import androidx.compose.runtime.mutableStateOf
|
|
|
|
|
|
|
|
import androidx.compose.runtime.remember
|
|
|
|
import androidx.compose.ui.Alignment
|
|
|
|
import androidx.compose.ui.Alignment
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
|
import androidx.compose.ui.text.font.FontWeight
|
|
|
|
import androidx.compose.ui.text.font.FontWeight
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
|
|
|
|
|
import org.mozilla.fenix.compose.annotation.LightDarkPreview
|
|
|
|
|
|
|
|
import org.mozilla.fenix.compose.button.RadioButton
|
|
|
|
|
|
|
|
import org.mozilla.fenix.theme.FirefoxTheme
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Dialogue top level card for the profiler
|
|
|
|
* Dialogue top level card for the profiler.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Composable
|
|
|
|
@Composable
|
|
|
|
fun ProfilerDialogueCard(content: @Composable () -> Unit) {
|
|
|
|
fun ProfilerDialogueCard(content: @Composable () -> Unit) {
|
|
|
@ -40,42 +44,42 @@ fun ProfilerDialogueCard(content: @Composable () -> Unit) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Top level radio button for the profiler dialogue
|
|
|
|
* Top level radio button for the profiler dialogue.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param text The main text to be displayed.
|
|
|
|
|
|
|
|
* @param subText The subtext to be displayed.
|
|
|
|
|
|
|
|
* @param selected [Boolean] that indicates whether the radio button is currently selected.
|
|
|
|
|
|
|
|
* @param onClick Invoked when the radio button is clicked.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Composable
|
|
|
|
@Composable
|
|
|
|
fun ProfilerLabeledRadioButton(
|
|
|
|
fun ProfilerLabeledRadioButton(
|
|
|
|
text: String,
|
|
|
|
text: String,
|
|
|
|
subText: String,
|
|
|
|
subText: String,
|
|
|
|
state: MutableState<String>,
|
|
|
|
selected: Boolean = false,
|
|
|
|
|
|
|
|
onClick: () -> Unit,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
Row {
|
|
|
|
Row(
|
|
|
|
|
|
|
|
modifier = Modifier.clickable { onClick() },
|
|
|
|
|
|
|
|
) {
|
|
|
|
RadioButton(
|
|
|
|
RadioButton(
|
|
|
|
selected = state.value == text,
|
|
|
|
selected = selected,
|
|
|
|
onClick = { state.value = text },
|
|
|
|
onClick = {},
|
|
|
|
enabled = true,
|
|
|
|
enabled = true,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
Column {
|
|
|
|
Column(
|
|
|
|
Text(
|
|
|
|
modifier = Modifier.padding(horizontal = 8.dp),
|
|
|
|
text = text,
|
|
|
|
) {
|
|
|
|
modifier = Modifier
|
|
|
|
Text(text = text)
|
|
|
|
.padding(start = 8.dp)
|
|
|
|
|
|
|
|
.clickable {
|
|
|
|
|
|
|
|
state.value = text
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
Text(
|
|
|
|
Text(
|
|
|
|
text = subText,
|
|
|
|
text = subText,
|
|
|
|
fontWeight = FontWeight.ExtraLight,
|
|
|
|
fontWeight = FontWeight.ExtraLight,
|
|
|
|
modifier = Modifier
|
|
|
|
|
|
|
|
.padding(start = 8.dp)
|
|
|
|
|
|
|
|
.clickable { state.value = text },
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Profiler Dialogue to display circular spinner when waiting
|
|
|
|
* Profiler Dialogue to display circular spinner when waiting.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Composable
|
|
|
|
@Composable
|
|
|
|
fun WaitForProfilerDialog(
|
|
|
|
fun WaitForProfilerDialog(
|
|
|
@ -98,3 +102,30 @@ fun WaitForProfilerDialog(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Preview example of [ProfilerLabeledRadioButton].
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
|
|
|
@LightDarkPreview
|
|
|
|
|
|
|
|
private fun ProfilerLabeledRadioButtonPreview() {
|
|
|
|
|
|
|
|
val radioOptions = listOf("Firefox", "Graphics", "Media", "Networking")
|
|
|
|
|
|
|
|
val selectedOption = remember { mutableStateOf("Firefox") }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FirefoxTheme {
|
|
|
|
|
|
|
|
Column(
|
|
|
|
|
|
|
|
modifier = Modifier.background(FirefoxTheme.colors.layer1),
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
radioOptions.forEach { text ->
|
|
|
|
|
|
|
|
ProfilerLabeledRadioButton(
|
|
|
|
|
|
|
|
text = text,
|
|
|
|
|
|
|
|
subText = "Sub",
|
|
|
|
|
|
|
|
selected = selectedOption.value == text,
|
|
|
|
|
|
|
|
onClick = {
|
|
|
|
|
|
|
|
selectedOption.value = text
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|