style(gjc): 开始组装页运单列表 5 列间距均分,表头两种状态各用一套列宽

- 新增 AssembleWaybillColumns:「件数/重量」与「剩余件数/总件数」两种表头状态
  各一套列宽,表头按 hasLoadedOnce、列表项按 showRemaining 切换,保证列对齐
- 件数与重量之间加弹性间隔;剩余态重量列放宽到 140dp,大重量不换行
- module_base 新增通用 layoutWeight 绑定适配器

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
YANG JIANKUAN
2026-10-13 02:29:33 -07:00
parent d9dc927525
commit f41d4186ea
4 changed files with 68 additions and 8 deletions

View File

@@ -2,6 +2,7 @@ package com.lukouguoji.module_base.adapter
import android.view.View import android.view.View
import android.widget.EditText import android.widget.EditText
import android.widget.LinearLayout
import androidx.databinding.BindingAdapter import androidx.databinding.BindingAdapter
import com.lukouguoji.module_base.interfaces.IOnFocusChangeListener import com.lukouguoji.module_base.interfaces.IOnFocusChangeListener
@@ -27,6 +28,18 @@ fun visible(view: View, visible: Any?) {
} }
} }
/**
* 动态设置 LinearLayout 子 View 的 layout_weight(如按状态切换列宽)
*/
@BindingAdapter("layoutWeight")
fun setLayoutWeight(view: View, weight: Float) {
val lp = view.layoutParams as? LinearLayout.LayoutParams ?: return
if (lp.weight != weight) {
lp.weight = weight
view.layoutParams = lp
}
}
@BindingAdapter("setFocusChangedListener") @BindingAdapter("setFocusChangedListener")
fun setOnFocusChangeListener(et: EditText, listener: IOnFocusChangeListener) { fun setOnFocusChangeListener(et: EditText, listener: IOnFocusChangeListener) {
et.onFocusChangeListener = View.OnFocusChangeListener { v, hasFocus -> et.onFocusChangeListener = View.OnFocusChangeListener { v, hasFocus ->

View File

@@ -0,0 +1,27 @@
package com.lukouguoji.gjc.page.assemble
/**
* 开始组装页「运单列表」列宽权重,表头与 item_assemble_waybill 共用以保证列对齐
*
* 首次装货成功前后,件数/重量列表头文字长短差异很大(「件数」↔「剩余件数/总件数」),
* 一套列宽无法让两种状态下 5 列文字间距都均匀,故按状态各取一套。
* 数值即平板(AutoSize 1152dp 基准)上各列的 dp 宽度;「选择」列固定 64dp 不在其中。
*/
object AssembleWaybillColumns {
const val WB_NO = 0
const val PIECES = 1
const val GAP = 2 // 件数与重量之间的间隔
const val WEIGHT = 3
const val FLIGHT = 4
/** 表头「件数 / 重量」 */
private val TOTAL = floatArrayOf(237f, 72f, 76f, 72f, 250f)
/** 表头「剩余件数/总件数 / 剩余重量/总重量」;重量列放宽到 140,容纳"120856.0/123456.0"不换行 */
private val REMAINING = floatArrayOf(199f, 120f, 57f, 140f, 192f)
@JvmStatic
fun weight(column: Int, showRemaining: Boolean): Float =
(if (showRemaining) REMAINING else TOTAL)[column]
}

View File

@@ -11,6 +11,8 @@
<import type="com.lukouguoji.module_base.ui.weight.search.layout.SearchLayoutType" /> <import type="com.lukouguoji.module_base.ui.weight.search.layout.SearchLayoutType" />
<import type="com.lukouguoji.gjc.page.assemble.AssembleWaybillColumns" />
<variable <variable
name="viewModel" name="viewModel"
type="com.lukouguoji.gjc.viewModel.IntExpAssembleStartViewModel" /> type="com.lukouguoji.gjc.viewModel.IntExpAssembleStartViewModel" />
@@ -179,7 +181,7 @@
<TextView <TextView
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" layoutWeight="@{AssembleWaybillColumns.weight(AssembleWaybillColumns.WB_NO, viewModel.hasLoadedOnce)}"
android:gravity="center" android:gravity="center"
android:text="运单号" android:text="运单号"
android:textColor="@color/text_normal" android:textColor="@color/text_normal"
@@ -187,17 +189,25 @@
<!-- 件数 --> <!-- 件数 -->
<TextView <TextView
android:layout_width="120dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
layoutWeight="@{AssembleWaybillColumns.weight(AssembleWaybillColumns.PIECES, viewModel.hasLoadedOnce)}"
android:gravity="center" android:gravity="center"
android:text='@{viewModel.hasLoadedOnce ? "剩余件数/总件数" : "件数"}' android:text='@{viewModel.hasLoadedOnce ? "剩余件数/总件数" : "件数"}'
android:textColor="@color/text_normal" android:textColor="@color/text_normal"
android:textSize="13sp" /> android:textSize="13sp" />
<!-- 件数与重量列间距(列宽见 AssembleWaybillColumns) -->
<Space
android:layout_width="0dp"
android:layout_height="1dp"
layoutWeight="@{AssembleWaybillColumns.weight(AssembleWaybillColumns.GAP, viewModel.hasLoadedOnce)}" />
<!-- 重量 --> <!-- 重量 -->
<TextView <TextView
android:layout_width="120dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
layoutWeight="@{AssembleWaybillColumns.weight(AssembleWaybillColumns.WEIGHT, viewModel.hasLoadedOnce)}"
android:gravity="center" android:gravity="center"
android:text='@{viewModel.hasLoadedOnce ? "剩余重量/总重量" : "重量"}' android:text='@{viewModel.hasLoadedOnce ? "剩余重量/总重量" : "重量"}'
android:textColor="@color/text_normal" android:textColor="@color/text_normal"
@@ -207,7 +217,7 @@
<TextView <TextView
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1.2" layoutWeight="@{AssembleWaybillColumns.weight(AssembleWaybillColumns.FLIGHT, viewModel.hasLoadedOnce)}"
android:gravity="center" android:gravity="center"
android:text="配载航班" android:text="配载航班"
android:textColor="@color/text_normal" android:textColor="@color/text_normal"

View File

@@ -6,6 +6,8 @@
<import type="android.view.View" /> <import type="android.view.View" />
<import type="com.lukouguoji.gjc.page.assemble.AssembleWaybillColumns" />
<variable <variable
name="bean" name="bean"
type="com.lukouguoji.module_base.bean.AssembleWaybillBean" /> type="com.lukouguoji.module_base.bean.AssembleWaybillBean" />
@@ -44,7 +46,7 @@
<TextView <TextView
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" layoutWeight="@{AssembleWaybillColumns.weight(AssembleWaybillColumns.WB_NO, bean.showRemaining)}"
android:gravity="center" android:gravity="center"
android:text="@{bean.waybillNo}" android:text="@{bean.waybillNo}"
android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}" android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}"
@@ -52,17 +54,25 @@
<!-- 件数 --> <!-- 件数 -->
<TextView <TextView
android:layout_width="120dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
layoutWeight="@{AssembleWaybillColumns.weight(AssembleWaybillColumns.PIECES, bean.showRemaining)}"
android:gravity="center" android:gravity="center"
android:text="@{bean.piecesDisplay}" android:text="@{bean.piecesDisplay}"
android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}" android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}"
android:textSize="14sp" /> android:textSize="14sp" />
<!-- 件数与重量列间距(列宽见 AssembleWaybillColumns) -->
<Space
android:layout_width="0dp"
android:layout_height="1dp"
layoutWeight="@{AssembleWaybillColumns.weight(AssembleWaybillColumns.GAP, bean.showRemaining)}" />
<!-- 重量 --> <!-- 重量 -->
<TextView <TextView
android:layout_width="120dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
layoutWeight="@{AssembleWaybillColumns.weight(AssembleWaybillColumns.WEIGHT, bean.showRemaining)}"
android:gravity="center" android:gravity="center"
android:text="@{bean.weightDisplay}" android:text="@{bean.weightDisplay}"
android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}" android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}"
@@ -72,7 +82,7 @@
<TextView <TextView
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1.2" layoutWeight="@{AssembleWaybillColumns.weight(AssembleWaybillColumns.FLIGHT, bean.showRemaining)}"
android:gravity="center" android:gravity="center"
android:text="@{bean.fLightInfo}" android:text="@{bean.fLightInfo}"
android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}" android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}"