Commit b0bf33e1 authored by Trio Saputra's avatar Trio Saputra

new updated

parent 3e4baf10
package com.example.yourcashiertest.adapters; package com.example.yourcashiertest.adapters;
import android.graphics.Color;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -87,6 +88,14 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.ViewHold ...@@ -87,6 +88,14 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.ViewHold
rupiah.setDecimalFormatSymbols(format); rupiah.setDecimalFormatSymbols(format);
binding.setPrice(rupiah.format(product.getPrice())); binding.setPrice(rupiah.format(product.getPrice()));
if (product.getQuantity() > 0 ) {
binding.setStock("Available");
binding.tvStock.setTextColor(Color.parseColor("#40e0d0"));
} else {
binding.setStock("Sold Out");
binding.tvStock.setTextColor(Color.parseColor("#BD0303"));
}
binding.ivUpdate.setOnClickListener(view -> listener.onUpdate(product)); binding.ivUpdate.setOnClickListener(view -> listener.onUpdate(product));
binding.ivDelete.setOnClickListener(view -> listener.onDelete(product)); binding.ivDelete.setOnClickListener(view -> listener.onDelete(product));
......
...@@ -16,6 +16,10 @@ ...@@ -16,6 +16,10 @@
<variable <variable
name="visibility" name="visibility"
type="boolean" /> type="boolean" />
<variable
name="stock"
type="String" />
</data> </data>
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
...@@ -79,6 +83,7 @@ ...@@ -79,6 +83,7 @@
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:maxLength="20" android:maxLength="20"
android:maxLines="1" android:maxLines="1"
tools:text="Burger mekdi bk"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.45" app:layout_constraintHorizontal_bias="0.45"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
...@@ -91,15 +96,12 @@ ...@@ -91,15 +96,12 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@{product.description}" android:text="@{product.description}"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="@dimen/space_default"
android:maxLength="40" android:maxLength="40"
android:maxLines="2" android:maxLines="2"
tools:text="@tools:sample/lorem"
app:layout_constraintTop_toBottomOf="@id/tv_name" app:layout_constraintTop_toBottomOf="@id/tv_name"
app:layout_constraintBottom_toTopOf="@id/tv_price" app:layout_constraintBottom_toTopOf="@id/tv_price" />
app:layout_constraintEnd_toEndOf="@+id/tv_name"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/tv_name"
app:layout_constraintVertical_bias="0.045" />
<TextView <TextView
android:id="@+id/tv_price" android:id="@+id/tv_price"
...@@ -107,11 +109,22 @@ ...@@ -107,11 +109,22 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@{price}" android:text="@{price}"
android:textStyle="bold" android:textStyle="bold"
tools:text="rp.200000"
android:layout_marginTop="@dimen/space_default"
app:layout_constraintTop_toBottomOf="@id/tv_desc"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/tvStock"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{stock}"
android:textStyle="bold"
tools:text="Available"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
app:layout_constraintBottom_toTopOf="@id/v_add" app:layout_constraintTop_toBottomOf="@+id/tv_price"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/tv_desc"
app:layout_constraintVertical_bias="0.0" /> app:layout_constraintVertical_bias="0.0" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
...@@ -120,7 +133,8 @@ ...@@ -120,7 +133,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="50dp" android:layout_height="50dp"
android:padding="5dp" android:padding="5dp"
android:layout_marginTop="8dp" android:layout_marginTop="@dimen/space_default"
app:layout_constraintTop_toBottomOf="@+id/tvStock"
app:cornerRadius="5dp" app:cornerRadius="5dp"
app:icon="@drawable/ic_baseline_add_shopping_cart_24" app:icon="@drawable/ic_baseline_add_shopping_cart_24"
app:iconGravity="textStart" app:iconGravity="textStart"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment