添加拼图底部导航条目
This commit is contained in:
@@ -10,6 +10,7 @@ import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.CameraAlt
|
||||
import androidx.compose.material.icons.filled.PhotoLibrary
|
||||
import androidx.compose.material.icons.filled.Settings
|
||||
import androidx.compose.material.icons.filled.GridView
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.NavigationBar
|
||||
import androidx.compose.material3.NavigationBarItem
|
||||
@@ -22,6 +23,8 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.inspection.camera.R
|
||||
import androidx.navigation.NavHostController
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
@@ -54,8 +57,8 @@ class MainActivity : ComponentActivity() {
|
||||
sealed class Screen(val route: String, val title: String, val icon: ImageVector) {
|
||||
data object Camera : Screen("camera", "相机", Icons.Default.CameraAlt)
|
||||
data object Gallery : Screen("gallery", "相册", Icons.Default.PhotoLibrary)
|
||||
data object Merge : Screen("merge", "拼图", Icons.Default.GridView)
|
||||
data object Settings : Screen("settings", "设置", Icons.Default.Settings)
|
||||
data object Merge : Screen("merge", "合成", Icons.Default.CameraAlt)
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -69,11 +72,11 @@ fun MainApp(preferencesManager: PreferencesManager) {
|
||||
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
||||
val currentRoute = navBackStackEntry?.destination?.route
|
||||
|
||||
if (currentRoute in listOf(Screen.Camera.route, Screen.Gallery.route, Screen.Settings.route)) {
|
||||
if (currentRoute in listOf(Screen.Camera.route, Screen.Gallery.route, Screen.Merge.route, Screen.Settings.route)) {
|
||||
NavigationBar {
|
||||
NavigationBarItem(
|
||||
icon = { Icon(Icons.Default.CameraAlt, contentDescription = "相机") },
|
||||
label = { Text("相机") },
|
||||
label = { Text(stringResource(R.string.camera)) },
|
||||
selected = currentRoute == Screen.Camera.route,
|
||||
onClick = {
|
||||
navController.navigate(Screen.Camera.route) {
|
||||
@@ -83,7 +86,7 @@ fun MainApp(preferencesManager: PreferencesManager) {
|
||||
)
|
||||
NavigationBarItem(
|
||||
icon = { Icon(Icons.Default.PhotoLibrary, contentDescription = "相册") },
|
||||
label = { Text("相册") },
|
||||
label = { Text(stringResource(R.string.gallery)) },
|
||||
selected = currentRoute == Screen.Gallery.route,
|
||||
onClick = {
|
||||
navController.navigate(Screen.Gallery.route) {
|
||||
@@ -91,9 +94,19 @@ fun MainApp(preferencesManager: PreferencesManager) {
|
||||
}
|
||||
}
|
||||
)
|
||||
NavigationBarItem(
|
||||
icon = { Icon(Icons.Default.GridView, contentDescription = "拼图") },
|
||||
label = { Text(stringResource(R.string.puzzle)) },
|
||||
selected = currentRoute == Screen.Merge.route,
|
||||
onClick = {
|
||||
navController.navigate(Screen.Merge.route) {
|
||||
popUpTo(Screen.Camera.route)
|
||||
}
|
||||
}
|
||||
)
|
||||
NavigationBarItem(
|
||||
icon = { Icon(Icons.Default.Settings, contentDescription = "设置") },
|
||||
label = { Text("设置") },
|
||||
label = { Text(stringResource(R.string.settings)) },
|
||||
selected = currentRoute == Screen.Settings.route,
|
||||
onClick = {
|
||||
navController.navigate(Screen.Settings.route) {
|
||||
|
||||
@@ -308,15 +308,7 @@ private fun CameraContent(
|
||||
modifier = Modifier.fillMaxSize()
|
||||
)
|
||||
|
||||
// 顶部栏
|
||||
TopControls(
|
||||
flashMode = flashMode,
|
||||
onFlashModeChange = onFlashModeChange,
|
||||
onSettingsClick = onSettingsClick,
|
||||
modifier = Modifier.align(Alignment.TopCenter)
|
||||
)
|
||||
|
||||
// 底部控制栏
|
||||
// 底部控制栏 - 只保留拍照按钮(其他功能在底部导航栏)
|
||||
BottomControls(
|
||||
capturedCount = capturedCount,
|
||||
imageCapture = imageCapture,
|
||||
@@ -383,56 +375,22 @@ private fun BottomControls(
|
||||
.padding(24.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceEvenly,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
// 只保留中间的拍照按钮
|
||||
FloatingActionButton(
|
||||
onClick = { imageCapture?.let { onCapture(it) } },
|
||||
modifier = Modifier.size(72.dp),
|
||||
containerColor = Color.White,
|
||||
shape = CircleShape
|
||||
) {
|
||||
IconButton(onClick = onGalleryClick) {
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.LocationOn,
|
||||
contentDescription = "相册",
|
||||
tint = Color.White
|
||||
)
|
||||
Text(text = "相册", style = MaterialTheme.typography.labelSmall, color = Color.White)
|
||||
}
|
||||
}
|
||||
|
||||
FloatingActionButton(
|
||||
onClick = { imageCapture?.let { onCapture(it) } },
|
||||
modifier = Modifier.size(72.dp),
|
||||
containerColor = Color.White,
|
||||
shape = CircleShape
|
||||
) {
|
||||
if (isCapturing) {
|
||||
CircularProgressIndicator(modifier = Modifier.size(32.dp))
|
||||
} else {
|
||||
Icon(
|
||||
imageVector = Icons.Default.CameraAlt,
|
||||
contentDescription = "拍照",
|
||||
tint = Color.Black,
|
||||
modifier = Modifier.size(32.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
IconButton(
|
||||
onClick = onMergeClick,
|
||||
enabled = capturedCount > 0
|
||||
) {
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Close,
|
||||
contentDescription = "合成",
|
||||
tint = if (capturedCount > 0) Color.White else Color.Gray
|
||||
)
|
||||
Text(
|
||||
text = "合成($capturedCount)",
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = if (capturedCount > 0) Color.White else Color.Gray
|
||||
)
|
||||
}
|
||||
if (isCapturing) {
|
||||
CircularProgressIndicator(modifier = Modifier.size(32.dp))
|
||||
} else {
|
||||
Icon(
|
||||
imageVector = Icons.Default.CameraAlt,
|
||||
contentDescription = "拍照",
|
||||
tint = Color.Black,
|
||||
modifier = Modifier.size(32.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user