1、首页优化,用工程模式,减少代码冗余度
This commit is contained in:
shenzuqiang 2026-03-12 14:14:58 +08:00
parent ba6190c95f
commit fe4f5b9ce1
4 changed files with 206 additions and 722 deletions

View File

@ -4,5 +4,8 @@ data class UIItemBean(
val id: Int,
val name: String,
val icon: Int,
val route: String
val route: String,
val resize: String = "",
val with: Float = 0f,
val height: Float = 0f
)

View File

@ -67,8 +67,8 @@ object CommonData {
// 定义尺寸列表
val resizes = mutableListOf<ResizeBean>().apply {
add(ResizeBean(id = 0, size = "23x35mm", title = "标准一寸", width = 25f, height = 35f))
add(ResizeBean(id = 1, size = "22x23mm", title = "小一寸", width = 22f, height = 32f))
add(ResizeBean(id = 0, size = "25x35mm", title = "标准一寸", width = 25f, height = 35f))
add(ResizeBean(id = 1, size = "22x32mm", title = "小一寸", width = 22f, height = 32f))
add(ResizeBean(id = 2, size = "35x53mm", title = "标准二寸", width = 35f, height = 53f))
add(ResizeBean(id = 3, size = "33x48mm", title = "小二寸", width = 33f, height = 48f))
add(ResizeBean(id = 4, size = "26x32mm", title = "身份证", width = 26f, height = 32f))

View File

@ -49,7 +49,6 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavController
import androidx.navigation.NavHostController
import androidx.navigation.compose.currentBackStackEntryAsState
@ -73,6 +72,7 @@ import io.dcloud.feature.sdk.DCUniMPSDK
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import org.json.JSONObject
import kotlin.collections.chunked
@SuppressLint("UnrememberedMutableState", "MutableCollectionMutableState")
@Composable
@ -87,7 +87,33 @@ fun HomeScreen(
val context = LocalContext.current
val scope: CoroutineScope = rememberCoroutineScope()
val progressPair = remember { mutableStateMapOf<String, Float>() }
//选尺寸制作
val sizeItems = mutableListOf<UIItemBean>().apply {
add(UIItemBean(id = 1, name = "标准一寸", icon = R.mipmap.ic_home_size_bg, route = ScreenRoute.Cutout.route, resize = "25x35mm", with = 25f, height = 35f))
add(UIItemBean(id = 2, name = "小一寸", icon = R.mipmap.ic_home_size_bg, route = ScreenRoute.Cutout.route, resize = "22x32mm", with = 22f, height = 32f))
add(UIItemBean(id = 3, name = "标准二寸", icon = R.mipmap.ic_home_size_bg, route = ScreenRoute.Cutout.route, resize = "35x53mm", with = 35f, height = 53f))
add(UIItemBean(id = 4, name = "小二寸", icon = R.mipmap.ic_home_size_bg, route = ScreenRoute.Cutout.route, resize = "33x48mm", with = 33f, height = 48f))
}
//每排展示2个
val sizeColumnsCount = 2
val sizeRow = sizeItems.chunked(sizeColumnsCount)
//选证件制作
val certificateItems = mutableListOf<UIItemBean>().apply {
add(UIItemBean(id = 1, name = "身份证", icon = R.mipmap.ic_home_certificate_bg, route = ScreenRoute.Cutout.route, resize = "26x32mm", with = 26f, height = 32f))
add(UIItemBean(id = 2, name = "护照", icon = R.mipmap.ic_home_certificate_bg, route = ScreenRoute.Cutout.route, resize = "33x48mm", with = 33f, height = 48f))
add(UIItemBean(id = 3, name = "驾驶证", icon = R.mipmap.ic_home_certificate_bg, route = ScreenRoute.Cutout.route, resize = "22x32mm", with = 22f, height = 32f))
add(UIItemBean(id = 4, name = "社保卡", icon = R.mipmap.ic_home_certificate_bg, route = ScreenRoute.Cutout.route, resize = "26x32mm", with = 26f, height = 32f))
add(UIItemBean(id = 5, name = "四六级", icon = R.mipmap.ic_home_certificate_bg, route = ScreenRoute.Cutout.route, resize = "26x32mm", with = 26f, height = 32f))
add(UIItemBean(id = 6, name = "司法考试", icon = R.mipmap.ic_home_certificate_bg, route = ScreenRoute.Cutout.route, resize = "33x48mm", with = 33f, height = 48f))
add(UIItemBean(id = 7, name = "结婚证", icon = R.mipmap.ic_home_certificate_bg, route = ScreenRoute.Cutout.route, resize = "40x60mm", with = 40f, height = 60f))
add(UIItemBean(id = 8, name = "中国签证", icon = R.mipmap.ic_home_certificate_bg, route = ScreenRoute.Cutout.route, resize = "35x45mm", with = 35f, height = 45f))
}
//每排展示4个
val certificateColumnsCount = 4
val certificateRow = certificateItems.chunked(certificateColumnsCount)
//其他
val otherItems = mutableListOf<UIItemBean>().apply {
add(UIItemBean(id = 1, name = "拼长图", icon = R.mipmap.ic_home_other_1_puzzle, route = ScreenRoute.LongImage.route))
add(UIItemBean(id = 2, name = "格式转换", icon = R.mipmap.ic_home_other_2_format, route = ScreenRoute.Format.route))
@ -422,7 +448,7 @@ fun HomeScreen(
}
}
}
//选尺寸制作
//选尺寸制作(标题)
item {
Column(
modifier = Modifier
@ -438,263 +464,19 @@ fun HomeScreen(
.wrapContentWidth()
.padding(start = 16.dp, end = 16.dp, top = 12.dp)
)
Row(
modifier = Modifier
.fillMaxWidth()
.padding(start = 16.dp, end = 16.dp, top = 12.dp)
) {
Box(
modifier = Modifier
.wrapContentWidth()
.weight(1f)
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() }
) {
// 隐藏TabBar
generalViewModel.setNavigationBarVisible(false)
// 跳转抠图页面
navController.apply {
currentBackStackEntry?.savedStateHandle?.set("width", 25f)
currentBackStackEntry?.savedStateHandle?.set("height", 35f)
navigate(ScreenRoute.Cutout.route)
}
}
){
Image(
painter = painterResource(id = R.mipmap.ic_home_size_bg),
modifier = Modifier
.fillMaxWidth()
.aspectRatio(166 / 68f),
contentDescription = null,
)
Row(
modifier = Modifier
.fillMaxWidth()
.align(Alignment.Center)
) {
Box(
modifier = Modifier
.fillMaxWidth()
.weight(0.25f)
)
Column(
modifier = Modifier
.wrapContentSize()
.weight(0.75f)
) {
Text(
text = "标准一寸",
fontSize = 14.sp,
fontWeight = FontWeight.Bold,
color = Color(0xFF1A1A1A),
modifier = Modifier.wrapContentSize()
)
Text(
text = "25x35mm",
fontSize = 10.sp,
fontWeight = FontWeight.Normal,
color = Color(0xFF767676),
modifier = Modifier.wrapContentSize()
)
}
}
}
Box(
modifier = Modifier
.width(10.dp)
)
Box(
modifier = Modifier
.wrapContentWidth()
.weight(1f)
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() }
) {
// 隐藏TabBar
generalViewModel.setNavigationBarVisible(false)
// 跳转抠图页面
navController.apply {
currentBackStackEntry?.savedStateHandle?.set("width", 22f)
currentBackStackEntry?.savedStateHandle?.set("height", 32f)
navigate(ScreenRoute.Cutout.route)
}
}
){
Image(
painter = painterResource(id = R.mipmap.ic_home_size_bg),
modifier = Modifier
.fillMaxWidth()
.aspectRatio(166 / 68f),
contentDescription = null,
)
Row(
modifier = Modifier
.fillMaxWidth()
.align(Alignment.Center)
) {
Box(
modifier = Modifier
.fillMaxWidth()
.weight(0.25f)
)
Column(
modifier = Modifier
.wrapContentSize()
.weight(0.75f)
) {
Text(
text = "小一寸",
fontSize = 14.sp,
fontWeight = FontWeight.Bold,
color = Color(0xFF1A1A1A),
modifier = Modifier.wrapContentSize()
)
Text(
text = "22x32mm",
fontSize = 10.sp,
fontWeight = FontWeight.Normal,
color = Color(0xFF767676),
modifier = Modifier.wrapContentSize()
)
}
}
}
}
Row(
modifier = Modifier
.fillMaxWidth()
.padding(start = 16.dp, end = 16.dp, top = 12.dp)
) {
Box(
modifier = Modifier
.wrapContentWidth()
.weight(1f)
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() }
) {
// 隐藏TabBar
generalViewModel.setNavigationBarVisible(false)
// 跳转抠图页面
navController.apply {
currentBackStackEntry?.savedStateHandle?.set("width", 35f)
currentBackStackEntry?.savedStateHandle?.set("height", 53f)
navigate(ScreenRoute.Cutout.route)
}
}
){
Image(
painter = painterResource(id = R.mipmap.ic_home_size_bg),
modifier = Modifier
.fillMaxWidth()
.aspectRatio(166 / 68f),
contentDescription = null,
)
Row(
modifier = Modifier
.fillMaxWidth()
.align(Alignment.Center)
) {
Box(
modifier = Modifier
.fillMaxWidth()
.weight(0.25f)
)
Column(
modifier = Modifier
.wrapContentSize()
.weight(0.75f)
) {
Text(
text = "标准二寸",
fontSize = 14.sp,
fontWeight = FontWeight.Bold,
color = Color(0xFF1A1A1A),
modifier = Modifier.wrapContentSize()
)
Text(
text = "35x53mm",
fontSize = 10.sp,
fontWeight = FontWeight.Normal,
color = Color(0xFF767676),
modifier = Modifier.wrapContentSize()
)
}
}
}
Box(
modifier = Modifier
.width(10.dp)
)
Box(
modifier = Modifier
.wrapContentWidth()
.weight(1f)
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() }
) {
// 隐藏TabBar
generalViewModel.setNavigationBarVisible(false)
// 跳转抠图页面
navController.apply {
currentBackStackEntry?.savedStateHandle?.set("width", 33f)
currentBackStackEntry?.savedStateHandle?.set("height", 48f)
navigate(ScreenRoute.Cutout.route)
}
}
){
Image(
painter = painterResource(id = R.mipmap.ic_home_size_bg),
modifier = Modifier
.fillMaxWidth()
.aspectRatio(166 / 68f),
contentDescription = null,
)
Row(
modifier = Modifier
.fillMaxWidth()
.align(Alignment.Center)
) {
Box(
modifier = Modifier
.fillMaxWidth()
.weight(0.25f)
)
Column(
modifier = Modifier
.wrapContentSize()
.weight(0.75f)
) {
Text(
text = "小二寸",
fontSize = 14.sp,
fontWeight = FontWeight.Bold,
color = Color(0xFF1A1A1A),
modifier = Modifier.wrapContentSize()
)
Text(
text = "33x48mm",
fontSize = 10.sp,
fontWeight = FontWeight.Normal,
color = Color(0xFF767676),
modifier = Modifier.wrapContentSize()
)
}
}
}
}
}
}
//选证件制作
//选尺寸制作(内容)
items (sizeRow){
Column(
modifier = Modifier
.fillMaxWidth()
.offset(y = (-36).dp)
) {
SizeItems(navController, generalViewModel, it)
}
}
//选证件制作(标题)
item {
//选证件制作
Column(
@ -710,467 +492,17 @@ fun HomeScreen(
.wrapContentWidth()
.padding(start = 16.dp, end = 16.dp, top = 18.dp)
)
Row(
modifier = Modifier
.fillMaxWidth()
.padding(start = 16.dp, end = 16.dp, top = 12.dp)
){
Box(
modifier = Modifier
.wrapContentWidth()
.weight(1f)
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() }
) {
// 隐藏TabBar
generalViewModel.setNavigationBarVisible(false)
// 跳转抠图页面
navController.apply {
currentBackStackEntry?.savedStateHandle?.set("width", 26f)
currentBackStackEntry?.savedStateHandle?.set("height", 32f)
navigate(ScreenRoute.Cutout.route)
}
}
) {
Image(
painter = painterResource(id = R.mipmap.ic_home_certificate_bg),
modifier = Modifier
.fillMaxWidth()
.aspectRatio(80f / 50f),
contentDescription = null,
)
Column(
modifier = Modifier
.fillMaxWidth()
.align(Alignment.Center)
) {
Text(
text = "身份证",
fontSize = 12.sp,
fontWeight = FontWeight.Bold,
color = Color(0xFF1A1A1A),
lineHeight = 12.sp,
modifier = Modifier
.wrapContentSize()
.align(Alignment.CenterHorizontally)
)
Text(
text = "26x32mm",
fontSize = 10.sp,
fontWeight = FontWeight.Normal,
lineHeight = 10.sp,
color = Color(0xFFAAAAAA),
modifier = Modifier
.wrapContentSize()
.align(Alignment.CenterHorizontally)
)
}
}
Box(
modifier = Modifier
.width(8.dp)
)
Box(
modifier = Modifier
.wrapContentWidth()
.weight(1f)
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() }
) {
// 隐藏TabBar
generalViewModel.setNavigationBarVisible(false)
// 跳转抠图页面
navController.apply {
currentBackStackEntry?.savedStateHandle?.set("width", 33f)
currentBackStackEntry?.savedStateHandle?.set("height", 48f)
navigate(ScreenRoute.Cutout.route)
}
}
) {
Image(
painter = painterResource(id = R.mipmap.ic_home_certificate_bg),
modifier = Modifier
.fillMaxWidth()
.aspectRatio(80f / 50f),
contentDescription = null,
)
Column(
modifier = Modifier
.fillMaxWidth()
.align(Alignment.Center)
) {
Text(
text = "护照",
fontSize = 12.sp,
fontWeight = FontWeight.Bold,
lineHeight = 12.sp,
color = Color(0xFF1A1A1A),
modifier = Modifier
.wrapContentSize()
.align(Alignment.CenterHorizontally)
)
Text(
text = "33x48mm",
fontSize = 10.sp,
fontWeight = FontWeight.Normal,
lineHeight = 10.sp,
color = Color(0xFFAAAAAA),
modifier = Modifier
.wrapContentSize()
.align(Alignment.CenterHorizontally)
)
}
}
Box(
modifier = Modifier
.width(8.dp)
)
Box(
modifier = Modifier
.wrapContentWidth()
.weight(1f)
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() }
) {
// 隐藏TabBar
generalViewModel.setNavigationBarVisible(false)
// 跳转抠图页面
navController.apply {
currentBackStackEntry?.savedStateHandle?.set("width", 22f)
currentBackStackEntry?.savedStateHandle?.set("height", 32f)
navigate(ScreenRoute.Cutout.route)
}
}
) {
Image(
painter = painterResource(id = R.mipmap.ic_home_certificate_bg),
modifier = Modifier
.fillMaxWidth()
.aspectRatio(80f / 50f),
contentDescription = null,
)
Column(
modifier = Modifier
.fillMaxWidth()
.align(Alignment.Center)
) {
Text(
text = "驾驶证",
fontSize = 12.sp,
fontWeight = FontWeight.Bold,
lineHeight = 12.sp,
color = Color(0xFF1A1A1A),
modifier = Modifier
.wrapContentSize()
.align(Alignment.CenterHorizontally)
)
Text(
text = "22x32mm",
fontSize = 10.sp,
fontWeight = FontWeight.Normal,
lineHeight = 10.sp,
color = Color(0xFFAAAAAA),
modifier = Modifier
.wrapContentSize()
.align(Alignment.CenterHorizontally)
)
}
}
Box(
modifier = Modifier
.width(8.dp)
)
Box(
modifier = Modifier
.wrapContentWidth()
.weight(1f)
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() }
) {
// 隐藏TabBar
generalViewModel.setNavigationBarVisible(false)
// 跳转抠图页面
navController.apply {
currentBackStackEntry?.savedStateHandle?.set("width", 26f)
currentBackStackEntry?.savedStateHandle?.set("height", 32f)
navigate(ScreenRoute.Cutout.route)
}
}
) {
Image(
painter = painterResource(id = R.mipmap.ic_home_certificate_bg),
modifier = Modifier
.fillMaxWidth()
.aspectRatio(80f / 50f),
contentDescription = null,
)
Column(
modifier = Modifier
.fillMaxWidth()
.align(Alignment.Center)
) {
Text(
text = "社保卡",
fontSize = 12.sp,
fontWeight = FontWeight.Bold,
lineHeight = 12.sp,
color = Color(0xFF1A1A1A),
modifier = Modifier
.wrapContentSize()
.align(Alignment.CenterHorizontally)
)
Text(
text = "26x32mm",
fontSize = 10.sp,
fontWeight = FontWeight.Normal,
lineHeight = 10.sp,
color = Color(0xFFAAAAAA),
modifier = Modifier
.wrapContentSize()
.align(Alignment.CenterHorizontally)
)
}
}
}
Row(
modifier = Modifier
.fillMaxWidth()
.padding(start = 16.dp, end = 16.dp, top = 12.dp)
){
Box(
modifier = Modifier
.wrapContentWidth()
.weight(1f)
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() }
) {
// 隐藏TabBar
generalViewModel.setNavigationBarVisible(false)
// 跳转抠图页面
navController.apply {
currentBackStackEntry?.savedStateHandle?.set("width", 26f)
currentBackStackEntry?.savedStateHandle?.set("height", 32f)
navigate(ScreenRoute.Cutout.route)
}
}
) {
Image(
painter = painterResource(id = R.mipmap.ic_home_certificate_bg),
modifier = Modifier
.fillMaxWidth()
.aspectRatio(80f / 50f),
contentDescription = null,
)
Column(
modifier = Modifier
.fillMaxWidth()
.align(Alignment.Center)
) {
Text(
text = "四六级",
fontSize = 12.sp,
fontWeight = FontWeight.Bold,
lineHeight = 12.sp,
color = Color(0xFF1A1A1A),
modifier = Modifier
.wrapContentSize()
.align(Alignment.CenterHorizontally)
)
Text(
text = "26x32mm",
fontSize = 10.sp,
fontWeight = FontWeight.Normal,
lineHeight = 10.sp,
color = Color(0xFFAAAAAA),
modifier = Modifier
.wrapContentSize()
.align(Alignment.CenterHorizontally)
)
}
}
Box(
modifier = Modifier
.width(8.dp)
)
Box(
modifier = Modifier
.wrapContentWidth()
.weight(1f)
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() }
) {
// 隐藏TabBar
generalViewModel.setNavigationBarVisible(false)
// 跳转抠图页面
navController.apply {
currentBackStackEntry?.savedStateHandle?.set("width", 33f)
currentBackStackEntry?.savedStateHandle?.set("height", 48f)
navigate(ScreenRoute.Cutout.route)
}
}
) {
Image(
painter = painterResource(id = R.mipmap.ic_home_certificate_bg),
modifier = Modifier
.fillMaxWidth()
.aspectRatio(80f / 50f),
contentDescription = null,
)
Column(
modifier = Modifier
.fillMaxWidth()
.align(Alignment.Center)
) {
Text(
text = "司法考试",
fontSize = 12.sp,
fontWeight = FontWeight.Bold,
lineHeight = 12.sp,
color = Color(0xFF1A1A1A),
modifier = Modifier
.wrapContentSize()
.align(Alignment.CenterHorizontally)
)
Text(
text = "33x48mm",
fontSize = 10.sp,
fontWeight = FontWeight.Normal,
lineHeight = 10.sp,
color = Color(0xFFAAAAAA),
modifier = Modifier
.wrapContentSize()
.align(Alignment.CenterHorizontally)
)
}
}
Box(
modifier = Modifier
.width(8.dp)
)
Box(
modifier = Modifier
.wrapContentWidth()
.weight(1f)
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() }
) {
// 隐藏TabBar
generalViewModel.setNavigationBarVisible(false)
// 跳转抠图页面
navController.apply {
currentBackStackEntry?.savedStateHandle?.set("width", 40f)
currentBackStackEntry?.savedStateHandle?.set("height", 60f)
navigate(ScreenRoute.Cutout.route)
}
}
) {
Image(
painter = painterResource(id = R.mipmap.ic_home_certificate_bg),
modifier = Modifier
.fillMaxWidth()
.aspectRatio(80f / 50f),
contentDescription = null,
)
Column(
modifier = Modifier
.fillMaxWidth()
.align(Alignment.Center)
) {
Text(
text = "结婚证",
fontSize = 12.sp,
fontWeight = FontWeight.Bold,
lineHeight = 12.sp,
color = Color(0xFF1A1A1A),
modifier = Modifier
.wrapContentSize()
.align(Alignment.CenterHorizontally)
)
Text(
text = "40x60mm",
fontSize = 10.sp,
fontWeight = FontWeight.Normal,
lineHeight = 10.sp,
color = Color(0xFFAAAAAA),
modifier = Modifier
.wrapContentSize()
.align(Alignment.CenterHorizontally)
)
}
}
Box(
modifier = Modifier
.width(8.dp)
)
Box(
modifier = Modifier
.wrapContentWidth()
.weight(1f)
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() }
) {
// 隐藏TabBar
generalViewModel.setNavigationBarVisible(false)
// 跳转抠图页面
navController.apply {
currentBackStackEntry?.savedStateHandle?.set("width", 35f)
currentBackStackEntry?.savedStateHandle?.set("height", 45f)
navigate(ScreenRoute.Cutout.route)
}
}
) {
Image(
painter = painterResource(id = R.mipmap.ic_home_certificate_bg),
modifier = Modifier
.fillMaxWidth()
.aspectRatio(80f / 50f),
contentDescription = null,
)
Column(
modifier = Modifier
.fillMaxWidth()
.align(Alignment.Center)
) {
Text(
text = "中国签证",
fontSize = 12.sp,
fontWeight = FontWeight.Bold,
lineHeight = 12.sp,
color = Color(0xFF1A1A1A),
modifier = Modifier
.wrapContentSize()
.align(Alignment.CenterHorizontally)
)
Text(
text = "35x45mm",
fontSize = 10.sp,
fontWeight = FontWeight.Normal,
lineHeight = 10.sp,
color = Color(0xFFAAAAAA),
modifier = Modifier
.wrapContentSize()
.align(Alignment.CenterHorizontally)
)
}
}
}
}
}
//选证件制作(内容)
items(certificateRow){
//选证件制作
Column(
modifier = Modifier
.fillMaxWidth()
.offset(y = (-36).dp)
) {
CertificateItems(navController, generalViewModel, it)
}
}
//其他
@ -1182,6 +514,155 @@ fun HomeScreen(
}
}
@Composable
private fun SizeItems(navController: NavController, generalViewModel: GeneralViewModel, data: List<UIItemBean>){
Row(
modifier = Modifier
.fillMaxWidth()
.padding(start = 16.dp, end = 16.dp, top = 12.dp)
) {
data.forEachIndexed { index, item ->
Box(
modifier = Modifier
.wrapContentWidth()
.weight(1f)
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() }
) {
// 隐藏TabBar
generalViewModel.setNavigationBarVisible(false)
// 跳转抠图页面
navController.apply {
currentBackStackEntry?.savedStateHandle?.set("width", item.with)
currentBackStackEntry?.savedStateHandle?.set("height", item.height)
navigate(item.route)
}
}
) {
Image(
painter = painterResource(id = item.icon),
modifier = Modifier
.fillMaxWidth()
.aspectRatio(166 / 68f),
contentDescription = null,
)
Row(
modifier = Modifier
.fillMaxWidth()
.align(Alignment.Center)
) {
Box(
modifier = Modifier
.fillMaxWidth()
.weight(0.25f)
)
Column(
modifier = Modifier
.wrapContentSize()
.weight(0.75f)
) {
Text(
text = item.name,
fontSize = 14.sp,
fontWeight = FontWeight.Bold,
color = Color(0xFF1A1A1A),
modifier = Modifier.wrapContentSize()
)
Text(
text = item.resize,
fontSize = 10.sp,
fontWeight = FontWeight.Normal,
color = Color(0xFF767676),
modifier = Modifier.wrapContentSize()
)
}
}
}
if(index != data.size - 1){
Box(
modifier = Modifier
.width(10.dp)
)
}
}
}
}
@Composable
private fun CertificateItems(navController: NavController, generalViewModel: GeneralViewModel, data: List<UIItemBean>){
Row(
modifier = Modifier
.fillMaxWidth()
.padding(start = 16.dp, end = 16.dp, top = 12.dp)
) {
data.forEachIndexed { index, item ->
Box(
modifier = Modifier
.wrapContentWidth()
.weight(1f)
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() }
) {
// 隐藏TabBar
generalViewModel.setNavigationBarVisible(false)
// 跳转抠图页面
navController.apply {
currentBackStackEntry?.savedStateHandle?.set("width", item.with)
currentBackStackEntry?.savedStateHandle?.set("height", item.height)
navigate(item.route)
}
}
) {
Image(
painter = painterResource(id = item.icon),//R.mipmap.ic_home_certificate_bg
modifier = Modifier
.fillMaxWidth()
.aspectRatio(80f / 50f),
contentDescription = null,
)
Column(
modifier = Modifier
.fillMaxWidth()
.align(Alignment.Center)
) {
Text(
text = item.name,
fontSize = 12.sp,
fontWeight = FontWeight.Bold,
color = Color(0xFF1A1A1A),
lineHeight = 12.sp,
modifier = Modifier
.wrapContentSize()
.align(Alignment.CenterHorizontally)
)
Text(
text = item.resize,
fontSize = 10.sp,
fontWeight = FontWeight.Normal,
lineHeight = 10.sp,
color = Color(0xFFAAAAAA),
modifier = Modifier
.wrapContentSize()
.align(Alignment.CenterHorizontally)
)
}
}
if(index != data.size - 1){
Box(
modifier = Modifier
.width(8.dp)
)
}
}
}
}
@Composable
private fun OtherItems(navController: NavController, generalViewModel: GeneralViewModel, data: List<UIItemBean>){
Column(

View File

@ -72,7 +72,7 @@ fun ResizeScreen(navController: NavController) {
val graphicsLayer = rememberGraphicsLayer()
val coroutineScope = rememberCoroutineScope()
//加载图片参数
val widthParam = navController.previousBackStackEntry?.savedStateHandle?.get<Float>("width") ?: 23f
val widthParam = navController.previousBackStackEntry?.savedStateHandle?.get<Float>("width") ?: 25f
val heightParam = navController.previousBackStackEntry?.savedStateHandle?.get<Float>("height") ?: 35f