feat: enhance navigation behavior in MainApp and add log export functionality in LogsScreen
This commit is contained in:
@@ -70,22 +70,32 @@ fun MainApp() {
|
|||||||
NavigationBarItem(
|
NavigationBarItem(
|
||||||
selected = currentRoute == Routes.Tables || currentRoute?.startsWith("list/") == true,
|
selected = currentRoute == Routes.Tables || currentRoute?.startsWith("list/") == true,
|
||||||
onClick = {
|
onClick = {
|
||||||
navController.navigate(Routes.Tables) {
|
if (currentRoute?.startsWith("list/") == true) {
|
||||||
popUpTo(navController.graph.findStartDestination().id) { saveState = true }
|
// Behave like back from details to tables overview
|
||||||
launchSingleTop = true
|
navController.popBackStack()
|
||||||
restoreState = true
|
} else {
|
||||||
|
navController.navigate(Routes.Tables) {
|
||||||
|
popUpTo(navController.graph.findStartDestination().id) { saveState = true }
|
||||||
|
launchSingleTop = true
|
||||||
|
restoreState = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
icon = { androidx.compose.material3.Icon(Icons.Default.Home, contentDescription = null) },
|
icon = { androidx.compose.material3.Icon(Icons.Default.Home, contentDescription = null) },
|
||||||
label = { Text("Tables") },
|
label = { Text("Tables") },
|
||||||
)
|
)
|
||||||
NavigationBarItem(
|
NavigationBarItem(
|
||||||
selected = currentRoute == Routes.Settings,
|
selected = currentRoute == Routes.Settings || currentRoute == Routes.Logs,
|
||||||
onClick = {
|
onClick = {
|
||||||
navController.navigate(Routes.Settings) {
|
if (currentRoute == Routes.Logs) {
|
||||||
popUpTo(navController.graph.findStartDestination().id) { saveState = true }
|
// Behave like back from logs to settings screen
|
||||||
launchSingleTop = true
|
navController.popBackStack()
|
||||||
restoreState = true
|
} else {
|
||||||
|
navController.navigate(Routes.Settings) {
|
||||||
|
popUpTo(navController.graph.findStartDestination().id) { saveState = true }
|
||||||
|
launchSingleTop = true
|
||||||
|
restoreState = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
icon = { androidx.compose.material3.Icon(Icons.Default.Settings, contentDescription = null) },
|
icon = { androidx.compose.material3.Icon(Icons.Default.Settings, contentDescription = null) },
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import androidx.compose.material.icons.Icons
|
|||||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||||
import androidx.compose.material3.HorizontalDivider
|
import androidx.compose.material3.HorizontalDivider
|
||||||
import androidx.compose.material.icons.filled.Delete
|
import androidx.compose.material.icons.filled.Delete
|
||||||
|
import androidx.compose.material.icons.filled.Share
|
||||||
import androidx.compose.material.icons.filled.FilterList
|
import androidx.compose.material.icons.filled.FilterList
|
||||||
import androidx.compose.material3.Badge
|
import androidx.compose.material3.Badge
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
@@ -54,6 +55,8 @@ import androidx.compose.ui.unit.sp
|
|||||||
import com.collabtable.app.utils.LogEntry
|
import com.collabtable.app.utils.LogEntry
|
||||||
import com.collabtable.app.utils.LogLevel
|
import com.collabtable.app.utils.LogLevel
|
||||||
import com.collabtable.app.utils.Logger
|
import com.collabtable.app.utils.Logger
|
||||||
|
import android.content.Intent
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
|
||||||
enum class TimeRange(val label: String, val milliseconds: Long) {
|
enum class TimeRange(val label: String, val milliseconds: Long) {
|
||||||
LAST_10_SECONDS("Last 10 seconds", 10_000),
|
LAST_10_SECONDS("Last 10 seconds", 10_000),
|
||||||
@@ -126,6 +129,20 @@ fun LogsScreen(onNavigateBack: () -> Unit) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions = {
|
actions = {
|
||||||
|
// Export logs via share intent
|
||||||
|
val ctx = LocalContext.current
|
||||||
|
IconButton(onClick = {
|
||||||
|
val all = logs.joinToString(separator = "\n") { it.toFormattedString() }
|
||||||
|
val sendIntent = Intent(Intent.ACTION_SEND).apply {
|
||||||
|
type = "text/plain"
|
||||||
|
putExtra(Intent.EXTRA_TEXT, all)
|
||||||
|
putExtra(Intent.EXTRA_SUBJECT, "CollabTable Logs")
|
||||||
|
}
|
||||||
|
val chooser = Intent.createChooser(sendIntent, "Export logs")
|
||||||
|
ctx.startActivity(chooser)
|
||||||
|
}) {
|
||||||
|
Icon(Icons.Default.Share, contentDescription = "Export logs")
|
||||||
|
}
|
||||||
IconButton(onClick = { showFilterSheet = true }) {
|
IconButton(onClick = { showFilterSheet = true }) {
|
||||||
Badge(
|
Badge(
|
||||||
containerColor =
|
containerColor =
|
||||||
@@ -244,7 +261,7 @@ fun LogsScreen(onNavigateBack: () -> Unit) {
|
|||||||
modifier =
|
modifier =
|
||||||
Modifier
|
Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.background(Color(0xFF1E1E1E)),
|
.background(MaterialTheme.colorScheme.background),
|
||||||
contentPadding = PaddingValues(8.dp),
|
contentPadding = PaddingValues(8.dp),
|
||||||
) {
|
) {
|
||||||
items(filteredLogs) { log ->
|
items(filteredLogs) { log ->
|
||||||
|
|||||||
Reference in New Issue
Block a user