diff --git a/app/src/main/java/com/alya/ecommerce_serang/ui/order/CheckoutActivity.kt b/app/src/main/java/com/alya/ecommerce_serang/ui/order/CheckoutActivity.kt
index 1c23baf..7b7bbfd 100644
--- a/app/src/main/java/com/alya/ecommerce_serang/ui/order/CheckoutActivity.kt
+++ b/app/src/main/java/com/alya/ecommerce_serang/ui/order/CheckoutActivity.kt
@@ -154,8 +154,18 @@ class CheckoutActivity : AppCompatActivity() {
// Observe address details
viewModel.addressDetails.observe(this) { address ->
- binding.tvPlacesAddress.text = address?.recipient
- binding.tvAddress.text = "${address?.street}, ${address?.subdistrict}"
+ if (address != null) {
+ // Show selected address
+ binding.containerEmptyAddress.visibility = View.GONE
+ binding.containerAddress.visibility = View.VISIBLE
+
+ binding.tvPlacesAddress.text = address.recipient
+ binding.tvAddress.text = "${address.street}, ${address.subdistrict}"
+ } else {
+ // Show empty address state
+ binding.containerEmptyAddress.visibility = View.VISIBLE
+ binding.containerAddress.visibility = View.GONE
+ }
}
viewModel.availablePaymentMethods.observe(this) { paymentMethods ->
@@ -172,9 +182,7 @@ class CheckoutActivity : AppCompatActivity() {
// Update the adapter ONLY if it exists
paymentAdapter?.let { adapter ->
- // This line was causing issues - using setSelectedPayment instead of setSelectedPaymentName
adapter.setSelectedPaymentId(selectedPayment.id)
-
Log.d("CheckoutActivity", "Updated adapter with selected payment: ${selectedPayment.id}")
}
}
@@ -183,13 +191,13 @@ class CheckoutActivity : AppCompatActivity() {
// Observe loading state
viewModel.isLoading.observe(this) { isLoading ->
binding.btnPay.isEnabled = !isLoading
-
}
// Observe error messages
viewModel.errorMessage.observe(this) { message ->
if (message.isNotEmpty()) {
- Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
+ Toast.makeText(this, "Terdapat kendala di pemesanan", Toast.LENGTH_SHORT).show()
+ Log.e("CheckoutActivity", "Error from errorMessage: $message")
}
}
@@ -207,11 +215,16 @@ class CheckoutActivity : AppCompatActivity() {
if (paymentMethods.isEmpty()) {
Log.e("CheckoutActivity", "Payment methods list is empty")
Toast.makeText(this, "Tidak ditemukan metode pembayaran", Toast.LENGTH_SHORT).show()
- binding.tvEmptyPayment.visibility = View.VISIBLE
+
+ // Show empty payment state
+ binding.containerEmptyPayment.visibility = View.VISIBLE
+ binding.rvPaymentInfo.visibility = View.GONE
return
}
- binding.tvEmptyPayment.visibility = View.GONE
+ binding.containerEmptyPayment.visibility = View.GONE
+ binding.rvPaymentInfo.visibility = View.VISIBLE
+
// Debug logging
Log.d("CheckoutActivity", "Setting up payment methods: ${paymentMethods.size} methods available")
@@ -257,6 +270,16 @@ class CheckoutActivity : AppCompatActivity() {
}
private fun setupProductRecyclerView(checkoutData: CheckoutData) {
+ if (checkoutData.cartItems.isEmpty()) {
+ // Show empty products state
+ binding.containerEmptyProducts.visibility = View.VISIBLE
+ binding.rvProductItems.visibility = View.GONE
+ return
+ }
+
+ binding.containerEmptyProducts.visibility = View.GONE
+ binding.rvProductItems.visibility = View.VISIBLE
+
val adapter = if (checkoutData.isBuyNow || checkoutData.cartItems.size <= 1) {
CheckoutSellerAdapter(checkoutData)
} else {
@@ -292,7 +315,8 @@ class CheckoutActivity : AppCompatActivity() {
private fun updateShippingUI(shipName: String, shipService: String, shipEtd: String, shipPrice: Int) {
if (shipName.isNotEmpty() && shipService.isNotEmpty()) {
- // Display shipping name and service in one line
+ // Hide empty state and show selected shipping
+ binding.containerEmptyShipping.visibility = View.GONE
binding.cardShipment.visibility = View.VISIBLE
binding.tvCourierName.text = "$shipName $shipService"
@@ -300,6 +324,8 @@ class CheckoutActivity : AppCompatActivity() {
binding.tvShippingPrice.text = formatCurrency(shipPrice.toDouble())
binding.rbJne.isChecked = true
} else {
+ // Show empty shipping state
+ binding.containerEmptyShipping.visibility = View.VISIBLE
binding.cardShipment.visibility = View.GONE
}
}
@@ -312,10 +338,10 @@ class CheckoutActivity : AppCompatActivity() {
}
// Shipping method selection
- binding.layoutShippingMethod.setOnClickListener {
+ binding.tvShippingOption.setOnClickListener {
val addressId = viewModel.addressDetails.value?.id ?: 0
if (addressId <= 0) {
- Toast.makeText(this, "Silahkan pilih metode pengiriman dahulu", Toast.LENGTH_SHORT).show()
+ Toast.makeText(this, "Silahkan pilih alamat dahulu", Toast.LENGTH_SHORT).show()
return@setOnClickListener
}
diff --git a/app/src/main/res/drawable/baseline_local_grocery_store_24.xml b/app/src/main/res/drawable/baseline_local_grocery_store_24.xml
new file mode 100644
index 0000000..5476e7e
--- /dev/null
+++ b/app/src/main/res/drawable/baseline_local_grocery_store_24.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/app/src/main/res/drawable/baseline_payment_24.xml b/app/src/main/res/drawable/baseline_payment_24.xml
new file mode 100644
index 0000000..bf9bfd1
--- /dev/null
+++ b/app/src/main/res/drawable/baseline_payment_24.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_checkout.xml b/app/src/main/res/layout/activity_checkout.xml
index 10944b5..43e7a44 100644
--- a/app/src/main/res/layout/activity_checkout.xml
+++ b/app/src/main/res/layout/activity_checkout.xml
@@ -34,69 +34,50 @@
android:orientation="vertical">
-
+ android:layout_marginHorizontal="16dp"
+ android:layout_marginTop="16dp"
+ app:cardCornerRadius="12dp"
+ app:cardElevation="2dp"
+ app:cardBackgroundColor="@color/white"
+ app:strokeColor="#E0E0E0"
+ app:strokeWidth="1dp">
-
+ android:padding="20dp">
+
+ android:orientation="horizontal"
+ android:gravity="center_vertical"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent">
+ app:tint="@color/blue_300" />
-
-
-
-
-
-
-
+ android:text="Alamat Pengiriman"
+ android:textSize="16sp"
+ android:textColor="@android:color/black"
+ android:fontFamily="@font/dmsans_medium"
+ android:layout_marginStart="12dp" />
+ android:textSize="14sp"
+ android:fontFamily="@font/dmsans_medium"
+ android:background="?attr/selectableItemBackgroundBorderless"
+ android:paddingHorizontal="8dp"
+ android:paddingVertical="4dp" />
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ android:layout_marginHorizontal="16dp"
+ android:layout_marginTop="8dp"
+ app:cardBackgroundColor="@color/white"
+ app:strokeColor="#E0E0E0"
+ app:strokeWidth="1dp">
-
+ android:padding="20dp">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
+ android:gravity="center_vertical"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent">
-
+
-
+ android:text="Produk Pesanan"
+ android:textSize="16sp"
+ android:textColor="@android:color/black"
+ android:fontFamily="@font/dmsans_medium"
+ android:layout_marginStart="12dp" />
+
-
+
+
-
-
+ android:textColor="#757575"
+ android:textSize="14sp"
+ android:gravity="center" />
+
+
-
-
-
+
+
-
-
+
+
+
+
+ android:layout_marginHorizontal="16dp"
+ android:layout_marginTop="8dp"
+ app:cardBackgroundColor="@color/white"
+ app:strokeColor="#E0E0E0"
+ app:strokeWidth="1dp">
-
+ android:padding="20dp">
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:padding="20dp">
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -303,7 +547,7 @@
android:id="@+id/tv_item_total"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="Rp65.000"
+ android:text="Rp0"
android:textSize="14sp" />
@@ -324,7 +568,7 @@
android:id="@+id/tv_shipping_fee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="Rp15.000"
+ android:text="Rp0"
android:textSize="14sp" />
@@ -351,8 +595,8 @@
android:id="@+id/tv_total"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="Rp75.000"
- android:textColor="#3D84FF"
+ android:text="Rp0"
+ android:textColor="@color/blue_400"
android:textSize="16sp"
android:fontFamily="@font/dmsans_bold" />
@@ -388,7 +632,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rp75.000"
- android:textColor="#3D84FF"
+ android:textColor="@color/blue_400"
android:textSize="18sp"
android:fontFamily="@font/dmsans_bold" />
@@ -401,7 +645,7 @@
android:textAllCaps="false"
android:paddingHorizontal="32dp"
app:cornerRadius="8dp"
- android:backgroundTint="#3D84FF" />
+ android:backgroundTint="@color/blue_500" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_shipping_order.xml b/app/src/main/res/layout/item_shipping_order.xml
index cb0ae51..95f14eb 100644
--- a/app/src/main/res/layout/item_shipping_order.xml
+++ b/app/src/main/res/layout/item_shipping_order.xml
@@ -9,10 +9,9 @@
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:gravity="start"
+ android:gravity="center"
android:layout_marginStart="16dp"
android:layout_marginVertical="8dp"
- android:layout_marginBottom="4dp"
android:layout_gravity="center_horizontal"
android:orientation="horizontal">
@@ -39,15 +40,15 @@
android:id="@+id/est_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textSize="16sp"
- android:paddingHorizontal="8dp"
+ android:textSize="12sp"
+ android:paddingHorizontal="4dp"
android:text="Estimasi 3-4 hari"/>