Close chat #169

Closed
RecentRunner wants to merge 291 commits from close-chat into main
10 changed files with 851 additions and 71 deletions
Showing only changes of commit 653ae3f233 - Show all commits

View File

@@ -0,0 +1,55 @@
package com.example.petstoremobile.adapters;
import android.view.*;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.petstoremobile.R;
import com.example.petstoremobile.dtos.ProductSupplierDTO;
import java.util.List;
public class ProductSupplierAdapter extends RecyclerView.Adapter<ProductSupplierAdapter.PSViewHolder> {
private List<ProductSupplierDTO> list;
private OnProductSupplierClickListener listener;
public interface OnProductSupplierClickListener {
void onProductSupplierClick(int position);
}
public ProductSupplierAdapter(List<ProductSupplierDTO> list, OnProductSupplierClickListener listener) {
this.list = list;
this.listener = listener;
}
public static class PSViewHolder extends RecyclerView.ViewHolder {
TextView tvProductName, tvSupplierName, tvCost;
public PSViewHolder(@NonNull View v) {
super(v);
tvProductName = v.findViewById(R.id.tvPSProductName);
tvSupplierName = v.findViewById(R.id.tvPSSupplierName);
tvCost = v.findViewById(R.id.tvPSCost);
}
}
@NonNull
@Override
public PSViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_product_supplier, parent, false);
return new PSViewHolder(v);
}
@Override
public void onBindViewHolder(@NonNull PSViewHolder holder, int position) {
ProductSupplierDTO ps = list.get(position);
holder.tvProductName.setText(ps.getProductName() != null ? ps.getProductName() : "");
holder.tvSupplierName.setText("Supplier: " + (ps.getSupplierName() != null ? ps.getSupplierName() : ""));
holder.tvCost.setText(ps.getCost() != null ? "Cost: $" + ps.getCost() : "");
holder.itemView.setOnClickListener(v -> listener.onProductSupplierClick(position));
}
@Override
public int getItemCount() { return list.size(); }
}

View File

@@ -0,0 +1,28 @@
package com.example.petstoremobile.api;
import com.example.petstoremobile.dtos.PageResponse;
import com.example.petstoremobile.dtos.ProductSupplierDTO;
import retrofit2.Call;
import retrofit2.http.*;
public interface ProductSupplierApi {
@GET("api/v1/product-suppliers")
Call<PageResponse<ProductSupplierDTO>> getAllProductSuppliers(
@Query("page") int page,
@Query("size") int size);
@POST("api/v1/product-suppliers")
Call<ProductSupplierDTO> createProductSupplier(@Body ProductSupplierDTO dto);
@PUT("api/v1/product-suppliers/{productId}/{supplierId}")
Call<ProductSupplierDTO> updateProductSupplier(
@Path("productId") Long productId,
@Path("supplierId") Long supplierId,
@Body ProductSupplierDTO dto);
@DELETE("api/v1/product-suppliers/{productId}/{supplierId}")
Call<Void> deleteProductSupplier(
@Path("productId") Long productId,
@Path("supplierId") Long supplierId);
}

View File

@@ -0,0 +1,48 @@
package com.example.petstoremobile.dtos;
import java.math.BigDecimal;
public class ProductSupplierDTO {
private Long productId;
private String productName;
private Long supplierId;
private String supplierName;
private BigDecimal cost;
private String createdAt;
private String updatedAt;
// Constructor for create/update
public ProductSupplierDTO(Long productId, Long supplierId, BigDecimal cost) {
this.productId = productId;
this.supplierId = supplierId;
this.cost = cost;
}
public Long getProductId() {
return productId;
}
public String getProductName() {
return productName;
}
public Long getSupplierId() {
return supplierId;
}
public String getSupplierName() {
return supplierName;
}
public BigDecimal getCost() {
return cost;
}
public String getCreatedAt() {
return createdAt;
}
public String getUpdatedAt() {
return updatedAt;
}
}

View File

