Commit 7c720a08 authored by iman Fauzi's avatar iman Fauzi

round bottom sheet

parent b60ffb58
...@@ -76,41 +76,41 @@ public class BottomSheets extends BottomSheetDialogFragment { ...@@ -76,41 +76,41 @@ public class BottomSheets extends BottomSheetDialogFragment {
btnCash = v.findViewById(R.id.btnCash); btnCash = v.findViewById(R.id.btnCash);
totalHarga = v.findViewById(R.id.totalHarga); totalHarga = v.findViewById(R.id.totalHarga);
utils = new Utils(); utils = new Utils();
bottomSheetBehavior = BottomSheetBehavior.from(layoutFormCash); // bottomSheetBehavior = BottomSheetBehavior.from(layoutFormCash);
// sharedPreferences = getActivity().getSharedPreferences(MainActivity.ORDER_ID, Context.MODE_PRIVATE); // sharedPreferences = getActivity().getSharedPreferences(MainActivity.ORDER_ID, Context.MODE_PRIVATE);
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); // bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
long ga = paymentsModels.getGrossAmount(); long ga = paymentsModels.getGrossAmount();
String setCurrency = utils.convertPrice("Rp.", ga); String setCurrency = utils.convertPrice("Rp.", ga);
totalHarga.setText(setCurrency); totalHarga.setText(setCurrency);
hargaChange.setText(defaultText); hargaChange.setText(defaultText);
bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() { // bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override // @Override
public void onStateChanged(@NonNull View bottomSheet, int newState) { // public void onStateChanged(@NonNull View bottomSheet, int newState) {
switch (newState) { // switch (newState) {
case BottomSheetBehavior.STATE_HIDDEN: // case BottomSheetBehavior.STATE_HIDDEN:
break; // break;
case BottomSheetBehavior.STATE_EXPANDED: // case BottomSheetBehavior.STATE_EXPANDED:
break; // break;
case BottomSheetBehavior.STATE_COLLAPSED: // case BottomSheetBehavior.STATE_COLLAPSED:
break; // break;
case BottomSheetBehavior.STATE_DRAGGING: // case BottomSheetBehavior.STATE_DRAGGING:
break; // break;
case BottomSheetBehavior.STATE_SETTLING: // case BottomSheetBehavior.STATE_SETTLING:
break; // break;
} // }
} // }
@Override // @Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) { // public void onSlide(@NonNull View bottomSheet, float slideOffset) {
if (bottomSheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED) { // if (bottomSheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED) {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); // bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
} else { // } else {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); // bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
} // }
} // }
}); // });
inputAmount.addTextChangedListener(new TextWatcher() { inputAmount.addTextChangedListener(new TextWatcher() {
@Override @Override
...@@ -120,7 +120,7 @@ public class BottomSheets extends BottomSheetDialogFragment { ...@@ -120,7 +120,7 @@ public class BottomSheets extends BottomSheetDialogFragment {
@Override @Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
if (TextUtils.isEmpty(charSequence)) inputAmount.setText("0"); if (TextUtils.isEmpty(charSequence)) inputAmount.setText("");
grossAmount = paymentsModels.getGrossAmount(); grossAmount = paymentsModels.getGrossAmount();
long input = Long.parseLong(inputAmount.getText().toString()); long input = Long.parseLong(inputAmount.getText().toString());
...@@ -142,6 +142,7 @@ public class BottomSheets extends BottomSheetDialogFragment { ...@@ -142,6 +142,7 @@ public class BottomSheets extends BottomSheetDialogFragment {
} }
private void bayar(View view) { private void bayar(View view) {
// String orderId, String paymentType, String bank, long grossAmount // String orderId, String paymentType, String bank, long grossAmount
PaymentsModels paymentsModels = new PaymentsModels( PaymentsModels paymentsModels = new PaymentsModels(
MainActivity.orderId, MainActivity.orderId,
......
...@@ -68,7 +68,7 @@ public class PaymentActivity extends AppCompatActivity { ...@@ -68,7 +68,7 @@ public class PaymentActivity extends AppCompatActivity {
Button cashBtn; Button cashBtn;
ProgressDialog progressDialog; ProgressDialog progressDialog;
BottomSheetBehavior bottomSheetBank; BottomSheetBehavior bottomSheetBank;
RelativeLayout qrcodeLayoutBank; // RelativeLayout qrcodeLayoutBank;
...@@ -89,8 +89,8 @@ public class PaymentActivity extends AppCompatActivity { ...@@ -89,8 +89,8 @@ public class PaymentActivity extends AppCompatActivity {
checkoutAdapter = new CheckoutAdapter(); checkoutAdapter = new CheckoutAdapter();
recyclerView = findViewById(R.id.rvItem); recyclerView = findViewById(R.id.rvItem);
grandTotal = findViewById(R.id.grand_total); grandTotal = findViewById(R.id.grand_total);
qrcodeLayoutBank = findViewById(R.id.qrCodeForm); // qrcodeLayoutBank = findViewById(R.id.qrCodeForm);
bottomSheetBank = BottomSheetBehavior.from(qrcodeLayoutBank); // bottomSheetBank = BottomSheetBehavior.from(qrcodeLayoutBank);
progressDialog = new ProgressDialog(PaymentActivity.this); progressDialog = new ProgressDialog(PaymentActivity.this);
progressDialog.setMessage("Loading..."); progressDialog.setMessage("Loading...");
progressDialog.setCancelable(false); progressDialog.setCancelable(false);
...@@ -144,32 +144,32 @@ public class PaymentActivity extends AppCompatActivity { ...@@ -144,32 +144,32 @@ public class PaymentActivity extends AppCompatActivity {
}); });
bottomSheetBank.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() { // bottomSheetBank.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override // @Override
public void onStateChanged(@NonNull View bottomSheet, int newState) { // public void onStateChanged(@NonNull View bottomSheet, int newState) {
switch (newState) { // switch (newState) {
case BottomSheetBehavior.STATE_HIDDEN: // case BottomSheetBehavior.STATE_HIDDEN:
break; // break;
case BottomSheetBehavior.STATE_EXPANDED: // case BottomSheetBehavior.STATE_EXPANDED:
break; // break;
case BottomSheetBehavior.STATE_COLLAPSED: // case BottomSheetBehavior.STATE_COLLAPSED:
break; // break;
case BottomSheetBehavior.STATE_DRAGGING: // case BottomSheetBehavior.STATE_DRAGGING:
break; // break;
case BottomSheetBehavior.STATE_SETTLING: // case BottomSheetBehavior.STATE_SETTLING:
break; // break;
} // }
} // }
//
@Override // @Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) { // public void onSlide(@NonNull View bottomSheet, float slideOffset) {
if (bottomSheetBank.getState() != BottomSheetBehavior.STATE_EXPANDED) { // if (bottomSheetBank.getState() != BottomSheetBehavior.STATE_EXPANDED) {
bottomSheetBank.setState(BottomSheetBehavior.STATE_EXPANDED); // bottomSheetBank.setState(BottomSheetBehavior.STATE_EXPANDED);
} else { // } else {
bottomSheetBank.setState(BottomSheetBehavior.STATE_COLLAPSED); // bottomSheetBank.setState(BottomSheetBehavior.STATE_COLLAPSED);
} // }
} // }
}); // });
btnPay.setOnClickListener(new View.OnClickListener() { btnPay.setOnClickListener(new View.OnClickListener() {
......
package com.yono.messeripos;
import android.content.Context;
import com.google.android.material.appbar.MaterialToolbar;
public class ToolbarApp {
}
...@@ -15,8 +15,7 @@ ...@@ -15,8 +15,7 @@
android:orientation="vertical" android:orientation="vertical"
app:behavior_hideable="true" app:behavior_hideable="true"
app:behavior_peekHeight="56dp" app:behavior_peekHeight="56dp"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior" style="@style/Widget.Rounded.BottomSheet"
style="@style/AppModalStyle"
android:padding="16dp"> android:padding="16dp">
<TextView <TextView
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<FrameLayout
android:id="@+id/btSheet"
style="?attr/bottomSheetStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="hello"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="This is"/>
</FrameLayout>
</FrameLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file
...@@ -87,5 +87,4 @@ ...@@ -87,5 +87,4 @@
</RelativeLayout> </RelativeLayout>
<include layout="@layout/activity_q_r_code"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<item name="windowActionBarOverlay">true</item> <item name="windowActionBarOverlay">true</item>
<item name="android:fontFamily">@font/roboto</item> <item name="android:fontFamily">@font/roboto</item>
<item name="actionBarStyle">@style/ThemeActionBar</item> <item name="actionBarStyle">@style/ThemeActionBar</item>
<item name="bottomSheetDialogTheme">@style/ThemeOverlay.Me.BottomSheetDialog</item> <item name="bottomSheetDialogTheme">@style/ThemeOverlay.Rounded.BottomSheetDialog</item>
</style> </style>
...@@ -75,6 +75,22 @@ ...@@ -75,6 +75,22 @@
<item name="android:hint">Select kategori</item> <item name="android:hint">Select kategori</item>
</style> </style>
<style name="ShapeAppearanceOverlay.Rounded.top" parent="">
<item name="cornerSizeTopLeft">30dp</item>
<item name="cornerSizeTopRight">30dp</item>
<item name="cornerFamily">rounded</item>
</style>
<style
name="ThemeOverlay.Rounded.BottomSheetDialog"
parent="@style/ThemeOverlay.MaterialComponents.BottomSheetDialog">
<item name="bottomSheetStyle">@style/Widget.Rounded.BottomSheet</item>
</style>
<style name="Widget.Rounded.BottomSheet" parent="Widget.MaterialComponents.BottomSheet">
<item name="shapeAppearanceOverlay">@style/ShapeAppearanceOverlay.Rounded.top</item>
</style>
<style name="AppModalStyle" parent="Widget.Design.BottomSheet.Modal"> <style name="AppModalStyle" parent="Widget.Design.BottomSheet.Modal">
<item name="android:background">@drawable/round_corner_sheet</item> <item name="android:background">@drawable/round_corner_sheet</item>
</style> </style>
......
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