Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions composeApp/src/commonMain/kotlin/org/ooni/probe/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ fun App(
arrayOf(LocalSnackbarHostState provides snackbarHostState, it)
} ?: arrayOf(LocalSnackbarHostState provides snackbarHostState),
) {
AppTheme(
currentRoute = currentRoute,
) {
AppTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
Expand Down Expand Up @@ -54,6 +55,7 @@ import org.ooni.probe.ui.shared.UpdateProgressStatus
import org.ooni.probe.ui.shared.UpdatesChip
import org.ooni.probe.ui.shared.relativeDateTime
import org.ooni.probe.ui.shared.shortFormat
import org.ooni.probe.ui.theme.LocalCustomColors

@Composable
fun DescriptorScreen(
Expand All @@ -79,6 +81,7 @@ fun DescriptorScreen(
Box(Modifier.nestedScroll(pullToRefreshState.nestedScrollConnection)) {
Column {
val descriptorColor = descriptor.color ?: MaterialTheme.colorScheme.primary
val onDescriptorColor = LocalCustomColors.current.onDescriptor
TopAppBar(
title = {
Text(descriptor.title.invoke())
Expand All @@ -92,9 +95,11 @@ fun DescriptorScreen(
}
},
colors = TopAppBarDefaults.topAppBarColors(
titleContentColor = descriptorColor,
navigationIconContentColor = descriptorColor,
actionIconContentColor = descriptorColor,
containerColor = descriptorColor,
scrolledContainerColor = descriptorColor,
navigationIconContentColor = onDescriptorColor,
titleContentColor = onDescriptorColor,
actionIconContentColor = onDescriptorColor,
),
)

Expand All @@ -105,56 +110,61 @@ fun DescriptorScreen(
.padding(WindowInsets.navigationBars.asPaddingValues())
.padding(bottom = 32.dp),
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.fillMaxWidth()
.padding(8.dp),
Surface(
color = descriptorColor,
contentColor = onDescriptorColor,
) {
descriptor.icon?.let { icon ->
Icon(
painterResource(icon),
contentDescription = null,
tint = descriptorColor,
modifier = Modifier.size(64.dp),
)
}
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.fillMaxWidth()
.padding(8.dp),
) {
descriptor.icon?.let { icon ->
Icon(
painterResource(icon),
contentDescription = null,
tint = onDescriptorColor,
modifier = Modifier.size(64.dp),
)
}

Row {
Text(stringResource(Res.string.Dashboard_Overview_Estimated))
Row {
Text(stringResource(Res.string.Dashboard_Overview_Estimated))

descriptor.dataUsage()?.let { dataUsage ->
Text(
text = dataUsage,
fontWeight = FontWeight.Bold,
modifier = Modifier.padding(start = 8.dp),
)
descriptor.dataUsage()?.let { dataUsage ->
Text(
text = dataUsage,
fontWeight = FontWeight.Bold,
modifier = Modifier.padding(start = 8.dp),
)
}

state.estimatedTime?.let { time ->
Text(
text = "~ ${time.shortFormat()}",
fontWeight = FontWeight.Bold,
modifier = Modifier.padding(start = 8.dp),
)
}
}

state.estimatedTime?.let { time ->
Row {
Text(stringResource(Res.string.Dashboard_Overview_LatestTest))

Text(
text = "~ ${time.shortFormat()}",
text = state.lastResult?.startTime?.relativeDateTime()
?: stringResource(Res.string.Dashboard_Overview_LastRun_Never),
fontWeight = FontWeight.Bold,
modifier = Modifier.padding(start = 8.dp),
)
}
}

Row {
Text(stringResource(Res.string.Dashboard_Overview_LatestTest))

Text(
text = state.lastResult?.startTime?.relativeDateTime()
?: stringResource(Res.string.Dashboard_Overview_LastRun_Never),
fontWeight = FontWeight.Bold,
modifier = Modifier.padding(start = 8.dp),
)
}
if (descriptor.updatable) {
UpdatesChip(onClick = { })
}
state.updatedDescriptor?.let {
OutlinedButton(onClick = { onEvent(DescriptorViewModel.Event.UpdateDescriptor) }) {
Text(stringResource(Res.string.Dashboard_Runv2_Overview_ReviewUpdates))
if (descriptor.updatable) {
UpdatesChip(onClick = { })
}
state.updatedDescriptor?.let {
OutlinedButton(onClick = { onEvent(DescriptorViewModel.Event.UpdateDescriptor) }) {
Text(stringResource(Res.string.Dashboard_Runv2_Overview_ReviewUpdates))
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.jetbrains.compose.resources.stringResource
import org.ooni.probe.data.models.toDescriptor
import org.ooni.probe.ui.dashboard.TestDescriptorLabel
import org.ooni.probe.ui.run.TestItem
import org.ooni.probe.ui.shared.ColorDefaults
import org.ooni.probe.ui.shared.NotificationMessages

@Composable
Expand All @@ -48,22 +49,26 @@ fun AddDescriptorScreen(
Column(
modifier = Modifier.padding(start = 16.dp, end = 16.dp),
) {
TopAppBar(title = {
Text(stringResource(Res.string.AddDescriptor_Title))
}, actions = {
IconButton(
onClick = {
onEvent(
AddDescriptorViewModel.Event.CancelClicked,
TopAppBar(
title = {
Text(stringResource(Res.string.AddDescriptor_Title))
},
actions = {
IconButton(
onClick = {
onEvent(
AddDescriptorViewModel.Event.CancelClicked,
)
},
) {
Icon(
imageVector = Icons.Filled.Close,
contentDescription = stringResource(Res.string.Modal_Cancel),
)
},
) {
Icon(
imageVector = Icons.Filled.Close,
contentDescription = stringResource(Res.string.Modal_Cancel),
)
}
})
}
},
colors = ColorDefaults.topAppBar(),
)
Box(modifier = Modifier.padding(16.dp)) {
TestDescriptorLabel(descriptor.toDescriptor())
}
Expand Down Expand Up @@ -147,9 +152,13 @@ fun AddDescriptorScreen(
}
}
} ?: Column(
verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
) {
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(16.dp)) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(16.dp),
) {
CircularProgressIndicator()
Text(stringResource(Res.string.LoadingScreen_Runv2_Message))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import org.jetbrains.compose.resources.stringResource
import org.ooni.engine.models.TestType
import org.ooni.probe.data.models.Descriptor
import org.ooni.probe.ui.dashboard.TestDescriptorLabel
import org.ooni.probe.ui.shared.ColorDefaults

@Composable
fun ReviewUpdatesScreen(
Expand Down Expand Up @@ -59,6 +60,7 @@ fun ReviewUpdatesScreen(
)
}
},
colors = ColorDefaults.topAppBar(),
)
Box(modifier = Modifier.fillMaxHeight().padding(16.dp)) {
HorizontalPager(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import org.jetbrains.compose.resources.getString
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.resources.stringResource
import org.ooni.probe.LocalSnackbarHostState
import org.ooni.probe.ui.shared.ColorDefaults
import org.ooni.probe.ui.shared.CustomFilterChip
import org.ooni.probe.ui.theme.LocalCustomColors

Expand Down Expand Up @@ -79,6 +80,7 @@ fun LogScreen(
)
}
},
colors = ColorDefaults.topAppBar(),
)

Row(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import ooniprobe.composeapp.generated.resources.measurement
import ooniprobe.composeapp.generated.resources.refresh
import org.jetbrains.compose.resources.stringResource
import org.ooni.probe.data.models.MeasurementModel
import org.ooni.probe.ui.shared.ColorDefaults

@Composable
fun MeasurementScreen(
Expand Down Expand Up @@ -67,15 +68,16 @@ fun MeasurementScreen(
)
}
},
colors = ColorDefaults.topAppBar(),
)

LinearProgressIndicator(
progress = {
val loadingState = webViewState.loadingState
if (loadingState is LoadingState.Loading) loadingState.progress else 1f
},
color = MaterialTheme.colorScheme.background,
trackColor = MaterialTheme.colorScheme.primary,
color = MaterialTheme.colorScheme.primary,
trackColor = MaterialTheme.colorScheme.onBackground,
modifier = Modifier
.fillMaxWidth()
.height(1.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fun ResultMeasurementCell(
if (measurement.isDone && !measurement.isMissingUpload) {
clickable { onClick(measurement.reportId!!, item.url?.url) }
} else {
alpha(0.5f)
alpha(0.66f)
}
}
.padding(16.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
Expand Down Expand Up @@ -58,6 +60,7 @@ import org.ooni.probe.ui.results.UploadResults
import org.ooni.probe.ui.shared.formatDataUsage
import org.ooni.probe.ui.shared.longFormat
import org.ooni.probe.ui.shared.shortFormat
import org.ooni.probe.ui.theme.LocalCustomColors

@Composable
fun ResultScreen(
Expand All @@ -66,6 +69,7 @@ fun ResultScreen(
) {
Column {
val descriptorColor = state.result?.descriptor?.color ?: MaterialTheme.colorScheme.primary
val onDescriptorColor = LocalCustomColors.current.onDescriptor
TopAppBar(
title = {
Text(state.result?.descriptor?.title?.invoke().orEmpty())
Expand All @@ -79,15 +83,22 @@ fun ResultScreen(
}
},
colors = TopAppBarDefaults.topAppBarColors(
titleContentColor = descriptorColor,
navigationIconContentColor = descriptorColor,
actionIconContentColor = descriptorColor,
containerColor = descriptorColor,
scrolledContainerColor = descriptorColor,
navigationIconContentColor = onDescriptorColor,
titleContentColor = onDescriptorColor,
actionIconContentColor = onDescriptorColor,
),
)

if (state.result == null) return@Column

Summary(state.result)
Surface(
color = descriptorColor,
contentColor = onDescriptorColor,
) {
Summary(state.result)
}

if (state.result.anyMeasurementMissingUpload) {
UploadResults(onUploadClick = { onEvent(ResultViewModel.Event.UploadClicked) })
Expand Down Expand Up @@ -140,7 +151,7 @@ private fun Summary(item: ResultItem) {
.padding(bottom = 8.dp)
.alpha(if (pagerState.currentPage == index) 1f else 0.33f)
.clip(CircleShape)
.background(MaterialTheme.colorScheme.onSurface)
.background(LocalContentColor.current)
.size(12.dp),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import ooniprobe.composeapp.generated.resources.ooni_empty_state
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.resources.stringArrayResource
import org.jetbrains.compose.resources.stringResource
import org.ooni.probe.ui.shared.CustomColors
import org.ooni.probe.ui.shared.ColorDefaults
import org.ooni.probe.ui.shared.formatDataUsage

@Composable
Expand All @@ -89,7 +89,7 @@ fun ResultsScreen(
}
}
},
colors = CustomColors.topAppBar(),
colors = ColorDefaults.topAppBar(),
)

Surface(color = MaterialTheme.colorScheme.primaryContainer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import org.ooni.probe.data.models.Descriptor
import org.ooni.probe.data.models.NetTest
import org.ooni.probe.ui.dashboard.TestDescriptorLabel
import org.ooni.probe.ui.dashboard.TestDescriptorSection
import org.ooni.probe.ui.shared.CustomColors
import org.ooni.probe.ui.shared.ColorDefaults
import org.ooni.probe.ui.shared.ParentSelectableItem
import org.ooni.probe.ui.shared.SelectableItem

Expand All @@ -88,7 +88,7 @@ fun RunScreen(
)
}
},
colors = CustomColors.topAppBar(),
colors = ColorDefaults.topAppBar(),
)

Column(
Expand Down
Loading