@@ -0,0 +1,134 @@
package com.example.petstoremobile.fragments.listfragments;
import android.os.Bundle;
import android.text.*;
import android.util.Log;
import android.view.*;
import android.widget.*;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.example.petstoremobile.R;
import com.example.petstoremobile.adapters.ProductSupplierAdapter;
import com.example.petstoremobile.api.RetrofitClient;
import com.example.petstoremobile.dtos.PageResponse;
import com.example.petstoremobile.dtos.ProductSupplierDTO;
import com.example.petstoremobile.fragments.ListFragment;
import com.example.petstoremobile.fragments.listfragments.detailfragments.ProductSupplierDetailFragment;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import java.util.*;
import retrofit2.*;
public class ProductSupplierFragment extends Fragment
implements ProductSupplierAdapter.OnProductSupplierClickListener {
private List<ProductSupplierDTO> psList = new ArrayList<>();
private List<ProductSupplierDTO> filteredList = new ArrayList<>();
private ProductSupplierAdapter adapter;
private SwipeRefreshLayout swipeRefresh;
private EditText etSearch;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_product_supplier, container, false);
setupRecyclerView(view);
setupSearch(view);
setupSwipeRefresh(view);
loadData();
FloatingActionButton fab = view.findViewById(R.id.fabAddPS);
fab.setOnClickListener(v -> openDetail(-1));
ImageButton hamburger = view.findViewById(R.id.btnHamburgerPS);
hamburger.setOnClickListener(v -> {
ListFragment lf = (ListFragment) getParentFragment();
if (lf != null) lf.openDrawer();
});
return view;
}
private void setupRecyclerView(View view) {
RecyclerView rv = view.findViewById(R.id.recyclerViewPS);
adapter = new ProductSupplierAdapter(filteredList, this);
rv.setLayoutManager(new LinearLayoutManager(getContext()));
rv.setAdapter(adapter);
}
private void setupSearch(View view) {
etSearch = view.findViewById(R.id.etSearchPS);
etSearch.addTextChangedListener(new TextWatcher() {
public void beforeTextChanged(CharSequence s, int a, int b, int c) {}
public void afterTextChanged(Editable s) {}
public void onTextChanged(CharSequence s, int a, int b, int c) {
filter(s.toString());
}
});
}
private void setupSwipeRefresh(View view) {
swipeRefresh = view.findViewById(R.id.swipeRefreshPS);
swipeRefresh.setOnRefreshListener(this::loadData);
}
private void filter(String query) {
filteredList.clear();
if (query.isEmpty()) {
filteredList.addAll(psList);
} else {
String lower = query.toLowerCase();
for (ProductSupplierDTO ps : psList) {
if ((ps.getProductName() != null && ps.getProductName().toLowerCase().contains(lower))
|| (ps.getSupplierName() != null && ps.getSupplierName().toLowerCase().contains(lower))) {
filteredList.add(ps);
}
}
}
adapter.notifyDataSetChanged();
}
private void loadData() {
if (swipeRefresh != null) swipeRefresh.setRefreshing(true);
RetrofitClient.getProductSupplierApi(requireContext()).getAllProductSuppliers(0, 100)
.enqueue(new Callback<PageResponse<ProductSupplierDTO>>() {
public void onResponse(Call<PageResponse<ProductSupplierDTO>> c,
Response<PageResponse<ProductSupplierDTO>> r) {
if (swipeRefresh != null) swipeRefresh.setRefreshing(false);
if (r.isSuccessful() && r.body() != null) {
psList.clear();
psList.addAll(r.body().getContent());
filter(etSearch != null ? etSearch.getText().toString() : "");
} else {
Toast.makeText(getContext(), "Failed to load",
Toast.LENGTH_SHORT).show();
}
}
public void onFailure(Call<PageResponse<ProductSupplierDTO>> c, Throwable t) {
if (swipeRefresh != null) swipeRefresh.setRefreshing(false);
Log.e("PSFragment", t.getMessage());
}
});
}
private void openDetail(int position) {
ProductSupplierDetailFragment detail = new ProductSupplierDetailFragment();
Bundle args = new Bundle();
if (position != -1) {
ProductSupplierDTO ps = filteredList.get(position);
args.putLong("productId", ps.getProductId());
args.putLong("supplierId", ps.getSupplierId());
args.putString("productName", ps.getProductName());
args.putString("supplierName", ps.getSupplierName());
args.putString("cost", ps.getCost() != null ? ps.getCost().toString() : "");
}
detail.setArguments(args);
ListFragment lf = (ListFragment) getParentFragment();
if (lf != null) lf.loadFragment(detail);
}
@Override
public void onProductSupplierClick(int position) { openDetail(position); }
}

