Commit e9fdb6f7 authored by iman Fauzi's avatar iman Fauzi

add sheets

parent abc3118f
<component name="ProjectCodeStyleConfiguration"> <component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173"> <code_scheme name="Project" version="173">
<DBN-PSQL>
<case-options enabled="true">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false" />
</DBN-PSQL>
<DBN-SQL>
<case-options enabled="true">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false">
<option name="STATEMENT_SPACING" value="one_line" />
<option name="CLAUSE_CHOP_DOWN" value="chop_down_if_statement_long" />
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
</formatting-settings>
</DBN-SQL>
<DBN-PSQL> <DBN-PSQL>
<case-options enabled="true"> <case-options enabled="true">
<option name="KEYWORD_CASE" value="lower" /> <option name="KEYWORD_CASE" value="lower" />
......
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
android:roundIcon="@mipmap/ic_launcher_new_icon" android:roundIcon="@mipmap/ic_launcher_new_icon"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme.appbar"> android:theme="@style/AppTheme.appbar">
<activity android:name=".QRCode"></activity> <activity android:name=".BottomSheets"></activity>
<activity android:name=".QRCode" />
<activity <activity
android:name=".HistoryActivity" android:name=".HistoryActivity"
android:theme="@style/AppTheme.appbar" /> android:theme="@style/AppTheme.appbar" />
......
package com.yono.messeripos;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import com.yono.messeripos.models.PaymentsModels;
import com.yono.messeripos.utils.Utils;
import okhttp3.internal.Util;
public class BottomSheets extends BottomSheetDialogFragment {
EditText inputAmount;
TextView hargaChange, totalHarga;
Button btnCash;
Utils utils;
String defaultText = "0";
PaymentsModels paymentsModels;
public BottomSheets(PaymentsModels paymentsModels) {
this.paymentsModels = paymentsModels;
}
@Override
public View onCreateView(LayoutInflater inflater, @Nullable
ViewGroup container, @Nullable Bundle savedInstanceState)
{
View v = inflater.inflate(R.layout.activity_bottom_sheets,
container, false);
inputAmount = v.findViewById(R.id.etBayar);
hargaChange = v.findViewById(R.id.hargaChange);
btnCash = v.findViewById(R.id.btnCash);
totalHarga = v.findViewById(R.id.totalHarga);
utils = new Utils();
long ga = paymentsModels.getGrossAmount();
String setCurrency = utils.convertPrice("Rp.", ga);
totalHarga.setText(setCurrency);
hargaChange.setText(defaultText);
inputAmount.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
if (TextUtils.isEmpty(charSequence)) inputAmount.setText("0");
long grossAmount = paymentsModels.getGrossAmount();
long input = Long.parseLong(inputAmount.getText().toString());
long result = grossAmount - input;
hargaChange.setText(utils.convertPrice("Rp.", result));
}
@Override
public void afterTextChanged(Editable editable) {
}
});
return v;
}
}
package com.yono.messeripos; package com.yono.messeripos;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.Observer; import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;
import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
...@@ -18,19 +15,12 @@ import android.view.View; ...@@ -18,19 +15,12 @@ import android.view.View;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.Button; import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import android.widget.Toolbar;
import com.google.android.material.appbar.MaterialToolbar; import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.yono.messeripos.adapter.CartAdapter;
import com.yono.messeripos.adapter.CheckoutAdapter; import com.yono.messeripos.adapter.CheckoutAdapter;
import com.yono.messeripos.adapter.PaymentAdapter; import com.yono.messeripos.adapter.PaymentAdapter;
import com.yono.messeripos.models.MainViewModels;
import com.yono.messeripos.models.MainViewModelsCart; import com.yono.messeripos.models.MainViewModelsCart;
import com.yono.messeripos.models.PaymentsModels; import com.yono.messeripos.models.PaymentsModels;
import com.yono.messeripos.models.ProductCartModels; import com.yono.messeripos.models.ProductCartModels;
...@@ -54,9 +44,9 @@ public class PaymentActivity extends AppCompatActivity { ...@@ -54,9 +44,9 @@ public class PaymentActivity extends AppCompatActivity {
private RecyclerView recyclerView; private RecyclerView recyclerView;
private CheckoutAdapter checkoutAdapter; private CheckoutAdapter checkoutAdapter;
private TextView grandTotal; private TextView grandTotal;
public static BottomSheets bottomSheet;
AlertDialog alertDialogBuilder;
View stView;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -125,13 +115,9 @@ public class PaymentActivity extends AppCompatActivity { ...@@ -125,13 +115,9 @@ public class PaymentActivity extends AppCompatActivity {
paymentsModels.setPaymentType("cash"); paymentsModels.setPaymentType("cash");
Log.i("CASH", "onClick: "+utils.convertGson(paymentsModels)); Log.i("CASH", "onClick: "+utils.convertGson(paymentsModels));
stView = View.inflate(getApplicationContext(), R.layout.alert_payments, null); bottomSheet = new BottomSheets(paymentsModels);
bottomSheet.show(getSupportFragmentManager(),
"ModalBottomSheet");
alertDialogBuilder = new AlertDialog.Builder(getApplicationContext())
.setTitle("Bayar")
.setView(stView)
.show();
}else{ }else{
paymentsModels.setPaymentType("bank_transfer"); paymentsModels.setPaymentType("bank_transfer");
paymentsModels.setBank(methodPay); paymentsModels.setBank(methodPay);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<shape> <shape>
<gradient android:startColor="#1B76D6" android:endColor="#3028A1"/> <gradient android:startColor="#1B76D6" android:endColor="#3028A1" android:angle="90"/>
</shape> </shape>
</item> </item>
</selector> </selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"> android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:id="@+id/totalText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Total"
android:textSize="30dp"
android:textFontWeight="600"
android:layout_alignParentStart="true" />
<TextView <TextView
android:id="@+id/tvAlertPrice" android:id="@+id/totalHarga"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Rp. 30000" android:text="Rp. 600.000"
android:textSize="28sp" android:textSize="30dp"
android:layout_alignParentEnd="true"/> android:textFontWeight="600"
android:layout_alignParentEnd="true" />
<TextView <TextView
android:id="@+id/labelBayar" android:id="@+id/label"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Bayar" android:text="Bayar"
android:layout_below="@id/tvAlertPrice"/> android:textFontWeight="600"
android:layout_below="@id/totalHarga" />
<EditText <EditText
android:id="@+id/etBayar" android:id="@+id/etBayar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="bayar" android:layout_below="@id/label"
android:layout_below="@id/labelBayar"/> android:hint="Rp."
android:inputType="number"
android:imeOptions="actionDone"/>
<TextView <TextView
android:id="@+id/change" android:id="@+id/textChange"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="change" android:text="Change"
android:layout_below="@id/etBayar" android:layout_below="@id/etBayar"
android:layout_alignParentEnd="true"/> android:layout_alignParentEnd="true" />
<TextView <TextView
android:id="@+id/changeResult" android:id="@+id/hargaChange"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/change" android:text="Rp.20.000"
android:text="Rp. 2000" android:layout_below="@id/textChange"
android:textSize="24sp"
android:layout_alignParentEnd="true"/> android:layout_alignParentEnd="true"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@id/changeResult"
android:backgroundTint="#333"/>
<Button <Button
android:id="@+id/btnCancel" android:id="@+id/btnCash"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="cancel" android:text="@string/hint_pay"
android:backgroundTint="@android:color/holo_red_dark" android:hint="Insert Money"
android:layout_below="@id/changeResult" android:layout_below="@id/hargaChange" />
android:layout_toLeftOf="@id/btnSubmit"
android:layout_marginRight="15dp"/> </RelativeLayout>
<Button
android:id="@+id/btnSubmit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="bayar"
android:layout_below="@id/changeResult"
android:layout_alignParentEnd="true"/>
</RelativeLayout>
\ 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