custom appbar

This commit is contained in:
riz081 2025-06-25 09:28:05 +07:00
parent f2c3de9f5f
commit 2b57d35553
8 changed files with 248 additions and 255 deletions

View File

@ -191,6 +191,8 @@ public class CreateTransactionActivity extends AppCompatActivity implements
if (newAmount.length() <= 9) { if (newAmount.length() <= 9) {
transactionAmount = newAmount; transactionAmount = newAmount;
updateAmountDisplay(); updateAmountDisplay();
// Update status tombol
btnConfirm.setEnabled(!transactionAmount.equals("0"));
} }
} }
@ -201,21 +203,23 @@ public class CreateTransactionActivity extends AppCompatActivity implements
transactionAmount = "0"; transactionAmount = "0";
} }
updateAmountDisplay(); updateAmountDisplay();
// Update status tombol
btnConfirm.setEnabled(!transactionAmount.equals("0"));
} }
private void updateAmountDisplay() { private void updateAmountDisplay() {
if (tvAmountDisplay != null) { if (tvAmountDisplay != null) {
if (transactionAmount.equals("0")) { if (transactionAmount.equals("0")) {
tvAmountDisplay.setText(""); tvAmountDisplay.setText("");
// Disable tombol dan akan otomatis pakai background inactive
btnConfirm.setEnabled(false);
} else { } else {
// Format the number with thousand separators but without currency symbol
long amountCents = Long.parseLong(transactionAmount); long amountCents = Long.parseLong(transactionAmount);
// Format as integer with thousand separators
NumberFormat formatter = NumberFormat.getNumberInstance(new Locale("id", "ID")); NumberFormat formatter = NumberFormat.getNumberInstance(new Locale("id", "ID"));
String formattedAmount = formatter.format(amountCents); String formattedAmount = formatter.format(amountCents);
tvAmountDisplay.setText(formattedAmount); tvAmountDisplay.setText(formattedAmount);
// Enable tombol dan akan otomatis pakai background active
btnConfirm.setEnabled(true);
} }
} }
} }

View File

@ -69,7 +69,7 @@ public class ResultTransactionActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_credit_card); setContentView(R.layout.activity_result_transaction);
getIntentData(); getIntentData();
initViews(); initViews();

View File

