|
@@ -47,14 +47,13 @@ import androidx.compose.ui.text.style.TextOverflow
|
|
|
import androidx.compose.ui.unit.dp
|
|
import androidx.compose.ui.unit.dp
|
|
|
import androidx.compose.ui.unit.sp
|
|
import androidx.compose.ui.unit.sp
|
|
|
import androidx.compose.ui.zIndex
|
|
import androidx.compose.ui.zIndex
|
|
|
-import androidx.lifecycle.lifecycleScope
|
|
|
|
|
import coil.compose.AsyncImage
|
|
import coil.compose.AsyncImage
|
|
|
import com.iscs.bozzys.R
|
|
import com.iscs.bozzys.R
|
|
|
import com.iscs.bozzys.api.Message
|
|
import com.iscs.bozzys.api.Message
|
|
|
-import com.iscs.bozzys.ui.common.PageBase
|
|
|
|
|
import com.iscs.bozzys.ui.pages.compose.CardBox
|
|
import com.iscs.bozzys.ui.pages.compose.CardBox
|
|
|
import com.iscs.bozzys.ui.pages.compose.TaskListItem
|
|
import com.iscs.bozzys.ui.pages.compose.TaskListItem
|
|
|
import com.iscs.bozzys.ui.pages.message.openPageMessage
|
|
import com.iscs.bozzys.ui.pages.message.openPageMessage
|
|
|
|
|
+import com.iscs.bozzys.ui.pages.return_device.openPageReturnDevice
|
|
|
import com.iscs.bozzys.ui.pages.vm.VMHome
|
|
import com.iscs.bozzys.ui.pages.vm.VMHome
|
|
|
import com.iscs.bozzys.ui.theme.Text
|
|
import com.iscs.bozzys.ui.theme.Text
|
|
|
import com.iscs.bozzys.utils.DateUtil.getShowDateOrTime
|
|
import com.iscs.bozzys.utils.DateUtil.getShowDateOrTime
|
|
@@ -73,8 +72,6 @@ import com.iscs.bozzys.utils.ble.BleManager
|
|
|
import com.iscs.bozzys.utils.ble.BleRunMode
|
|
import com.iscs.bozzys.utils.ble.BleRunMode
|
|
|
import com.iscs.bozzys.utils.byteArrayToHexString
|
|
import com.iscs.bozzys.utils.byteArrayToHexString
|
|
|
import com.iscs.bozzys.utils.getRoleName
|
|
import com.iscs.bozzys.utils.getRoleName
|
|
|
-import kotlinx.coroutines.Dispatchers
|
|
|
|
|
-import kotlinx.coroutines.launch
|
|
|
|
|
|
|
|
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
|
@Composable
|
|
@Composable
|
|
@@ -112,7 +109,14 @@ private fun TopToolBar(pv: PaddingValues, vm: VMHome) {
|
|
|
Column(
|
|
Column(
|
|
|
modifier = Modifier
|
|
modifier = Modifier
|
|
|
.fillMaxWidth()
|
|
.fillMaxWidth()
|
|
|
- .background(brush = Brush.horizontalGradient(listOf(Color(0xFFFF8C00), Color(0xFFFFA500))))
|
|
|
|
|
|
|
+ .background(
|
|
|
|
|
+ brush = Brush.horizontalGradient(
|
|
|
|
|
+ listOf(
|
|
|
|
|
+ Color(0xFFFF8C00),
|
|
|
|
|
+ Color(0xFFFFA500)
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
.padding(top = pv.calculateTopPadding())
|
|
.padding(top = pv.calculateTopPadding())
|
|
|
) {
|
|
) {
|
|
|
Row(
|
|
Row(
|
|
@@ -137,11 +141,27 @@ private fun TopToolBar(pv: PaddingValues, vm: VMHome) {
|
|
|
contentDescription = null,
|
|
contentDescription = null,
|
|
|
tint = Color.White
|
|
tint = Color.White
|
|
|
)
|
|
)
|
|
|
- AsyncImage(model = state.user.avatar, contentDescription = null, modifier = Modifier.fillMaxSize(), contentScale = ContentScale.Crop)
|
|
|
|
|
|
|
+ AsyncImage(
|
|
|
|
|
+ model = state.user.avatar,
|
|
|
|
|
+ contentDescription = null,
|
|
|
|
|
+ modifier = Modifier.fillMaxSize(),
|
|
|
|
|
+ contentScale = ContentScale.Crop
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
Column(Modifier.padding(horizontal = 10.dp)) {
|
|
Column(Modifier.padding(horizontal = 10.dp)) {
|
|
|
- Text(state.user.nickname, fontSize = 16.sp, lineHeight = 16.sp, fontWeight = FontWeight.Medium, color = Color.White)
|
|
|
|
|
- Text(state.roles.getRoleName(), fontSize = 12.sp, lineHeight = 12.sp, color = Color.White.copy(alpha = 0.8f))
|
|
|
|
|
|
|
+ Text(
|
|
|
|
|
+ state.user.nickname,
|
|
|
|
|
+ fontSize = 16.sp,
|
|
|
|
|
+ lineHeight = 16.sp,
|
|
|
|
|
+ fontWeight = FontWeight.Medium,
|
|
|
|
|
+ color = Color.White
|
|
|
|
|
+ )
|
|
|
|
|
+ Text(
|
|
|
|
|
+ state.roles.getRoleName(),
|
|
|
|
|
+ fontSize = 12.sp,
|
|
|
|
|
+ lineHeight = 12.sp,
|
|
|
|
|
+ color = Color.White.copy(alpha = 0.8f)
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
Spacer(Modifier.weight(1f))
|
|
Spacer(Modifier.weight(1f))
|
|
|
Box(modifier = Modifier.fillMaxHeight(), contentAlignment = Alignment.Center) {
|
|
Box(modifier = Modifier.fillMaxHeight(), contentAlignment = Alignment.Center) {
|
|
@@ -156,8 +176,39 @@ private fun TopToolBar(pv: PaddingValues, vm: VMHome) {
|
|
|
tint = Color.White
|
|
tint = Color.White
|
|
|
)
|
|
)
|
|
|
if (state.msgCount > 0) Text(
|
|
if (state.msgCount > 0) Text(
|
|
|
- if (state.msgCount > 99) "99+" else "${state.msgCount}", color = Color.White, modifier = Modifier
|
|
|
|
|
- .offset(x = 8.dp, y = 15.dp)
|
|
|
|
|
|
|
+ if (state.msgCount > 99) "99+" else "${state.msgCount}",
|
|
|
|
|
+ color = Color.White,
|
|
|
|
|
+ modifier = Modifier
|
|
|
|
|
+ .offset(x = 12.dp, y = 15.dp)
|
|
|
|
|
+ .defaultMinSize(14.dp, 14.dp)
|
|
|
|
|
+ .clip(RoundedCornerShape(14.dp))
|
|
|
|
|
+ .background(Color.Red)
|
|
|
|
|
+ .align(Alignment.TopCenter)
|
|
|
|
|
+ .padding(top = 1.dp)
|
|
|
|
|
+ .padding(horizontal = 2.dp),
|
|
|
|
|
+ textAlign = TextAlign.Center,
|
|
|
|
|
+ fontSize = 10.sp,
|
|
|
|
|
+ lineHeight = 10.sp
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ // 待归还设备入口
|
|
|
|
|
+ Box(modifier = Modifier.fillMaxHeight(), contentAlignment = Alignment.Center) {
|
|
|
|
|
+ Icon(
|
|
|
|
|
+ painter = painterResource(R.drawable.return_device),
|
|
|
|
|
+ contentDescription = null,
|
|
|
|
|
+ modifier = Modifier
|
|
|
|
|
+ .padding(start = 8.dp)
|
|
|
|
|
+ .size(36.dp)
|
|
|
|
|
+ .clip(RoundedCornerShape(6.dp))
|
|
|
|
|
+ .clickable(onClick = { ctx.openPageReturnDevice() })
|
|
|
|
|
+ .padding(7.dp),
|
|
|
|
|
+ tint = Color.White
|
|
|
|
|
+ )
|
|
|
|
|
+ Text(
|
|
|
|
|
+ if (state.msgCount > 99) "99+" else "${state.msgCount}",
|
|
|
|
|
+ color = Color.White,
|
|
|
|
|
+ modifier = Modifier
|
|
|
|
|
+ .offset(x = 12.dp, y = 15.dp)
|
|
|
.defaultMinSize(14.dp, 14.dp)
|
|
.defaultMinSize(14.dp, 14.dp)
|
|
|
.clip(RoundedCornerShape(14.dp))
|
|
.clip(RoundedCornerShape(14.dp))
|
|
|
.background(Color.Red)
|
|
.background(Color.Red)
|
|
@@ -169,25 +220,6 @@ private fun TopToolBar(pv: PaddingValues, vm: VMHome) {
|
|
|
lineHeight = 10.sp
|
|
lineHeight = 10.sp
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
-// Icon(
|
|
|
|
|
-// painter = painterResource(R.drawable.settings),
|
|
|
|
|
-// contentDescription = null,
|
|
|
|
|
-// modifier = Modifier
|
|
|
|
|
-// .size(36.dp)
|
|
|
|
|
-// .clip(RoundedCornerShape(6.dp))
|
|
|
|
|
-// .clickable(onClick = {
|
|
|
|
|
-// if (ctx is PageBase) {
|
|
|
|
|
-// ctx.lifecycleScope.launch(Dispatchers.IO) {
|
|
|
|
|
-// bleKeyTest(ctx.application, "CC:BA:97:21:72:C6")
|
|
|
|
|
-// // bleKeyTest(ctx.application, "CC:BA:97:21:71:E6")
|
|
|
|
|
-// // bleKeyTest(ctx.application, "CC:BA:97:21:72:0A")
|
|
|
|
|
-// // bleKeyTest(ctx.application, "CC:BA:97:21:71:CA")
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
-// })
|
|
|
|
|
-// .padding(10.dp),
|
|
|
|
|
-// tint = Color.White
|
|
|
|
|
-// )
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -226,7 +258,8 @@ private suspend fun bleKeyTest(application: Application, mac: String) {
|
|
|
}
|
|
}
|
|
|
LogUtil.i("xiaoming $mac", "下发作业票:$ticketSendOk")
|
|
LogUtil.i("xiaoming $mac", "下发作业票:$ticketSendOk")
|
|
|
// 作业票下发成功,修改设备运行模式为工作模式
|
|
// 作业票下发成功,修改设备运行模式为工作模式
|
|
|
- val switch = bm.writeByResponse(token.buildBLESwitchRunModeCMD(BleRunMode.WORK)).getSwitchRunModeResult()
|
|
|
|
|
|
|
+ val switch = bm.writeByResponse(token.buildBLESwitchRunModeCMD(BleRunMode.WORK))
|
|
|
|
|
+ .getSwitchRunModeResult()
|
|
|
LogUtil.i("xiaoming $mac", "切换工作模式:$switch")
|
|
LogUtil.i("xiaoming $mac", "切换工作模式:$switch")
|
|
|
// 读取作业票信息
|
|
// 读取作业票信息
|
|
|
// val pkgList = ArrayList<BleTicketDataPackage>()
|
|
// val pkgList = ArrayList<BleTicketDataPackage>()
|
|
@@ -285,10 +318,17 @@ private fun TODO(vmHome: VMHome) {
|
|
|
horizontalAlignment = Alignment.CenterHorizontally,
|
|
horizontalAlignment = Alignment.CenterHorizontally,
|
|
|
verticalArrangement = Arrangement.Center
|
|
verticalArrangement = Arrangement.Center
|
|
|
) {
|
|
) {
|
|
|
- Text("${state.todoCountRunning}", fontSize = 24.sp, lineHeight = 24.sp, fontWeight = FontWeight.Bold, color = Color(0xFFFFA500))
|
|
|
|
|
|
|
+ Text(
|
|
|
|
|
+ "${state.todoCountRunning}",
|
|
|
|
|
+ fontSize = 24.sp,
|
|
|
|
|
+ lineHeight = 24.sp,
|
|
|
|
|
+ fontWeight = FontWeight.Bold,
|
|
|
|
|
+ color = Color(0xFFFFA500)
|
|
|
|
|
+ )
|
|
|
Row(
|
|
Row(
|
|
|
modifier = Modifier.fillMaxWidth(),
|
|
modifier = Modifier.fillMaxWidth(),
|
|
|
- horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically
|
|
|
|
|
|
|
+ horizontalArrangement = Arrangement.Center,
|
|
|
|
|
+ verticalAlignment = Alignment.CenterVertically
|
|
|
) {
|
|
) {
|
|
|
Icon(
|
|
Icon(
|
|
|
painterResource(R.drawable.job_ing),
|
|
painterResource(R.drawable.job_ing),
|
|
@@ -320,10 +360,17 @@ private fun TODO(vmHome: VMHome) {
|
|
|
horizontalAlignment = Alignment.CenterHorizontally,
|
|
horizontalAlignment = Alignment.CenterHorizontally,
|
|
|
verticalArrangement = Arrangement.Center
|
|
verticalArrangement = Arrangement.Center
|
|
|
) {
|
|
) {
|
|
|
- Text("${state.todoCountFinish}", fontSize = 24.sp, lineHeight = 24.sp, fontWeight = FontWeight.Bold, color = Color(0xFF32CD32))
|
|
|
|
|
|
|
+ Text(
|
|
|
|
|
+ "${state.todoCountFinish}",
|
|
|
|
|
+ fontSize = 24.sp,
|
|
|
|
|
+ lineHeight = 24.sp,
|
|
|
|
|
+ fontWeight = FontWeight.Bold,
|
|
|
|
|
+ color = Color(0xFF32CD32)
|
|
|
|
|
+ )
|
|
|
Row(
|
|
Row(
|
|
|
modifier = Modifier.fillMaxWidth(),
|
|
modifier = Modifier.fillMaxWidth(),
|
|
|
- horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically
|
|
|
|
|
|
|
+ horizontalArrangement = Arrangement.Center,
|
|
|
|
|
+ verticalAlignment = Alignment.CenterVertically
|
|
|
) {
|
|
) {
|
|
|
Icon(
|
|
Icon(
|
|
|
painterResource(R.drawable.job_finish),
|
|
painterResource(R.drawable.job_finish),
|
|
@@ -366,9 +413,12 @@ private fun TaskList(pv: PaddingValues, vm: VMHome) {
|
|
|
.padding(horizontal = 16.dp)
|
|
.padding(horizontal = 16.dp)
|
|
|
.fillMaxWidth()
|
|
.fillMaxWidth()
|
|
|
.height(36.dp)
|
|
.height(36.dp)
|
|
|
- .clickable(indication = null, interactionSource = remember { MutableInteractionSource() }, onClick = {
|
|
|
|
|
- vm.onTaskProgressClick()
|
|
|
|
|
- }),
|
|
|
|
|
|
|
+ .clickable(
|
|
|
|
|
+ indication = null,
|
|
|
|
|
+ interactionSource = remember { MutableInteractionSource() },
|
|
|
|
|
+ onClick = {
|
|
|
|
|
+ vm.onTaskProgressClick()
|
|
|
|
|
+ }),
|
|
|
verticalAlignment = Alignment.CenterVertically
|
|
verticalAlignment = Alignment.CenterVertically
|
|
|
) {
|
|
) {
|
|
|
Text("当前任务", fontSize = 14.sp, fontWeight = FontWeight.Medium, color = Text)
|
|
Text("当前任务", fontSize = 14.sp, fontWeight = FontWeight.Medium, color = Text)
|
|
@@ -404,9 +454,12 @@ private fun TaskList(pv: PaddingValues, vm: VMHome) {
|
|
|
.padding(horizontal = 16.dp)
|
|
.padding(horizontal = 16.dp)
|
|
|
.fillMaxWidth()
|
|
.fillMaxWidth()
|
|
|
.height(36.dp)
|
|
.height(36.dp)
|
|
|
- .clickable(indication = null, interactionSource = remember { MutableInteractionSource() }, onClick = {
|
|
|
|
|
- ctx.openPageMessage()
|
|
|
|
|
- }),
|
|
|
|
|
|
|
+ .clickable(
|
|
|
|
|
+ indication = null,
|
|
|
|
|
+ interactionSource = remember { MutableInteractionSource() },
|
|
|
|
|
+ onClick = {
|
|
|
|
|
+ ctx.openPageMessage()
|
|
|
|
|
+ }),
|
|
|
verticalAlignment = Alignment.CenterVertically,
|
|
verticalAlignment = Alignment.CenterVertically,
|
|
|
) {
|
|
) {
|
|
|
Text("最新消息", fontSize = 14.sp, fontWeight = FontWeight.Medium, color = Text)
|
|
Text("最新消息", fontSize = 14.sp, fontWeight = FontWeight.Medium, color = Text)
|
|
@@ -455,7 +508,12 @@ fun MessageListItem(msg: Message, vm: VMHome) {
|
|
|
.fillMaxHeight()
|
|
.fillMaxHeight()
|
|
|
.weight(1f)
|
|
.weight(1f)
|
|
|
) {
|
|
) {
|
|
|
- Text(msg.title ?: "提醒", fontSize = 15.sp, fontWeight = FontWeight.Medium, color = Text)
|
|
|
|
|
|
|
+ Text(
|
|
|
|
|
+ msg.title ?: "提醒",
|
|
|
|
|
+ fontSize = 15.sp,
|
|
|
|
|
+ fontWeight = FontWeight.Medium,
|
|
|
|
|
+ color = Text
|
|
|
|
|
+ )
|
|
|
Text(
|
|
Text(
|
|
|
msg.templateContent,
|
|
msg.templateContent,
|
|
|
fontSize = 13.sp,
|
|
fontSize = 13.sp,
|
|
@@ -468,7 +526,11 @@ fun MessageListItem(msg: Message, vm: VMHome) {
|
|
|
Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
|
|
Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
|
|
|
Text("作业管理", fontSize = 12.sp, color = Color(0xFF999999))
|
|
Text("作业管理", fontSize = 12.sp, color = Color(0xFF999999))
|
|
|
Spacer(Modifier.weight(1f))
|
|
Spacer(Modifier.weight(1f))
|
|
|
- Text(msg.createTime.getShowDateOrTime(), fontSize = 12.sp, color = Text.copy(alpha = 0.6f))
|
|
|
|
|
|
|
+ Text(
|
|
|
|
|
+ msg.createTime.getShowDateOrTime(),
|
|
|
|
|
+ fontSize = 12.sp,
|
|
|
|
|
+ color = Text.copy(alpha = 0.6f)
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// Spacer(
|
|
// Spacer(
|