View File

@@ -0,0 +1,220 @@
package com.example.petstoremobile.fragments.listfragments.detailfragments;
import android.os.Bundle;
import android.util.Log;
import android.view.*;
import android.widget.*;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import com.example.petstoremobile.R;
import com.example.petstoremobile.api.*;
import com.example.petstoremobile.dtos.*;
import com.example.petstoremobile.fragments.ListFragment;
import java.math.BigDecimal;
import java.util.*;
import retrofit2.*;
public class ProductSupplierDetailFragment extends Fragment {
private TextView tvMode;
private Spinner spinnerProduct, spinnerSupplier;
private EditText etCost;
private Button btnSave, btnDelete, btnBack;
private boolean isEditing = false;
private long editProductId = -1;
private long editSupplierId = -1;
private long preselectedProductId = -1;
private long preselectedSupplierId = -1;
private List<ProductDTO> productList = new ArrayList<>();
private List<SupplierDTO> supplierList = new ArrayList<>();
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_product_supplier_detail, container, false);
initViews(view);
loadData();
handleArguments();
btnBack.setOnClickListener(v -> navigateBack());
btnSave.setOnClickListener(v -> save());
btnDelete.setOnClickListener(v -> confirmDelete());
return view;
}
private void initViews(View v) {
tvMode = v.findViewById(R.id.tvPSMode);
spinnerProduct = v.findViewById(R.id.spinnerPSProduct);
spinnerSupplier = v.findViewById(R.id.spinnerPSSupplier);
etCost = v.findViewById(R.id.etPSCost);
btnSave = v.findViewById(R.id.btnSavePS);
btnDelete = v.findViewById(R.id.btnDeletePS);
btnBack = v.findViewById(R.id.btnPSBack);
}
private void loadData() {
loadProducts();
loadSuppliers();
}
private void loadProducts() {
RetrofitClient.getProductApi(requireContext()).getAllProducts(null, 0, 200)
.enqueue(new Callback<PageResponse<ProductDTO>>() {
public void onResponse(Call<PageResponse<ProductDTO>> c,
Response<PageResponse<ProductDTO>> r) {
if (r.isSuccessful() && r.body() != null) {
productList = r.body().getContent();
populateProductSpinner();
}
}
public void onFailure(Call<PageResponse<ProductDTO>> c, Throwable t) {
Log.e("PSDetail", "Product load failed: " + t.getMessage());
}
});
}
private void populateProductSpinner() {
List<String> names = new ArrayList<>();
names.add("-- Select Product --");
for (ProductDTO p : productList) names.add(p.getProdName());
spinnerProduct.setAdapter(new ArrayAdapter<>(requireContext(),
android.R.layout.simple_spinner_item, names));
if (preselectedProductId != -1) {
for (int i = 0; i < productList.size(); i++) {
if (productList.get(i).getProdId().equals(preselectedProductId)) {
spinnerProduct.setSelection(i + 1); break;
}
}
}
}
private void loadSuppliers() {
RetrofitClient.getSupplierApi(requireContext()).getAllSuppliers(0, 200)
.enqueue(new Callback<PageResponse<SupplierDTO>>() {
public void onResponse(Call<PageResponse<SupplierDTO>> c,
Response<PageResponse<SupplierDTO>> r) {
if (r.isSuccessful() && r.body() != null) {
supplierList = r.body().getContent();
populateSupplierSpinner();
}
}
public void onFailure(Call<PageResponse<SupplierDTO>> c, Throwable t) {
Log.e("PSDetail", "Supplier load failed: " + t.getMessage());
}
});
}
private void populateSupplierSpinner() {
List<String> names = new ArrayList<>();
names.add("-- Select Supplier --");
for (SupplierDTO s : supplierList) names.add(s.getSupCompany());
spinnerSupplier.setAdapter(new ArrayAdapter<>(requireContext(),
android.R.layout.simple_spinner_item, names));
if (preselectedSupplierId != -1) {
for (int i = 0; i < supplierList.size(); i++) {
if (supplierList.get(i).getSupId().equals(preselectedSupplierId)) {
spinnerSupplier.setSelection(i + 1); break;
}
}
}
}
private void handleArguments() {
Bundle a = getArguments();
if (a != null && a.containsKey("productId")) {
isEditing = true;
editProductId = a.getLong("productId");
editSupplierId = a.getLong("supplierId");
preselectedProductId = editProductId;
preselectedSupplierId = editSupplierId;
etCost.setText(a.getString("cost"));
tvMode.setText("Edit Product Supplier");
btnDelete.setVisibility(View.VISIBLE);
} else {
tvMode.setText("Add Product Supplier");
btnDelete.setVisibility(View.GONE);
}
}
private void save() {
if (spinnerProduct.getSelectedItemPosition() == 0) {
Toast.makeText(getContext(), "Select a product", Toast.LENGTH_SHORT).show(); return;
}
if (spinnerSupplier.getSelectedItemPosition() == 0) {
Toast.makeText(getContext(), "Select a supplier", Toast.LENGTH_SHORT).show(); return;
}
String costStr = etCost.getText().toString().trim();
if (costStr.isEmpty()) {
etCost.setError("Enter cost"); return;
}
ProductDTO product = productList.get(spinnerProduct.getSelectedItemPosition() - 1);
SupplierDTO supplier = supplierList.get(spinnerSupplier.getSelectedItemPosition() - 1);
BigDecimal cost;
try {
cost = new BigDecimal(costStr);
} catch (Exception e) {
etCost.setError("Invalid cost"); return;
}
ProductSupplierDTO dto = new ProductSupplierDTO(
product.getProdId(), supplier.getSupId(), cost);
ProductSupplierApi api = RetrofitClient.getProductSupplierApi(requireContext());
if (isEditing) {
api.updateProductSupplier(editProductId, editSupplierId, dto)
.enqueue(simpleCallback("Updated"));
} else {
api.createProductSupplier(dto).enqueue(simpleCallback("Saved"));
}
}
private Callback<ProductSupplierDTO> simpleCallback(String msg) {
return new Callback<>() {
public void onResponse(Call<ProductSupplierDTO> c, Response<ProductSupplierDTO> r) {
if (r.isSuccessful()) {
Toast.makeText(getContext(), msg, Toast.LENGTH_SHORT).show();
navigateBack();
} else {
try {
String err = r.errorBody().string();
Log.e("PS_SAVE", "Error: " + err);
Toast.makeText(getContext(), "Error " + r.code(), Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Log.e("PS_SAVE", "Failed to read error");
}
}
}
public void onFailure(Call<ProductSupplierDTO> c, Throwable t) {
Log.e("PS_SAVE", "Failure: " + t.getMessage());
Toast.makeText(getContext(), "Network error", Toast.LENGTH_SHORT).show();
}
};
}
private void confirmDelete() {
new AlertDialog.Builder(requireContext())
.setTitle("Delete?")
.setPositiveButton("Yes", (d, w) ->
RetrofitClient.getProductSupplierApi(requireContext())
.deleteProductSupplier(editProductId, editSupplierId)
.enqueue(new Callback<Void>() {
public void onResponse(Call<Void> c, Response<Void> r) {
navigateBack();
}
public void onFailure(Call<Void> c, Throwable t) {
Toast.makeText(getContext(), "Delete failed",
Toast.LENGTH_SHORT).show();
}
}))
.setNegativeButton("No", null).show();
}
private void navigateBack() {
ListFragment lf = (ListFragment) getParentFragment();
if (lf != null) lf.getChildFragmentManager().popBackStack();
}
}

