|
@@ -23,7 +23,6 @@ import androidx.compose.material3.ExperimentalMaterial3Api
|
|
|
import androidx.compose.material3.Icon
|
|
import androidx.compose.material3.Icon
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
import androidx.compose.material3.Text
|
|
import androidx.compose.material3.Text
|
|
|
-import androidx.compose.material3.pulltorefresh.PullToRefreshBox
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.runtime.Composable
|
|
|
import androidx.compose.runtime.LaunchedEffect
|
|
import androidx.compose.runtime.LaunchedEffect
|
|
|
import androidx.compose.runtime.collectAsState
|
|
import androidx.compose.runtime.collectAsState
|
|
@@ -44,10 +43,9 @@ import androidx.compose.ui.unit.sp
|
|
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
|
|
import com.iscs.bozzys.R
|
|
import com.iscs.bozzys.R
|
|
|
import com.iscs.bozzys.ui.common.PageBase
|
|
import com.iscs.bozzys.ui.common.PageBase
|
|
|
-import com.iscs.bozzys.ui.dialog.TipsDialog
|
|
|
|
|
|
|
+import com.iscs.bozzys.ui.dialog.ExceptReportDialog
|
|
|
import com.iscs.bozzys.ui.pages.compose.CardBox
|
|
import com.iscs.bozzys.ui.pages.compose.CardBox
|
|
|
-import com.iscs.bozzys.ui.pages.vm.StatePageMessage
|
|
|
|
|
-import com.iscs.bozzys.ui.pages.vm.VMMessage
|
|
|
|
|
|
|
+import com.iscs.bozzys.ui.pages.vm.VMReturnDevice
|
|
|
import com.iscs.bozzys.ui.theme.Text
|
|
import com.iscs.bozzys.ui.theme.Text
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -63,7 +61,7 @@ fun Context.openPageReturnDevice() {
|
|
|
class PageReturnDevice : PageBase() {
|
|
class PageReturnDevice : PageBase() {
|
|
|
@Composable
|
|
@Composable
|
|
|
override fun GetViews(pv: PaddingValues) {
|
|
override fun GetViews(pv: PaddingValues) {
|
|
|
- val vm: VMMessage = viewModel()
|
|
|
|
|
|
|
+ val vm: VMReturnDevice = viewModel()
|
|
|
val state by vm.state.collectAsState()
|
|
val state by vm.state.collectAsState()
|
|
|
LaunchedEffect(Unit) {
|
|
LaunchedEffect(Unit) {
|
|
|
vm.toast.initToast()
|
|
vm.toast.initToast()
|
|
@@ -82,13 +80,13 @@ class PageReturnDevice : PageBase() {
|
|
|
.fillMaxSize()
|
|
.fillMaxSize()
|
|
|
) {
|
|
) {
|
|
|
TopToolBar(pv, vm)
|
|
TopToolBar(pv, vm)
|
|
|
- MessageList(vm)
|
|
|
|
|
|
|
+ DeviceList(vm)
|
|
|
}
|
|
}
|
|
|
- // 提示弹窗
|
|
|
|
|
- TipsDialog(
|
|
|
|
|
- show = state.tips.show, title = state.tips.title, content = state.tips.content,
|
|
|
|
|
- onCancel = { vm.hideTips() },
|
|
|
|
|
- onConfirm = { vm.onTipsConfirm() })
|
|
|
|
|
|
|
+ // 异常上报Dialog
|
|
|
|
|
+ ExceptReportDialog(state.showExceptDialog, state.exceptDeviceMac,{
|
|
|
|
|
+ vm.hideExceptDialog()
|
|
|
|
|
+ vm.reportExcept()
|
|
|
|
|
+ }, { vm.hideExceptDialog() })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -97,7 +95,7 @@ class PageReturnDevice : PageBase() {
|
|
|
* 顶部工具栏
|
|
* 顶部工具栏
|
|
|
*/
|
|
*/
|
|
|
@Composable
|
|
@Composable
|
|
|
- private fun TopToolBar(pv: PaddingValues, vm: VMMessage) {
|
|
|
|
|
|
|
+ private fun TopToolBar(pv: PaddingValues, vm: VMReturnDevice) {
|
|
|
Column(
|
|
Column(
|
|
|
modifier = Modifier
|
|
modifier = Modifier
|
|
|
.fillMaxWidth()
|
|
.fillMaxWidth()
|
|
@@ -157,7 +155,7 @@ class PageReturnDevice : PageBase() {
|
|
|
*/
|
|
*/
|
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
|
@Composable
|
|
@Composable
|
|
|
-private fun MessageList(vm: VMMessage) {
|
|
|
|
|
|
|
+private fun DeviceList(vm: VMReturnDevice) {
|
|
|
val state by vm.state.collectAsState()
|
|
val state by vm.state.collectAsState()
|
|
|
// 监听顶部Item
|
|
// 监听顶部Item
|
|
|
val listState = rememberLazyListState()
|
|
val listState = rememberLazyListState()
|
|
@@ -177,25 +175,25 @@ private fun MessageList(vm: VMMessage) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// 处理加载更多数据
|
|
// 处理加载更多数据
|
|
|
- LaunchedEffect(shouldLoadMore) {
|
|
|
|
|
- if (shouldLoadMore && state.messages.isNotEmpty() && !state.page.noMore) {
|
|
|
|
|
- vm.getMessage(state.page.copy(page = state.page.page + 1, isRefresh = false))
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- PullToRefreshBox(state.page.isRefresh, onRefresh = {
|
|
|
|
|
- vm.getMessage(StatePageMessage(isRefresh = true, page = 1))
|
|
|
|
|
- }, modifier = Modifier.fillMaxSize()) {
|
|
|
|
|
- Box(
|
|
|
|
|
- modifier = Modifier
|
|
|
|
|
- .padding(top = 5.dp)
|
|
|
|
|
- .fillMaxSize()
|
|
|
|
|
|
|
+// LaunchedEffect(shouldLoadMore) {
|
|
|
|
|
+// if (shouldLoadMore && state.messages.isNotEmpty() && !state.page.noMore) {
|
|
|
|
|
+// vm.getMessage(state.page.copy(page = state.page.page + 1, isRefresh = false))
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// PullToRefreshBox(state.page.isRefresh, onRefresh = {
|
|
|
|
|
+// vm.getMessage(StatePageMessage(isRefresh = true, page = 1))
|
|
|
|
|
+// }, modifier = Modifier.fillMaxSize()) {
|
|
|
|
|
+ Box(
|
|
|
|
|
+ modifier = Modifier
|
|
|
|
|
+ .padding(top = 5.dp)
|
|
|
|
|
+ .fillMaxSize()
|
|
|
|
|
+ ) {
|
|
|
|
|
+ LazyColumn(
|
|
|
|
|
+ state = listState,
|
|
|
|
|
+ modifier = Modifier.fillMaxSize()
|
|
|
) {
|
|
) {
|
|
|
- LazyColumn(
|
|
|
|
|
- state = listState,
|
|
|
|
|
- modifier = Modifier.fillMaxSize()
|
|
|
|
|
- ) {
|
|
|
|
|
- items(3) { item -> DeviceItem(item) }
|
|
|
|
|
- // 数据不为空才会显示加载中
|
|
|
|
|
|
|
+ items(3) { item -> DeviceItem(item, vm) }
|
|
|
|
|
+ // 数据不为空才会显示加载中
|
|
|
// if (state.messages.isNotEmpty()) item {
|
|
// if (state.messages.isNotEmpty()) item {
|
|
|
// Text(
|
|
// Text(
|
|
|
// if (state.page.noMore) "没有更多数据" else "加载更多数据中...",
|
|
// if (state.page.noMore) "没有更多数据" else "加载更多数据中...",
|
|
@@ -207,7 +205,7 @@ private fun MessageList(vm: VMMessage) {
|
|
|
// color = Text.copy(alpha = 0.6f)
|
|
// color = Text.copy(alpha = 0.6f)
|
|
|
// )
|
|
// )
|
|
|
// }
|
|
// }
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
// Empty(tips = "暂无待归还设备")
|
|
// Empty(tips = "暂无待归还设备")
|
|
|
// // 悬浮在列表的顶部
|
|
// // 悬浮在列表的顶部
|
|
|
// if (state.messages.isNotEmpty()) Box(
|
|
// if (state.messages.isNotEmpty()) Box(
|
|
@@ -216,7 +214,7 @@ private fun MessageList(vm: VMMessage) {
|
|
|
// ) {
|
|
// ) {
|
|
|
// MessageListItemTitle(state.messages[topIdx])
|
|
// MessageListItemTitle(state.messages[topIdx])
|
|
|
// }
|
|
// }
|
|
|
- }
|
|
|
|
|
|
|
+// }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -224,7 +222,7 @@ private fun MessageList(vm: VMMessage) {
|
|
|
* 消息内容
|
|
* 消息内容
|
|
|
*/
|
|
*/
|
|
|
@Composable
|
|
@Composable
|
|
|
-private fun DeviceItem(item: Int) {
|
|
|
|
|
|
|
+private fun DeviceItem(item: Int, vm: VMReturnDevice) {
|
|
|
CardBox(modifier = Modifier.padding(vertical = 8.dp, horizontal = 16.dp)) {
|
|
CardBox(modifier = Modifier.padding(vertical = 8.dp, horizontal = 16.dp)) {
|
|
|
Row(
|
|
Row(
|
|
|
Modifier
|
|
Modifier
|
|
@@ -273,7 +271,7 @@ private fun DeviceItem(item: Int) {
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
Button(
|
|
Button(
|
|
|
- {},
|
|
|
|
|
|
|
+ { vm.showExceptDialog("32A9553$item") },
|
|
|
shape = RoundedCornerShape(6.dp),
|
|
shape = RoundedCornerShape(6.dp),
|
|
|
contentPadding = PaddingValues(vertical = 0.dp, horizontal = 5.dp),
|
|
contentPadding = PaddingValues(vertical = 0.dp, horizontal = 5.dp),
|
|
|
modifier = Modifier.height(28.dp)
|
|
modifier = Modifier.height(28.dp)
|