Browse Source

refactor(数据管理):
- 优化开关示意图弹窗显示逻辑和样式
- 调整`SwitchInfoDialog`中开关状态文本的国际化键名为`switch_status`
- 移除`SwitchInfoDialog`中不必要的延时调用

周文健 2 months ago
parent
commit
77b37d5e56

+ 5 - 3
app/src/main/java/com/grkj/iscs/features/main/dialog/data_manage/SwitchInfoDialog.kt

@@ -4,6 +4,7 @@ import android.graphics.Color
 import android.view.Gravity
 import android.view.View
 import androidx.annotation.IntDef
+import androidx.compose.ui.graphics.vector.Group
 import com.grkj.iscs.R
 import com.grkj.iscs.databinding.DialogSwitchInfoBinding
 import com.grkj.ui_base.utils.CommonUtils
@@ -30,8 +31,6 @@ class SwitchInfoDialog(
         // 行为:可返回键关闭、无遮罩(透明)、居中
         dialog.isCancelable = true
         dialog.setMaskColor(Color.TRANSPARENT)
-        dialog.align = CustomDialog.ALIGN.CENTER
-        dialog.maxWidth = (v.resources.displayMetrics.widthPixels * 0.9f).toInt()
 
         // --- 数据填充 ---
         binding.switchName.text = switchName
@@ -42,14 +41,17 @@ class SwitchInfoDialog(
                 binding.switchStatus.setBackgroundResource(R.drawable.bg_switch_off)
                 binding.switchStatus.text = CommonUtils.getStr("switch_close")
             }
+
             STATUS_ON -> {
                 binding.switchStatus.setBackgroundResource(R.drawable.bg_switch_on)
                 binding.switchStatus.text = CommonUtils.getStr("switch_open")
             }
+
             STATUS_ALARM -> {
                 binding.switchStatus.setBackgroundResource(R.drawable.bg_switch_alarm)
                 binding.switchStatus.text = CommonUtils.getStr("switch_alarm")
             }
+
             else -> {
                 // 兜底
                 binding.switchStatus.setBackgroundResource(R.drawable.bg_switch_off)
@@ -77,7 +79,7 @@ class SwitchInfoDialog(
             return CustomDialog.show(
                 SwitchInfoDialog(switchName, pointNfc, switchStatus),
                 CustomDialog.ALIGN.CENTER
-            ).setAlignBaseViewGravity(view, Gravity.TOP)
+            ).setAlignBaseViewGravity(view, Gravity.CENTER_HORIZONTAL or Gravity.TOP)
         }
     }
 }

+ 5 - 7
app/src/main/java/com/grkj/iscs/features/main/fragment/data_manage/SwitchLayoutFragment.kt

@@ -281,13 +281,11 @@ class SwitchLayoutFragment : BaseFragment<FragmentSwitchLayoutBinding>() {
                 lp.leftMargin = screenX.toInt()
                 lp.topMargin = screenY.toInt()
                 binding.dialogPositionPoint.layoutParams = lp
-                binding.dialogPositionPoint.postDelayed({
-                    SwitchInfoDialog.show(
-                        binding.dialogPositionPoint, point.entityName,
-                        "${point.pointNfc}",
-                        point.status
-                    )
-                }, 100)
+                SwitchInfoDialog.show(
+                    binding.dialogPositionPoint, point.entityName,
+                    "${point.pointNfc}",
+                    point.status
+                )
             }
             binding.mapview.addLayer(stationLayer)
             stationLayer?.setRatio(viewModel.mapRatio)

+ 1 - 1
app/src/main/res/layout/dialog_switch_info.xml

@@ -40,7 +40,7 @@
                 android:layout_height="wrap_content"
                 android:textColor="@color/white"
                 android:textSize="@dimen/iscs_text_sm"
-                app:i18nKey='@{"iscs_text_sm"}' />
+                app:i18nKey='@{"switch_status"}' />
 
             <TextView
                 android:id="@+id/switch_status"