mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat: implement PacketResponseState.Loading (#630)
This commit is contained in:
parent
7d1d793fb9
commit
70f7ffb5fc
3 changed files with 133 additions and 39 deletions
|
|
@ -31,11 +31,11 @@ fun EditDeviceProfileDialog(
|
|||
onDismissRequest: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
var longNameInput by remember { mutableStateOf(deviceProfile.hasLongName()) }
|
||||
var shortNameInput by remember { mutableStateOf(deviceProfile.hasShortName()) }
|
||||
var channelUrlInput by remember { mutableStateOf(deviceProfile.hasChannelUrl()) }
|
||||
var configInput by remember { mutableStateOf(deviceProfile.hasConfig()) }
|
||||
var moduleConfigInput by remember { mutableStateOf(deviceProfile.hasModuleConfig()) }
|
||||
var longNameInput by remember(deviceProfile) { mutableStateOf(deviceProfile.hasLongName()) }
|
||||
var shortNameInput by remember(deviceProfile) { mutableStateOf(deviceProfile.hasShortName()) }
|
||||
var channelUrlInput by remember(deviceProfile) { mutableStateOf(deviceProfile.hasChannelUrl()) }
|
||||
var configInput by remember(deviceProfile) { mutableStateOf(deviceProfile.hasConfig()) }
|
||||
var moduleConfigInput by remember(deviceProfile) { mutableStateOf(deviceProfile.hasModuleConfig()) }
|
||||
|
||||
AlertDialog(
|
||||
title = { Text(title) },
|
||||
|
|
|
|||
|
|
@ -0,0 +1,69 @@
|
|||
package com.geeksville.mesh.ui.components.config
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.AlertDialog
|
||||
import androidx.compose.material.Button
|
||||
import androidx.compose.material.LinearProgressIndicator
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.geeksville.mesh.R
|
||||
import com.geeksville.mesh.ui.PacketResponseState
|
||||
|
||||
@Composable
|
||||
fun PacketResponseStateDialog(
|
||||
state: PacketResponseState.Loading,
|
||||
onDismiss: () -> Unit
|
||||
) {
|
||||
val progress = state.completed.toFloat() / state.total.toFloat()
|
||||
AlertDialog(
|
||||
onDismissRequest = { },
|
||||
text = {
|
||||
Column(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text("%.0f%%".format(progress * 100))
|
||||
LinearProgressIndicator(
|
||||
progress = progress,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 8.dp),
|
||||
color = MaterialTheme.colors.onSurface,
|
||||
)
|
||||
}
|
||||
},
|
||||
buttons = {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.Center
|
||||
) {
|
||||
Button(
|
||||
onClick = onDismiss,
|
||||
modifier = Modifier.padding(bottom = 16.dp)
|
||||
) { Text(stringResource(R.string.cancel)) }
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
fun PacketResponseStateDialogPreview() {
|
||||
PacketResponseStateDialog(
|
||||
state = PacketResponseState.Loading.apply {
|
||||
total = 17
|
||||
completed = 5
|
||||
},
|
||||
onDismiss = { }
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue