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