refactor(ui): 優化支付選項對話框之版面配置與應付金額顯示樣式
This commit is contained in:
parent
309518f3ca
commit
4afc3a59d4
@ -308,16 +308,30 @@ public class BuyDialog extends DialogAbstract {
|
||||
binding.textCount.setText(getContext().getString(R.string.pay_item_count, getTotalCount()));
|
||||
|
||||
int payable = getTotalPrice();
|
||||
StringBuilder priceText = new StringBuilder("NT$").append(payable);
|
||||
String priceText = "NT$" + payable;
|
||||
android.text.SpannableStringBuilder spannable = new android.text.SpannableStringBuilder(priceText);
|
||||
spannable.setSpan(
|
||||
new android.text.style.ForegroundColorSpan(androidx.core.content.ContextCompat.getColor(getContext(), R.color.primary)),
|
||||
0,
|
||||
priceText.length(),
|
||||
android.text.Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
);
|
||||
|
||||
if (!MyApp.getInstance().getReportFreeGiftCodeStructure().getFreeGiftId().isEmpty()) {
|
||||
int saved = getOriginalPrice() - payable;
|
||||
if (saved > 0) {
|
||||
priceText.append(" (")
|
||||
.append(getContext().getString(R.string.pay_discounted_format, saved))
|
||||
.append(")");
|
||||
String discountPart = " (" + getContext().getString(R.string.pay_discounted_format, saved) + ")";
|
||||
int start = spannable.length();
|
||||
spannable.append(discountPart);
|
||||
spannable.setSpan(
|
||||
new android.text.style.ForegroundColorSpan(androidx.core.content.ContextCompat.getColor(getContext(), R.color.success)),
|
||||
start,
|
||||
spannable.length(),
|
||||
android.text.Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
);
|
||||
}
|
||||
}
|
||||
binding.textPrice.setText(priceText.toString());
|
||||
binding.textPrice.setText(spannable);
|
||||
}
|
||||
|
||||
public void dialogCancel() {
|
||||
|
||||
@ -8,57 +8,6 @@
|
||||
android:paddingTop="24dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- 件數 / 應付金額列:讓使用者在選擇支付方式時看到要買幾件、要付多少(已含來店禮折抵) -->
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@color/white"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingHorizontal="12dp"
|
||||
android:paddingVertical="10dp">
|
||||
|
||||
<!-- 件數 -->
|
||||
<TextView
|
||||
android:id="@+id/textCount"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="start|center_vertical"
|
||||
android:text="@string/cart"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="26sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<!-- 應付金額標題 -->
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:text="@string/pay_payable_amount"
|
||||
android:textColor="@color/red"
|
||||
android:textSize="26sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<!-- 應付金額(已含來店禮折抵) -->
|
||||
<TextView
|
||||
android:id="@+id/textPrice"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="end|center_vertical"
|
||||
android:text="0"
|
||||
android:textColor="@color/red"
|
||||
android:textSize="30sp"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- 支付方式標題 -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
@ -67,10 +16,63 @@
|
||||
android:textSize="30sp"
|
||||
android:textColor="@color/primary"
|
||||
android:padding="10dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:gravity="center"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<!-- 件數 / 應付金額列:讓使用者在選擇支付方式時看到要買幾件、要付多少(已含來店禮折抵) -->
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:paddingHorizontal="12dp"
|
||||
android:paddingVertical="10dp">
|
||||
|
||||
<!-- 件數 -->
|
||||
<TextView
|
||||
android:id="@+id/textCount"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/cart"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="26sp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<!-- 應付金額標題 -->
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:text="@string/pay_payable_amount"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="26sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<!-- 應付金額(已含來店禮折抵) -->
|
||||
<TextView
|
||||
android:id="@+id/textPrice"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="0"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="30sp"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 支付方式按鈕區(可滾動) -->
|
||||
<ScrollView
|
||||
android:id="@+id/layoutPaymentTransactions"
|
||||
|
||||
@ -333,7 +333,7 @@
|
||||
<string name="cancel_button_format">取消(%d秒)</string>
|
||||
<string name="total_items_format">購物車品項(%d件)</string>
|
||||
<string name="total_amount_format">NT$%d</string>
|
||||
<string name="pay_item_count">共 %d 件</string>
|
||||
<string name="pay_item_count">商品數量:共 %d 件</string>
|
||||
<string name="pay_payable_amount">應付金額</string>
|
||||
<string name="pay_discounted_format">已折抵 NT$%d</string>
|
||||
<string name="cart_out_of_stock">超出庫存</string>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user