View File

@@ -0,0 +1,49 @@
package com.example.petstoremobile.models;
public class ProductSupplier {
private int supId;
private int prodId;
private String supCompany;
private String prodName;
private double cost;
public ProductSupplier(int supId, int prodId, String supCompany, String prodName, double cost) {
this.supId = supId;
this.prodId = prodId;
this.supCompany = supCompany;
this.prodName = prodName;
this.cost = cost;
}
public int getSupId() {
return supId;
}
public int getProdId() {
return prodId;
}
public String getSupCompany() {
return supCompany;
}
public String getProdName() {
return prodName;
}
public double getCost() {
return cost;
}
public void setSupCompany(String supCompany) {
this.supCompany = supCompany;
}
public void setProdName(String prodName) {
this.prodName = prodName;
}
public void setCost(double cost) {
this.cost = cost;
}
}

View File

@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_grey">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="@color/primary_dark"
android:gravity="center_vertical"
android:paddingStart="16dp"
android:paddingEnd="16dp">
<ImageButton
android:id="@+id/btnHamburgerPS"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/baseline_menu_36"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="Open menu"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Product Suppliers"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold"/>
</LinearLayout>
<EditText
android:id="@+id/etSearchPS"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:hint="Search by product or supplier..."
android:inputType="text"
android:drawableStart="@android:drawable/ic_menu_search"
android:drawablePadding="8dp"
android:background="@android:color/white"
android:padding="12dp"
android:textColor="@color/text_dark"/>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshPS"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewPS"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp"/>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</LinearLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabAddPS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:backgroundTint="@color/accent_coral"
android:contentDescription="Add Product Supplier"
app:srcCompat="@android:drawable/ic_input_add"
app:tint="@color/white"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/background_grey">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="@color/primary_dark"
android:gravity="center_vertical"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:orientation="horizontal">
<TextView
android:id="@+id/tvPSMode"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Add Product Supplier"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold"/>
<Button
android:id="@+id/btnDeletePS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="@color/accent_coral"
android:text="Delete"
android:textColor="@color/white"/>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="24dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/rounded_card"
android:padding="16dp"
android:layout_marginBottom="16dp">
<!-- Product -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Product"
android:textColor="@color/text_dark"
android:textSize="12sp"
android:layout_marginBottom="4dp"/>
<Spinner
android:id="@+id/spinnerPSProduct"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"/>
<!-- Supplier -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Supplier"
android:textColor="@color/text_dark"
android:textSize="12sp"
android:layout_marginBottom="4dp"/>
<Spinner
android:id="@+id/spinnerPSSupplier"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"/>
<!-- Cost -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cost"
android:textColor="@color/text_dark"
android:textSize="12sp"
android:layout_marginBottom="4dp"/>
<EditText
android:id="@+id/etPSCost"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="0.00"
android:inputType="numberDecimal"
android:layout_marginBottom="8dp"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/white"
android:padding="16dp">
<Button
android:id="@+id/btnPSBack"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="8dp"
android:text="Back"
android:backgroundTint="@color/primary_medium"
android:textColor="@color/white"/>
<Button
android:id="@+id/btnSavePS"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="8dp"
android:text="Save"
android:backgroundTint="@color/accent_coral"
android:textColor="@color/white"/>
</LinearLayout>
</LinearLayout>

