Forráskód Böngészése

适配小米,部分字体显示较小的问题

bjb 3 hónapja
szülő
commit
01c4e08188

+ 4 - 5
app/src/main/java/com/iscs/bozzys/ui/dialog/InputDialog.kt

@@ -99,7 +99,7 @@ fun InputDialog(
                 topRadius = 16.dp,
                 bottomRadius = 16.dp,
                 modifier = Modifier
-                    .width(320.dp)
+                    .fillMaxWidth(0.75f)
                     // 防止点击穿透
                     .clickable(
                         indication = null,
@@ -111,13 +111,12 @@ fun InputDialog(
                     Row(
                         Modifier
                             .fillMaxWidth()
-                            .height(40.dp)
                             .padding(horizontal = 16.dp),
                         verticalAlignment = Alignment.CenterVertically
                     ) {
                         Text(
                             title,
-                            fontSize = 16.sp,
+                            fontSize = 18.sp,
                             lineHeight = 48.sp,
                             fontWeight = FontWeight.Bold,
                             color = Text,
@@ -173,7 +172,7 @@ fun InputDialog(
                                 .clip(RoundedCornerShape(6.dp))
                                 .background(Color.Gray.copy(alpha = 0.6f))
                                 .clickable(onClick = { onCancel() })
-                                .padding(vertical = 5.dp),
+                                .padding(vertical = 8.dp),
                             textAlign = TextAlign.Center,
                             fontSize = 16.sp,
                             fontWeight = FontWeight.Bold
@@ -187,7 +186,7 @@ fun InputDialog(
                                 .clip(RoundedCornerShape(6.dp))
                                 .background(MaterialTheme.colorScheme.primary)
                                 .clickable(onClick = { onConfirm() })
-                                .padding(vertical = 5.dp),
+                                .padding(vertical = 8.dp),
                             textAlign = TextAlign.Center,
                             fontSize = 16.sp,
                             fontWeight = FontWeight.Bold

+ 8 - 1
app/src/main/java/com/iscs/bozzys/ui/dialog/TipsDialog.kt

@@ -95,7 +95,14 @@ fun TipsDialog(
                             content,
                             fontSize = 16.sp,
                             color = Text.copy(alpha = 0.8f),
-                            modifier = Modifier.padding(horizontal = 16.dp, vertical = 20.dp)
+                            modifier = Modifier.padding(horizontal = 16.dp, vertical = 20.dp),
+                            textAlign = TextAlign.Center
+                        )
+                        Spacer(
+                            Modifier
+                                .fillMaxWidth()
+                                .height(0.5.dp)
+                                .background(Color.Black.copy(alpha = 0.05f))
                         )
                         Row(Modifier.padding(horizontal = 5.dp, vertical = 10.dp)) {
                             Text(

+ 7 - 8
app/src/main/java/com/iscs/bozzys/ui/pages/profile/face/PageFace.kt

@@ -125,6 +125,12 @@ class PageFace : PageBase() {
                 }
                 if (state.faceList.isEmpty() && !state.isFirstLoad) Empty(tips = "暂无人脸数据")
             }
+            TipsDialog(show = state.showDeleteTips, title = "提示", content = "确定要删除当前人脸数据吗?", onCancel = {
+                vm.hideDeleteTips()
+            }, onConfirm = {
+                vm.hideDeleteTips()
+                vm.deleteFaceData()
+            })
         }
 
     }
@@ -134,7 +140,6 @@ class PageFace : PageBase() {
      */
     @Composable
     fun FaceListItem(vm: VMFace, face: UserCharacteristic) {
-        val state by vm.state.collectAsState()
         CardBox(modifier = Modifier.padding(vertical = 8.dp)) {
             Row(
                 modifier = Modifier
@@ -164,17 +169,11 @@ class PageFace : PageBase() {
                     painter = painterResource(R.drawable.delete_all), contentDescription = null, modifier = Modifier
                         .size(36.dp)
                         .clip(RoundedCornerShape(50))
-                        .clickable { vm.showDeleteTips() }
+                        .clickable { vm.showDeleteTips(face) }
                         .padding(5.dp),
                     tint = Color(0xFFFA666C)
                 )
             }
-            TipsDialog(show = state.showDeleteTips, title = "提示", content = "确定要删除当前人脸数据吗?", onCancel = {
-                vm.hideDeleteTips()
-            }, onConfirm = {
-                vm.hideDeleteTips()
-                vm.deleteFaceData(face)
-            })
         }
     }
 }

+ 6 - 7
app/src/main/java/com/iscs/bozzys/ui/pages/vm/VMFace.kt

@@ -57,13 +57,11 @@ class VMFace : VMBase() {
 
     /**
      * 删除特征数据
-     *
-     * @param face 特征数据
      */
-    fun deleteFaceData(face: UserCharacteristic) {
+    fun deleteFaceData() {
         viewModelScope.launch(Dispatchers.IO) {
             loading.emit(StateLoading(show = true))
-            ApiRequest.deleteUserCharacteristic(mutableMapOf("ids" to face.id)).onSuccess {
+            ApiRequest.deleteUserCharacteristic(mutableMapOf("ids" to _state.value.face.id)).onSuccess {
                 delay(500)
                 loading.emit(StateLoading())
                 delay(100)
@@ -107,8 +105,8 @@ class VMFace : VMBase() {
     /**
      * 显示删除弹窗
      */
-    fun showDeleteTips() {
-        _state.value = _state.value.copy(showDeleteTips = true)
+    fun showDeleteTips(face: UserCharacteristic) {
+        _state.value = _state.value.copy(showDeleteTips = true, face = face)
     }
 
     /**
@@ -130,5 +128,6 @@ class VMFace : VMBase() {
 data class StateFace(
     val faceList: MutableList<UserCharacteristic> = mutableListOf(),
     val showDeleteTips: Boolean = false,
-    val isFirstLoad: Boolean = true
+    val isFirstLoad: Boolean = true,
+    val face: UserCharacteristic = UserCharacteristic()
 )

+ 4 - 0
app/src/main/java/com/iscs/bozzys/ui/pages/vm/VMMessage.kt

@@ -50,6 +50,10 @@ class VMMessage : VMBase() {
                 // 查找消息个数是否和后台返回的消息个数一致
                 val noMore = newList.count { m -> !m.uiIsTitle } == dataCount
                 _state.value = _state.value.copy(page = _state.value.page.copy(isRefresh = false, noMore = noMore))
+            }.onFailure {
+                delay(500)
+                _state.value = _state.value.copy(page = _state.value.page.copy(page = page.page, isRefresh = false))
+                delay(100)
             }
         }
     }