Commit e1651425 authored by Muhammad Suryono's avatar Muhammad Suryono

Fix form

parent 079ec47b
...@@ -6,12 +6,19 @@ import android.os.PersistableBundle; ...@@ -6,12 +6,19 @@ import android.os.PersistableBundle;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import com.google.android.material.appbar.MaterialToolbar;
public class FormProductActivity extends AppCompatActivity { public class FormProductActivity extends AppCompatActivity {
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.form_product); setContentView(R.layout.form_product);
MaterialToolbar toolbars = findViewById(R.id.topAppBarForm);
setSupportActionBar(toolbars);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle("Add Product");
toolbars.setNavigationOnClickListener(view -> onBackPressed());
} }
} }
...@@ -23,6 +23,7 @@ import androidx.recyclerview.widget.LinearLayoutManager; ...@@ -23,6 +23,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import com.google.android.material.appbar.MaterialToolbar; import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.button.MaterialButton; import com.google.android.material.button.MaterialButton;
import com.yono.messeripos.adapter.CartAdapter;
import com.yono.messeripos.adapter.ProductAdapter; import com.yono.messeripos.adapter.ProductAdapter;
import com.yono.messeripos.databinding.ActivityMainBinding; import com.yono.messeripos.databinding.ActivityMainBinding;
import com.yono.messeripos.models.MainViewModels; import com.yono.messeripos.models.MainViewModels;
...@@ -48,6 +49,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -48,6 +49,7 @@ public class MainActivity extends AppCompatActivity {
ActivityMainBinding binding; ActivityMainBinding binding;
CategoryAdapter categoryAdapter; CategoryAdapter categoryAdapter;
ProductAdapter productAdapter; ProductAdapter productAdapter;
CartAdapter cartAdapter;
public static Boolean status_update = false; public static Boolean status_update = false;
MainViewModelsCart mainViewModelsCart; MainViewModelsCart mainViewModelsCart;
...@@ -61,7 +63,8 @@ public class MainActivity extends AppCompatActivity { ...@@ -61,7 +63,8 @@ public class MainActivity extends AppCompatActivity {
categoryAdapter = new CategoryAdapter(); categoryAdapter = new CategoryAdapter();
productAdapter = new ProductAdapter(); productAdapter = new ProductAdapter();
mainViewModelsCart = new ViewModelProvider(this).get(MainViewModelsCart.class); mainViewModelsCart = new ViewModelProvider(MainActivity.this).get(MainViewModelsCart.class);
cartAdapter = new CartAdapter();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
......
package com.yono.messeripos.adapter; package com.yono.messeripos.adapter;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -82,6 +83,7 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.MyViewHo ...@@ -82,6 +83,7 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.MyViewHo
public class MyViewHolder extends RecyclerView.ViewHolder { public class MyViewHolder extends RecyclerView.ViewHolder {
private ItemListBinding binding; private ItemListBinding binding;
private String statusProduct;
public MyViewHolder(@NonNull ItemListBinding binding) { public MyViewHolder(@NonNull ItemListBinding binding) {
...@@ -89,6 +91,7 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.MyViewHo ...@@ -89,6 +91,7 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.MyViewHo
this.binding = binding; this.binding = binding;
} }
@SuppressLint("ResourceAsColor")
public void bindData(ProductModels products) { public void bindData(ProductModels products) {
binding.setProducts(products); binding.setProducts(products);
...@@ -108,6 +111,17 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.MyViewHo ...@@ -108,6 +111,17 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.MyViewHo
binding.btnDelete.setVisibility(View.GONE); binding.btnDelete.setVisibility(View.GONE);
binding.btnEdit.setVisibility(View.GONE); binding.btnEdit.setVisibility(View.GONE);
} }
if (products.getStockProduct() == 0){
statusProduct = "Not Available";
binding.status.setBackgroundColor(0x55FF0000);
binding.setStatus(statusProduct);
}else{
statusProduct = "Available";
binding.status.setBackgroundColor(0xFF12FF45);
binding.setStatus(statusProduct);
}
binding.materialBtnAddCart.setOnClickListener(new View.OnClickListener() { binding.materialBtnAddCart.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
......
...@@ -5,6 +5,21 @@ ...@@ -5,6 +5,21 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/topAppBarForm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="0dp"
android:paddingTop="20dp"
android:background="@drawable/gradient"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
style="@style/Widget.MaterialComponents.Toolbar.Primary"
xmlns:android="http://schemas.android.com/apk/res/android">
</com.google.android.material.appbar.MaterialToolbar>
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
android:id="@+id/cvProduct" android:id="@+id/cvProduct"
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -12,6 +27,7 @@ ...@@ -12,6 +27,7 @@
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_margin="10dp" android:layout_margin="10dp"
app:cardCornerRadius="80dp" app:cardCornerRadius="80dp"
app:layout_constraintTop_toBottomOf="@id/topAppBarForm"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/tfName"> app:layout_constraintBottom_toTopOf="@id/tfName">
...@@ -21,7 +37,7 @@ ...@@ -21,7 +37,7 @@
android:layout_width="160dp" android:layout_width="160dp"
android:layout_height="160dp" android:layout_height="160dp"
android:scaleType="centerCrop" android:scaleType="centerCrop"
android:src="@drawable/ic_meser_icon" /> android:src="@mipmap/ic_launcher_round" />
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>
......
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
<variable <variable
name="image" name="image"
type="String" /> type="String" />
<variable
name="status"
type="String" />
</data> </data>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
...@@ -77,6 +81,7 @@ ...@@ -77,6 +81,7 @@
android:maxLength="25"/> android:maxLength="25"/>
<TextView <TextView
android:id="@+id/price"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/title_product" app:layout_constraintTop_toBottomOf="@id/title_product"
...@@ -90,6 +95,22 @@ ...@@ -90,6 +95,22 @@
android:text="@{price}" android:text="@{price}"
android:maxLength="25"/> android:maxLength="25"/>
<TextView
android:id="@+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/title_product"
app:layout_constraintStart_toEndOf="@id/price"
tools:text="@tools:sample/full_names"
android:textColor="@android:color/black"
android:layout_marginStart="10dp"
android:layout_marginTop="5dp"
android:textSize="10sp"
android:lines="1"
android:textAllCaps="true"
android:text="@{status}"
android:maxLength="25"/>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
......
...@@ -6,4 +6,6 @@ ...@@ -6,4 +6,6 @@
<color name="colorWhite">#fff</color> <color name="colorWhite">#fff</color>
<color name="mtrl_textinput_default_box_stroke_color">#fff</color> <color name="mtrl_textinput_default_box_stroke_color">#fff</color>
<color name="color_stroke">#22333333</color> <color name="color_stroke">#22333333</color>
<color name="badge_not_available">#F1ACAC</color>
<color name="badge_available">#9DED87</color>
</resources> </resources>
\ No newline at end of file
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