@ -16,80 +16,31 @@
android:scrollbars="none" android:scrollbars="none"
android:background="#FFFFFF"> android:background="#FFFFFF">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF">
<!-- Red Status Bar -->
<View
android:id="@+id/red_status_bar"
android:layout_width="match_parent"
android:layout_height="24dp"
android:background="#E31937"
app:layout_constraintTop_toTopOf="parent"/>
<!-- Red Background Header -->
<View
android:id="@+id/red_header_background"
android:layout_width="match_parent"
android:layout_height="160dp"
android:background="#E31937"
app:layout_constraintTop_toBottomOf="@id/red_status_bar"/>
<!-- Back Navigation -->
<LinearLayout <LinearLayout
android:id="@+id/back_navigation" android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="vertical">
android:gravity="center_vertical"
android:layout_marginStart="16dp"
android:layout_marginBottom="5dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:padding="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/red_status_bar">
<!-- Back Arrow --> <include layout="@layout/component_appbar" />
<ImageView
android:id="@+id/backArrow"
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_arrow_back"
android:contentDescription="Back" />
<!-- Title Text --> <!-- Payment Card - Positioned to overlap with red header -->
<TextView
android:id="@+id/toolbarTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="Kembali"
android:textColor="@android:color/white"
android:textSize="12sp"
android:fontFamily="@font/inter"
android:textStyle="normal" />
</LinearLayout>
<!-- Payment Card -->
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:id="@+id/paymentCard" android:id="@+id/paymentCard"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="191dp" android:layout_height="191dp"
android:layout_margin="16dp" android:layout_marginStart="16dp"
android:layout_marginTop="5dp" android:layout_marginEnd="16dp"
android:layout_marginTop="-85dp"
app:cardBackgroundColor="#3498DB" app:cardBackgroundColor="#3498DB"
app:cardCornerRadius="12dp" app:cardCornerRadius="16dp"
app:cardElevation="8dp" app:cardElevation="8dp">
app:layout_constraintTop_toBottomOf="@id/back_navigation">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:padding="20dp"> android:padding="24dp"
android:paddingTop="32dp">
<!-- Title --> <!-- Title -->
<TextView <TextView
@ -97,10 +48,10 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="TOTAL PEMBAYARAN" android:text="TOTAL PEMBAYARAN"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="18sp" android:textSize="20sp"
android:textStyle="bold" android:textStyle="bold"
android:fontFamily="@font/inter" android:fontFamily="@font/inter"
android:layout_marginBottom="24dp" /> android:layout_marginBottom="20dp" />
<!-- Amount Input Section --> <!-- Amount Input Section -->
<LinearLayout <LinearLayout
@ -127,7 +78,7 @@
android:layout_weight="1" android:layout_weight="1"
android:background="@android:color/transparent" android:background="@android:color/transparent"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="20sp" android:textSize="32sp"
android:textStyle="bold" android:textStyle="bold"
android:fontFamily="@font/inter" android:fontFamily="@font/inter"
android:text="" android:text=""
@ -141,7 +92,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="2dp" android:layout_height="2dp"
android:background="@android:color/white" android:background="@android:color/white"
android:layout_marginBottom="16dp" /> android:layout_marginBottom="12dp" />
<!-- Description --> <!-- Description -->
<TextView <TextView
@ -149,8 +100,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Pastikan kembali nominal pembayaran pelanggan Anda" android:text="Pastikan kembali nominal pembayaran pelanggan Anda"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="12sp" android:textSize="10sp"
android:fontFamily="@font/inter" android:fontFamily="@font/inter"
android:textStyle="normal"
android:alpha="0.9" /> android:alpha="0.9" />
</LinearLayout> </LinearLayout>
@ -164,10 +116,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:columnCount="3" android:columnCount="3"
android:rowCount="4" android:rowCount="4"
android:layout_marginTop="24dp" android:layout_marginTop="32dp"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp">
app:layout_constraintTop_toBottomOf="@id/paymentCard">
<!-- Row 1: 1, 2, 3 --> <!-- Row 1: 1, 2, 3 -->
<TextView <TextView
@ -248,37 +199,32 @@
android:layout_height="48dp" android:layout_height="48dp"
android:text="Konfirmasi" android:text="Konfirmasi"
android:textColor="#FFFFFF" android:textColor="#FFFFFF"
android:textSize="16sp" android:textSize="12sp"
android:textStyle="bold" android:textStyle="bold"
android:fontFamily="@font/inter" android:fontFamily="@font/inter"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:layout_marginTop="24dp" android:layout_marginTop="32dp"
android:layout_marginBottom="24dp" android:layout_marginBottom="24dp"
android:enabled="true" app:backgroundTint="@null"
app:backgroundTint="#DE0701" android:background="@drawable/button_confirm_background_selector"
android:enabled="false"
app:cornerRadius="8dp" app:cornerRadius="8dp"
app:rippleColor="#B3000000" app:rippleColor="#B3000000" />
app:layout_constraintTop_toBottomOf="@id/numpad_grid"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintVertical_bias="1" />
<!-- Hidden Mode Indicator and Toggle (for compatibility with existing code) --> <!-- Hidden Components -->
<TextView <TextView
android:id="@+id/tv_mode_indicator" android:id="@+id/tv_mode_indicator"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:visibility="gone" android:visibility="gone" />
app:layout_constraintTop_toTopOf="parent" />
<Button <Button
android:id="@+id/btn_toggle_mode" android:id="@+id/btn_toggle_mode"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:visibility="gone" android:visibility="gone" />
app:layout_constraintTop_toTopOf="parent" />
<!-- Hidden Progress Bar for Card Scanning -->
<ProgressBar <ProgressBar
android:id="@+id/progress_bar" android:id="@+id/progress_bar"
style="?android:attr/progressBarStyle" style="?android:attr/progressBarStyle"
@ -286,16 +232,13 @@
android:layout_height="48dp" android:layout_height="48dp"
android:layout_gravity="center" android:layout_gravity="center"
android:visibility="gone" android:visibility="gone"
android:indeterminateTint="#E31937" android:indeterminateTint="#E31937" />
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" </LinearLayout>
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView> </ScrollView>
<!-- Modal Overlay with Blur Effect for Card Scanning - MOVED TO TOP LEVEL --> <!-- Modal Overlay -->
<FrameLayout <FrameLayout
android:id="@+id/modal_overlay" android:id="@+id/modal_overlay"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -306,7 +249,6 @@
android:focusable="true" android:focusable="true"
android:elevation="100dp"> android:elevation="100dp">
<!-- Modal Content -->
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:id="@+id/modal_card" android:id="@+id/modal_card"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -324,7 +266,6 @@
android:padding="32dp" android:padding="32dp"
android:gravity="center"> android:gravity="center">
<!-- Card Icon -->
<ImageView <ImageView
android:id="@+id/modal_icon" android:id="@+id/modal_icon"
android:layout_width="80dp" android:layout_width="80dp"
@ -335,7 +276,6 @@
android:adjustViewBounds="true" android:adjustViewBounds="true"
app:tint="#E31937" /> app:tint="#E31937" />
<!-- Main Text -->
<TextView <TextView
android:id="@+id/modal_text" android:id="@+id/modal_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="130dp"
android:background="#DE0701"
android:fitsSystemWindows="true">
<!-- Back Navigation -->
<LinearLayout
android:id="@+id/back_navigation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:padding="4dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<!-- Back Arrow -->
<ImageView
android:id="@+id/backArrow"
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_arrow_back"
android:contentDescription="Back"
app:tint="@android:color/white" />
<!-- Title Text -->
<TextView
android:id="@+id/appbarTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:text="Kembali"
android:textColor="@android:color/white"
android:textSize="10sp"
android:fontFamily="@font/inter"
android:textStyle="normal" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -22,6 +22,7 @@
<!-- Banking App Theme Colors --> <!-- Banking App Theme Colors -->
<color name="red">#DE0701</color>
<color name="primary_blue">#1976D2</color> <color name="primary_blue">#1976D2</color>
<color name="light_blue">#BBDEFB</color> <color name="light_blue">#BBDEFB</color>
<color name="accent_teal">#009688</color> <color name="accent_teal">#009688</color>

View File

@ -1,8 +1,9 @@
<resources xmlns:tools="http://schemas.android.com/tools"> <resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="Base.Theme.BDKIPOC" parent="Theme.Material3.DayNight.NoActionBar"> <style name="Base.Theme.BDKIPOC" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Customize your light theme here. --> <!-- Customize your theme here. -->
<!-- <item name="colorPrimary">@color/my_light_primary</item> --> <item name="colorPrimary">@color/red</item>
<item name="colorOnPrimary">@color/white</item>
</style> </style>
<style name="Theme.BDKIPOC" parent="Base.Theme.BDKIPOC" /> <style name="Theme.BDKIPOC" parent="Base.Theme.BDKIPOC" />