View File

@@ -1,84 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:background="@color/white">
android:layout_margin="8dp"
app:cardCornerRadius="8dp"
app:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical">
android:orientation="vertical"
android:padding="16dp">
<TextView
android:id="@+id/tvProductName"
android:layout_width="0dp"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="Product Name"
android:textColor="@color/text_dark"
android:textSize="18sp"
android:textStyle="bold" />
android:orientation="horizontal">
<TextView
android:id="@+id/tvProductPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="$0.00"
android:textColor="@color/accent_coral"
android:textSize="16sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/tvProductName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="@color/text_dark"/>
<TextView
android:id="@+id/tvProductCategory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13sp"
android:textColor="@color/text_light"
android:layout_marginTop="2dp"/>
<TextView
android:id="@+id/tvProductDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textColor="@color/text_light"
android:layout_marginTop="2dp"
android:maxLines="2"
android:ellipsize="end"/>
</LinearLayout>
<TextView
android:id="@+id/tvProductPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="@color/accent_coral"
android:layout_gravity="center_vertical"/>
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/tvProductDesc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:ellipsize="end"
android:maxLines="1"
android:text="Description"
android:textColor="#888888"
android:textSize="13sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_marginTop="8dp">
<TextView
android:id="@+id/tvProductCategory"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Category"
android:textColor="#888888"
android:textSize="13sp" />
<TextView
android:id="@+id/tvStockQuantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Stock: 0"
android:textColor="#888888"
android:textSize="13sp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#F0F0F0"
android:layout_marginTop="12dp"/>
</LinearLayout>
</androidx.cardview.widget.CardView>

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:cardCornerRadius="8dp"
app:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:id="@+id/tvPSProductName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="@color/text_dark"/>
<TextView
android:id="@+id/tvPSSupplierName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13sp"
android:textColor="@color/text_light"
android:layout_marginTop="2dp"/>
<TextView
android:id="@+id/tvPSCost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="@color/accent_coral"
android:layout_marginTop="4dp"/>
</LinearLayout>
</androidx.cardview.widget.CardView>