Skip to content

Commit 5813c1a

Browse files
committed
Results, Settings and Descriptor UI
1 parent 811a4c8 commit 5813c1a

File tree

21 files changed

+184
-156
lines changed

21 files changed

+184
-156
lines changed

composeApp/src/commonMain/kotlin/org/ooni/probe/App.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ fun App(
4747
arrayOf(LocalSnackbarHostState provides snackbarHostState, it)
4848
} ?: arrayOf(LocalSnackbarHostState provides snackbarHostState),
4949
) {
50-
AppTheme(
51-
currentRoute = currentRoute,
52-
) {
50+
AppTheme {
5351
Surface(
5452
modifier = Modifier.fillMaxSize(),
5553
color = MaterialTheme.colorScheme.background,

composeApp/src/commonMain/kotlin/org/ooni/probe/ui/descriptor/DescriptorScreen.kt

Lines changed: 53 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import androidx.compose.material3.Icon
2020
import androidx.compose.material3.IconButton
2121
import androidx.compose.material3.MaterialTheme
2222
import androidx.compose.material3.OutlinedButton
23+
import androidx.compose.material3.Surface
2324
import androidx.compose.material3.Text
2425
import androidx.compose.material3.TopAppBar
2526
import androidx.compose.material3.TopAppBarDefaults
@@ -54,6 +55,7 @@ import org.ooni.probe.ui.shared.UpdateProgressStatus
5455
import org.ooni.probe.ui.shared.UpdatesChip
5556
import org.ooni.probe.ui.shared.relativeDateTime
5657
import org.ooni.probe.ui.shared.shortFormat
58+
import org.ooni.probe.ui.theme.LocalCustomColors
5759

5860
@Composable
5961
fun DescriptorScreen(
@@ -79,6 +81,7 @@ fun DescriptorScreen(
7981
Box(Modifier.nestedScroll(pullToRefreshState.nestedScrollConnection)) {
8082
Column {
8183
val descriptorColor = descriptor.color ?: MaterialTheme.colorScheme.primary
84+
val onDescriptorColor = LocalCustomColors.current.onDescriptor
8285
TopAppBar(
8386
title = {
8487
Text(descriptor.title.invoke())
@@ -92,9 +95,11 @@ fun DescriptorScreen(
9295
}
9396
},
9497
colors = TopAppBarDefaults.topAppBarColors(
95-
titleContentColor = descriptorColor,
96-
navigationIconContentColor = descriptorColor,
97-
actionIconContentColor = descriptorColor,
98+
containerColor = descriptorColor,
99+
scrolledContainerColor = descriptorColor,
100+
navigationIconContentColor = onDescriptorColor,
101+
titleContentColor = onDescriptorColor,
102+
actionIconContentColor = onDescriptorColor,
98103
),
99104
)
100105

@@ -105,56 +110,61 @@ fun DescriptorScreen(
105110
.padding(WindowInsets.navigationBars.asPaddingValues())
106111
.padding(bottom = 32.dp),
107112
) {
108-
Column(
109-
horizontalAlignment = Alignment.CenterHorizontally,
110-
modifier = Modifier.fillMaxWidth()
111-
.padding(8.dp),
113+
Surface(
114+
color = descriptorColor,
115+
contentColor = onDescriptorColor,
112116
) {
113-
descriptor.icon?.let { icon ->
114-
Icon(
115-
painterResource(icon),
116-
contentDescription = null,
117-
tint = descriptorColor,
118-
modifier = Modifier.size(64.dp),
119-
)
120-
}
117+
Column(
118+
horizontalAlignment = Alignment.CenterHorizontally,
119+
modifier = Modifier.fillMaxWidth()
120+
.padding(8.dp),
121+
) {
122+
descriptor.icon?.let { icon ->
123+
Icon(
124+
painterResource(icon),
125+
contentDescription = null,
126+
tint = onDescriptorColor,
127+
modifier = Modifier.size(64.dp),
128+
)
129+
}
121130

122-
Row {
123-
Text(stringResource(Res.string.Dashboard_Overview_Estimated))
131+
Row {
132+
Text(stringResource(Res.string.Dashboard_Overview_Estimated))
124133

125-
descriptor.dataUsage()?.let { dataUsage ->
126-
Text(
127-
text = dataUsage,
128-
fontWeight = FontWeight.Bold,
129-
modifier = Modifier.padding(start = 8.dp),
130-
)
134+
descriptor.dataUsage()?.let { dataUsage ->
135+
Text(
136+
text = dataUsage,
137+
fontWeight = FontWeight.Bold,
138+
modifier = Modifier.padding(start = 8.dp),
139+
)
140+
}
141+
142+
state.estimatedTime?.let { time ->
143+
Text(
144+
text = "~ ${time.shortFormat()}",
145+
fontWeight = FontWeight.Bold,
146+
modifier = Modifier.padding(start = 8.dp),
147+
)
148+
}
131149
}
132150

133-
state.estimatedTime?.let { time ->
151+
Row {
152+
Text(stringResource(Res.string.Dashboard_Overview_LatestTest))
153+
134154
Text(
135-
text = "~ ${time.shortFormat()}",
155+
text = state.lastResult?.startTime?.relativeDateTime()
156+
?: stringResource(Res.string.Dashboard_Overview_LastRun_Never),
136157
fontWeight = FontWeight.Bold,
137158
modifier = Modifier.padding(start = 8.dp),
138159
)
139160
}
140-
}
141-
142-
Row {
143-
Text(stringResource(Res.string.Dashboard_Overview_LatestTest))
144-
145-
Text(
146-
text = state.lastResult?.startTime?.relativeDateTime()
147-
?: stringResource(Res.string.Dashboard_Overview_LastRun_Never),
148-
fontWeight = FontWeight.Bold,
149-
modifier = Modifier.padding(start = 8.dp),
150-
)
151-
}
152-
if (descriptor.updatable) {
153-
UpdatesChip(onClick = { })
154-
}
155-
state.updatedDescriptor?.let {
156-
OutlinedButton(onClick = { onEvent(DescriptorViewModel.Event.UpdateDescriptor) }) {
157-
Text(stringResource(Res.string.Dashboard_Runv2_Overview_ReviewUpdates))
161+
if (descriptor.updatable) {
162+
UpdatesChip(onClick = { })
163+
}
164+
state.updatedDescriptor?.let {
165+
OutlinedButton(onClick = { onEvent(DescriptorViewModel.Event.UpdateDescriptor) }) {
166+
Text(stringResource(Res.string.Dashboard_Runv2_Overview_ReviewUpdates))
167+
}
158168
}
159169
}
160170
}

composeApp/src/commonMain/kotlin/org/ooni/probe/ui/descriptor/add/AddDescriptorScreen.kt

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import org.jetbrains.compose.resources.stringResource
3737
import org.ooni.probe.data.models.toDescriptor
3838
import org.ooni.probe.ui.dashboard.TestDescriptorLabel
3939
import org.ooni.probe.ui.run.TestItem
40+
import org.ooni.probe.ui.shared.ColorDefaults
4041
import org.ooni.probe.ui.shared.NotificationMessages
4142

4243
@Composable
@@ -48,22 +49,26 @@ fun AddDescriptorScreen(
4849
Column(
4950
modifier = Modifier.padding(start = 16.dp, end = 16.dp),
5051
) {
51-
TopAppBar(title = {
52-
Text(stringResource(Res.string.AddDescriptor_Title))
53-
}, actions = {
54-
IconButton(
55-
onClick = {
56-
onEvent(
57-
AddDescriptorViewModel.Event.CancelClicked,
52+
TopAppBar(
53+
title = {
54+
Text(stringResource(Res.string.AddDescriptor_Title))
55+
},
56+
actions = {
57+
IconButton(
58+
onClick = {
59+
onEvent(
60+
AddDescriptorViewModel.Event.CancelClicked,
61+
)
62+
},
63+
) {
64+
Icon(
65+
imageVector = Icons.Filled.Close,
66+
contentDescription = stringResource(Res.string.Modal_Cancel),
5867
)
59-
},
60-
) {
61-
Icon(
62-
imageVector = Icons.Filled.Close,
63-
contentDescription = stringResource(Res.string.Modal_Cancel),
64-
)
65-
}
66-
})
68+
}
69+
},
70+
colors = ColorDefaults.topAppBar(),
71+
)
6772
Box(modifier = Modifier.padding(16.dp)) {
6873
TestDescriptorLabel(descriptor.toDescriptor())
6974
}
@@ -147,9 +152,13 @@ fun AddDescriptorScreen(
147152
}
148153
}
149154
} ?: Column(
150-
verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally,
155+
verticalArrangement = Arrangement.Center,
156+
horizontalAlignment = Alignment.CenterHorizontally,
151157
) {
152-
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(16.dp)) {
158+
Row(
159+
verticalAlignment = Alignment.CenterVertically,
160+
horizontalArrangement = Arrangement.spacedBy(16.dp),
161+
) {
153162
CircularProgressIndicator()
154163
Text(stringResource(Res.string.LoadingScreen_Runv2_Message))
155164
}

composeApp/src/commonMain/kotlin/org/ooni/probe/ui/descriptor/review/ReviewUpdatesScreen.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import org.jetbrains.compose.resources.stringResource
3232
import org.ooni.engine.models.TestType
3333
import org.ooni.probe.data.models.Descriptor
3434
import org.ooni.probe.ui.dashboard.TestDescriptorLabel
35+
import org.ooni.probe.ui.shared.ColorDefaults
3536

3637
@Composable
3738
fun ReviewUpdatesScreen(
@@ -59,6 +60,7 @@ fun ReviewUpdatesScreen(
5960
)
6061
}
6162
},
63+
colors = ColorDefaults.topAppBar(),
6264
)
6365
Box(modifier = Modifier.fillMaxHeight().padding(16.dp)) {
6466
HorizontalPager(

composeApp/src/commonMain/kotlin/org/ooni/probe/ui/log/LogScreen.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import org.jetbrains.compose.resources.getString
4646
import org.jetbrains.compose.resources.painterResource
4747
import org.jetbrains.compose.resources.stringResource
4848
import org.ooni.probe.LocalSnackbarHostState
49+
import org.ooni.probe.ui.shared.ColorDefaults
4950
import org.ooni.probe.ui.shared.CustomFilterChip
5051
import org.ooni.probe.ui.theme.LocalCustomColors
5152

@@ -79,6 +80,7 @@ fun LogScreen(
7980
)
8081
}
8182
},
83+
colors = ColorDefaults.topAppBar(),
8284
)
8385

8486
Row(

composeApp/src/commonMain/kotlin/org/ooni/probe/ui/measurement/MeasurementScreen.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import ooniprobe.composeapp.generated.resources.measurement
3030
import ooniprobe.composeapp.generated.resources.refresh
3131
import org.jetbrains.compose.resources.stringResource
3232
import org.ooni.probe.data.models.MeasurementModel
33+
import org.ooni.probe.ui.shared.ColorDefaults
3334

3435
@Composable
3536
fun MeasurementScreen(
@@ -67,15 +68,16 @@ fun MeasurementScreen(
6768
)
6869
}
6970
},
71+
colors = ColorDefaults.topAppBar(),
7072
)
7173

7274
LinearProgressIndicator(
7375
progress = {
7476
val loadingState = webViewState.loadingState
7577
if (loadingState is LoadingState.Loading) loadingState.progress else 1f
7678
},
77-
color = MaterialTheme.colorScheme.background,
78-
trackColor = MaterialTheme.colorScheme.primary,
79+
color = MaterialTheme.colorScheme.primary,
80+
trackColor = MaterialTheme.colorScheme.onBackground,
7981
modifier = Modifier
8082
.fillMaxWidth()
8183
.height(1.dp),

composeApp/src/commonMain/kotlin/org/ooni/probe/ui/result/ResultMeasurementCell.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fun ResultMeasurementCell(
4646
if (measurement.isDone && !measurement.isMissingUpload) {
4747
clickable { onClick(measurement.reportId!!, item.url?.url) }
4848
} else {
49-
alpha(0.5f)
49+
alpha(0.66f)
5050
}
5151
}
5252
.padding(16.dp),

composeApp/src/commonMain/kotlin/org/ooni/probe/ui/result/ResultScreen.kt

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ import androidx.compose.material.icons.Icons
2222
import androidx.compose.material.icons.automirrored.filled.ArrowBack
2323
import androidx.compose.material3.Icon
2424
import androidx.compose.material3.IconButton
25+
import androidx.compose.material3.LocalContentColor
2526
import androidx.compose.material3.MaterialTheme
27+
import androidx.compose.material3.Surface
2628
import androidx.compose.material3.Text
2729
import androidx.compose.material3.TopAppBar
2830
import androidx.compose.material3.TopAppBarDefaults
@@ -58,6 +60,7 @@ import org.ooni.probe.ui.results.UploadResults
5860
import org.ooni.probe.ui.shared.formatDataUsage
5961
import org.ooni.probe.ui.shared.longFormat
6062
import org.ooni.probe.ui.shared.shortFormat
63+
import org.ooni.probe.ui.theme.LocalCustomColors
6164

6265
@Composable
6366
fun ResultScreen(
@@ -66,6 +69,7 @@ fun ResultScreen(
6669
) {
6770
Column {
6871
val descriptorColor = state.result?.descriptor?.color ?: MaterialTheme.colorScheme.primary
72+
val onDescriptorColor = LocalCustomColors.current.onDescriptor
6973
TopAppBar(
7074
title = {
7175
Text(state.result?.descriptor?.title?.invoke().orEmpty())
@@ -79,15 +83,22 @@ fun ResultScreen(
7983
}
8084
},
8185
colors = TopAppBarDefaults.topAppBarColors(
82-
titleContentColor = descriptorColor,
83-
navigationIconContentColor = descriptorColor,
84-
actionIconContentColor = descriptorColor,
86+
containerColor = descriptorColor,
87+
scrolledContainerColor = descriptorColor,
88+
navigationIconContentColor = onDescriptorColor,
89+
titleContentColor = onDescriptorColor,
90+
actionIconContentColor = onDescriptorColor,
8591
),
8692
)
8793

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

90-
Summary(state.result)
96+
Surface(
97+
color = descriptorColor,
98+
contentColor = onDescriptorColor,
99+
) {
100+
Summary(state.result)
101+
}
91102

92103
if (state.result.anyMeasurementMissingUpload) {
93104
UploadResults(onUploadClick = { onEvent(ResultViewModel.Event.UploadClicked) })
@@ -140,7 +151,7 @@ private fun Summary(item: ResultItem) {
140151
.padding(bottom = 8.dp)
141152
.alpha(if (pagerState.currentPage == index) 1f else 0.33f)
142153
.clip(CircleShape)
143-
.background(MaterialTheme.colorScheme.onSurface)
154+
.background(LocalContentColor.current)
144155
.size(12.dp),
145156
)
146157
}

composeApp/src/commonMain/kotlin/org/ooni/probe/ui/results/ResultsScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ import ooniprobe.composeapp.generated.resources.ooni_empty_state
6464
import org.jetbrains.compose.resources.painterResource
6565
import org.jetbrains.compose.resources.stringArrayResource
6666
import org.jetbrains.compose.resources.stringResource
67-
import org.ooni.probe.ui.shared.CustomColors
67+
import org.ooni.probe.ui.shared.ColorDefaults
6868
import org.ooni.probe.ui.shared.formatDataUsage
6969

7070
@Composable
@@ -89,7 +89,7 @@ fun ResultsScreen(
8989
}
9090
}
9191
},
92-
colors = CustomColors.topAppBar(),
92+
colors = ColorDefaults.topAppBar(),
9393
)
9494

9595
Surface(color = MaterialTheme.colorScheme.primaryContainer) {

composeApp/src/commonMain/kotlin/org/ooni/probe/ui/run/RunScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ import org.ooni.probe.data.models.Descriptor
6666
import org.ooni.probe.data.models.NetTest
6767
import org.ooni.probe.ui.dashboard.TestDescriptorLabel
6868
import org.ooni.probe.ui.dashboard.TestDescriptorSection
69-
import org.ooni.probe.ui.shared.CustomColors
69+
import org.ooni.probe.ui.shared.ColorDefaults
7070
import org.ooni.probe.ui.shared.ParentSelectableItem
7171
import org.ooni.probe.ui.shared.SelectableItem
7272

@@ -88,7 +88,7 @@ fun RunScreen(
8888
)
8989
}
9090
},
91-
colors = CustomColors.topAppBar(),
91+
colors = ColorDefaults.topAppBar(),
9292
)
9393

9494
Column(

0 commit comments

Comments
 (0)