forked from thijooree/android
redesigned full screen for MIB recipt
This commit is contained in:
@@ -35,6 +35,7 @@ import sh.sar.basedbank.BasedBankApp
|
||||
import sh.sar.basedbank.R
|
||||
import sh.sar.basedbank.api.mib.MibContactsClient
|
||||
import sh.sar.basedbank.databinding.DialogReceiptFullscreenBmlBinding
|
||||
import sh.sar.basedbank.databinding.DialogReceiptFullscreenMibBinding
|
||||
import sh.sar.basedbank.databinding.FragmentReceiptBmlBinding
|
||||
import sh.sar.basedbank.databinding.FragmentReceiptMfaisaBinding
|
||||
import sh.sar.basedbank.databinding.FragmentReceiptMibBinding
|
||||
@@ -486,6 +487,7 @@ class TransferReceiptFragment : Fragment() {
|
||||
val ctx = requireContext()
|
||||
val bank = arguments?.getString(ARG_BANK, "MIB") ?: "MIB"
|
||||
if (bank == "BML") { showBmlFullScreenReceipt(); return }
|
||||
if (bank == "MIB") { showMibFullScreenReceipt(); return }
|
||||
val dialog = Dialog(ctx, android.R.style.Theme_Black_NoTitleBar_Fullscreen)
|
||||
|
||||
val scrollView = android.widget.ScrollView(ctx).apply {
|
||||
@@ -587,6 +589,64 @@ class TransferReceiptFragment : Fragment() {
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
/**
|
||||
* MIB full-screen receipt: edge-to-edge card whose green header runs under the
|
||||
* (visible) status bar, a floating close button top-right just below the status bar,
|
||||
* and MIB-styled Share/Save buttons pinned to the bottom. Follows the app theme.
|
||||
*/
|
||||
private fun showMibFullScreenReceipt() {
|
||||
val ctx = requireContext()
|
||||
val dialog = Dialog(ctx, R.style.Theme_BasedBank)
|
||||
val page = DialogReceiptFullscreenMibBinding.inflate(layoutInflater)
|
||||
|
||||
val cardBinding = FragmentReceiptMibBinding.inflate(layoutInflater).also { bindMib(it) }
|
||||
val card = cardBinding.receiptCard
|
||||
(card.parent as? ViewGroup)?.removeView(card)
|
||||
page.cardHolder.addView(card, ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
))
|
||||
|
||||
page.btnClose.setOnClickListener { dialog.dismiss() }
|
||||
page.btnShareFull.setOnClickListener { shareReceipt() }
|
||||
page.btnSaveFull.setOnClickListener { saveReceipt() }
|
||||
|
||||
val header = cardBinding.receiptHeader
|
||||
val headerBaseHeight = header.layoutParams.height
|
||||
val headerBasePadding = header.paddingTop
|
||||
val closeBaseMargin = (page.btnClose.layoutParams as ViewGroup.MarginLayoutParams).topMargin
|
||||
val bottomBasePadding = page.bottomBar.paddingBottom
|
||||
ViewCompat.setOnApplyWindowInsetsListener(page.root) { _, insets ->
|
||||
val bars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
// Grow the green header under the status bar, keeping its content below it
|
||||
header.layoutParams = header.layoutParams.apply { height = headerBaseHeight + bars.top }
|
||||
header.updatePadding(top = headerBasePadding + bars.top)
|
||||
page.btnClose.layoutParams = (page.btnClose.layoutParams as ViewGroup.MarginLayoutParams)
|
||||
.apply { topMargin = closeBaseMargin + bars.top }
|
||||
page.bottomBar.updatePadding(bottom = bottomBasePadding + bars.bottom)
|
||||
page.root.updatePadding(left = bars.left, right = bars.right)
|
||||
insets
|
||||
}
|
||||
|
||||
dialog.setContentView(page.root)
|
||||
dialog.window?.let { win ->
|
||||
win.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
|
||||
androidx.core.view.WindowCompat.setDecorFitsSystemWindows(win, false)
|
||||
@Suppress("DEPRECATION")
|
||||
win.statusBarColor = Color.TRANSPARENT
|
||||
@Suppress("DEPRECATION")
|
||||
win.navigationBarColor = Color.TRANSPARENT
|
||||
val isLight = (resources.configuration.uiMode and
|
||||
android.content.res.Configuration.UI_MODE_NIGHT_MASK) ==
|
||||
android.content.res.Configuration.UI_MODE_NIGHT_NO
|
||||
androidx.core.view.WindowInsetsControllerCompat(win, win.decorView).apply {
|
||||
// Status bar sits over the green header, so always use light icons
|
||||
isAppearanceLightStatusBars = false
|
||||
isAppearanceLightNavigationBars = isLight
|
||||
}
|
||||
}
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
private fun copyOnLongClick(vararg views: android.widget.TextView) {
|
||||
for (tv in views) {
|
||||
tv.setOnLongClickListener {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- MIB full-screen receipt close button: tinted-black disc, themed ring, white X -->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="32dp"
|
||||
android:height="32dp"
|
||||
android:viewportWidth="32"
|
||||
android:viewportHeight="32">
|
||||
<path
|
||||
android:fillColor="#4D000000"
|
||||
android:strokeColor="@color/mib_receipt_close_ring"
|
||||
android:strokeWidth="1.5"
|
||||
android:pathData="M16,1.25 A14.75,14.75 0 1,1 16,30.75 A14.75,14.75 0 1,1 16,1.25 Z" />
|
||||
<path
|
||||
android:strokeColor="#FFFFFFFF"
|
||||
android:strokeWidth="2"
|
||||
android:strokeLineCap="round"
|
||||
android:pathData="M11,11 L21,21 M21,11 L11,21" />
|
||||
</vector>
|
||||
@@ -0,0 +1,96 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Full-screen MIB receipt. The receipt card is inserted into cardHolder and its green
|
||||
header is extended under the status bar in code; the close button floats over the
|
||||
header just below the status bar. Share/Save sit pinned at the bottom of the screen. -->
|
||||
<FrameLayout
|
||||
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/mib_receipt_bg">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scroll"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:overScrollMode="never"
|
||||
android:scrollbars="none">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/cardHolder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/mib_receipt_divider" />
|
||||
|
||||
<!-- Bottom actions — nav bar inset is added to bottom padding in code -->
|
||||
<LinearLayout
|
||||
android:id="@+id/bottomBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingHorizontal="20dp"
|
||||
android:paddingTop="20dp"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/btnShareFull"
|
||||
style="@style/Widget.Material3.Button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="44dp"
|
||||
android:insetTop="0dp"
|
||||
android:insetBottom="0dp"
|
||||
android:text="Share Receipt"
|
||||
android:textAllCaps="false"
|
||||
android:letterSpacing="0"
|
||||
android:textSize="17sp"
|
||||
android:textColor="#FFFFFF"
|
||||
app:backgroundTint="@color/mib_blue"
|
||||
app:cornerRadius="10dp" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/btnSaveFull"
|
||||
style="@style/Widget.Material3.Button.OutlinedButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="44dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:insetTop="0dp"
|
||||
android:insetBottom="0dp"
|
||||
android:text="Save Receipt"
|
||||
android:textAllCaps="false"
|
||||
android:letterSpacing="0"
|
||||
android:textSize="17sp"
|
||||
android:textColor="@color/mib_blue"
|
||||
app:backgroundTint="@color/mib_receipt_bg"
|
||||
app:strokeColor="@color/mib_blue"
|
||||
app:strokeWidth="1dp"
|
||||
app:cornerRadius="10dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Close (back) button — status bar inset is added to top margin in code -->
|
||||
<ImageButton
|
||||
android:id="@+id/btnClose"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="top|end"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:src="@drawable/ic_mib_receipt_close"
|
||||
android:contentDescription="Close" />
|
||||
|
||||
</FrameLayout>
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
<!-- Green header — from/to avatars and names -->
|
||||
<FrameLayout
|
||||
android:id="@+id/receiptHeader"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="160dp"
|
||||
android:background="@drawable/mib_receipt_header_bg">
|
||||
|
||||
@@ -15,4 +15,5 @@
|
||||
<color name="mib_receipt_value">#FFFFFF</color>
|
||||
<color name="mib_receipt_divider">#33335C</color>
|
||||
<color name="mib_receipt_footer_text">#FFFFFF</color>
|
||||
<color name="mib_receipt_close_ring">#000000</color>
|
||||
</resources>
|
||||
|
||||
@@ -23,4 +23,6 @@
|
||||
<color name="mib_receipt_divider">#CAC4D0</color>
|
||||
<color name="mib_receipt_footer_text">#000000</color>
|
||||
<color name="mib_receipt_amount">#1EA833</color>
|
||||
<color name="mib_receipt_close_ring">#FFFFFF</color>
|
||||
<color name="mib_blue">#006FFC</color>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user