feat: add feedback when publishing KeyPackage on Marmot Groups screen
The publish KeyPackage button had no visual feedback, making it unclear whether anything happened. Added a Snackbar to confirm success or show errors, disabled the button during publishing, and updated the hint text to direct users to the key icon. https://claude.ai/code/session_013dhfy18dfuSYN8khXiLLBb
This commit is contained in:
+16
-2
@@ -41,6 +41,8 @@ import androidx.compose.material3.Icon
|
|||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
|
import androidx.compose.material3.SnackbarHost
|
||||||
|
import androidx.compose.material3.SnackbarHostState
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TopAppBar
|
import androidx.compose.material3.TopAppBar
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@@ -72,6 +74,8 @@ fun MarmotGroupListScreen(
|
|||||||
) {
|
) {
|
||||||
var groupList by remember { mutableStateOf(listOf<Pair<HexKey, MarmotGroupChatroom>>()) }
|
var groupList by remember { mutableStateOf(listOf<Pair<HexKey, MarmotGroupChatroom>>()) }
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
val snackbarHostState = remember { SnackbarHostState() }
|
||||||
|
var isPublishing by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
// Load group list
|
// Load group list
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
@@ -99,9 +103,18 @@ fun MarmotGroupListScreen(
|
|||||||
title = { Text("Marmot Groups") },
|
title = { Text("Marmot Groups") },
|
||||||
actions = {
|
actions = {
|
||||||
IconButton(
|
IconButton(
|
||||||
|
enabled = !isPublishing,
|
||||||
onClick = {
|
onClick = {
|
||||||
|
isPublishing = true
|
||||||
scope.launch(Dispatchers.IO) {
|
scope.launch(Dispatchers.IO) {
|
||||||
accountViewModel.publishMarmotKeyPackage()
|
try {
|
||||||
|
accountViewModel.publishMarmotKeyPackage()
|
||||||
|
snackbarHostState.showSnackbar("KeyPackage published successfully")
|
||||||
|
} catch (e: Exception) {
|
||||||
|
snackbarHostState.showSnackbar("Failed to publish KeyPackage: ${e.message}")
|
||||||
|
} finally {
|
||||||
|
isPublishing = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
@@ -113,6 +126,7 @@ fun MarmotGroupListScreen(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
snackbarHost = { SnackbarHost(snackbarHostState) },
|
||||||
floatingActionButton = {
|
floatingActionButton = {
|
||||||
FloatingActionButton(onClick = { nav.nav(Route.CreateMarmotGroup) }) {
|
FloatingActionButton(onClick = { nav.nav(Route.CreateMarmotGroup) }) {
|
||||||
Icon(Icons.Default.Add, contentDescription = "Create Group")
|
Icon(Icons.Default.Add, contentDescription = "Create Group")
|
||||||
@@ -130,7 +144,7 @@ fun MarmotGroupListScreen(
|
|||||||
style = MaterialTheme.typography.titleMedium,
|
style = MaterialTheme.typography.titleMedium,
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
"Publish your KeyPackage to receive invitations.",
|
"Tap the key icon above to publish your KeyPackage and receive invitations.",
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
modifier = Modifier.padding(top = 4.dp),
|
modifier = Modifier.padding(top = 4.dp),
|
||||||
|
|||||||
Reference in New Issue
Block a user