Skip to content

Commit

Permalink
feat(bank-sdk): Add custom nav bar to skonto help
Browse files Browse the repository at this point in the history
PP-626
  • Loading branch information
abolfazlimahdi committed Aug 12, 2024
1 parent 6d597d6 commit 183ed1e
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,12 @@ class ConfigurationActivity : AppCompatActivity() {
// 11 enable review screens custom bottom navigation bar
binding.layoutBottomNavigationToggles.switchReviewScreenCustomBottomNavbar.isChecked =
configuration.isReviewScreenCustomBottomNavBarEnabled

// 39 enable skonto screens custom bottom navigation bar
binding.layoutBottomNavigationToggles.switchSkontoCustomBottomNavbar.isChecked =
configuration.isSkontoCustomNavBarEnabled
// 41 enable skonto help screens custom bottom navigation bar
binding.layoutBottomNavigationToggles.switchSkontoHelpCustomBottomNavbar.isChecked =
configuration.isSkontoHelpCustomNavBarEnabled

// 12 enable image picker screens custom bottom navigation bar -> was implemented on iOS, not needed for Android

Expand Down Expand Up @@ -375,6 +378,7 @@ class ConfigurationActivity : AppCompatActivity() {
)
}

// 39 enable skonto screens custom bottom navigation bar
binding.layoutBottomNavigationToggles.switchSkontoCustomBottomNavbar.setOnCheckedChangeListener { _, isChecked ->
configurationViewModel.setConfiguration(
configurationViewModel.configurationFlow.value.copy(
Expand All @@ -383,6 +387,15 @@ class ConfigurationActivity : AppCompatActivity() {
)
}

// 41 enable skonto screens custom bottom navigation bar
binding.layoutBottomNavigationToggles.switchSkontoHelpCustomBottomNavbar.setOnCheckedChangeListener { _, isChecked ->
configurationViewModel.setConfiguration(
configurationViewModel.configurationFlow.value.copy(
isSkontoHelpCustomNavBarEnabled = isChecked
)
)
}

// 12 enable image picker screens custom bottom navigation bar -> was implemented on iOS, not needed for Android

// 13 enable onboarding screens at first launch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import net.gini.android.bank.sdk.exampleapp.ui.adapters.CustomOnButtonLoadingInd
import net.gini.android.bank.sdk.exampleapp.ui.adapters.CustomOnboardingIllustrationAdapter
import net.gini.android.bank.sdk.exampleapp.ui.adapters.CustomOnboardingNavigationBarBottomAdapter
import net.gini.android.bank.sdk.exampleapp.ui.adapters.CustomReviewNavigationBarBottomAdapter
import net.gini.android.bank.sdk.exampleapp.ui.adapters.CustomSkontoHelpNavigationBarBottomAdapter
import net.gini.android.bank.sdk.exampleapp.ui.adapters.CustomSkontoNavigationBarBottomAdapter
import net.gini.android.bank.sdk.exampleapp.ui.data.Configuration
import net.gini.android.capture.GiniCaptureDebug
Expand Down Expand Up @@ -285,6 +286,12 @@ class ConfigurationViewModel @Inject constructor(
GiniBank.skontoNavigationBarBottomAdapter = null
}

if (configuration.isSkontoHelpCustomNavBarEnabled) {
GiniBank.skontoHelpNavigationBarBottomAdapter = CustomSkontoHelpNavigationBarBottomAdapter()
} else {
GiniBank.skontoHelpNavigationBarBottomAdapter = null
}

// 35 Digital invoice onboarding bottom navigation bar
if (configuration.isDigitalInvoiceOnboardingBottomNavigationBarEnabled) {
GiniBank.digitalInvoiceOnboardingNavigationBarBottomAdapter =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package net.gini.android.bank.sdk.exampleapp.ui.adapters

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import net.gini.android.bank.sdk.capture.skonto.help.SkontoHelpNavigationBarBottomAdapter
import net.gini.android.bank.sdk.exampleapp.databinding.CustomSkontoHelpNavigationBarBottomBinding

class CustomSkontoHelpNavigationBarBottomAdapter:
SkontoHelpNavigationBarBottomAdapter {
var viewBinding: CustomSkontoHelpNavigationBarBottomBinding? = null

override fun setOnBackClickListener(onClick: () -> Unit) {
viewBinding?.gbsGoBack?.setOnClickListener { onClick() }
}

override fun onCreateView(container: ViewGroup): View {
val binding = CustomSkontoHelpNavigationBarBottomBinding.inflate(LayoutInflater.from(container.context), container, false)
viewBinding = binding

return viewBinding!!.root
}

override fun onDestroy() {
viewBinding = null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ data class Configuration(
// 40 enable Skonto
val isSkontoEnabled: Boolean = true,

// 41 Skonto help Custom bottom navigation
val isSkontoHelpCustomNavBarEnabled: Boolean = false,

) : Parcelable {

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorSurface"
android:minHeight="@dimen/gc_large_64">

<ImageButton
android:id="@+id/gbs_go_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/gc_large"
android:src="@drawable/gc_action_bar_back"
android:padding="@dimen/gc_medium"
app:tint="?attr/colorError"
android:background="@android:color/transparent"
android:contentDescription="@string/gc_back_button_description"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,18 @@
android:layout_height="wrap_content"
android:text="@string/custom_bottom_navbar_switch_description" />

<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/switch_skontoHelpCustomBottomNavbar"
style="@style/SwitchConfigurationStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/gc_medium_12"
android:text="@string/skonto_help_screen_custom_bottom_navbar_switch_label" />

<TextView
style="@style/TextAppearance.MaterialComponents.Caption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/custom_bottom_navbar_switch_description" />

</LinearLayout>
1 change: 1 addition & 0 deletions bank-sdk/example-app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<string name="camera_screen_custom_bottom_navbar_switch_label">Camera screen custom bottom navigation bar</string>
<string name="review_screen_custom_bottom_navbar_switch_label">Review screen custom bottom navigation bar</string>
<string name="skonto_screen_custom_bottom_navbar_switch_label">Skonto screen custom bottom navigation bar</string>
<string name="skonto_help_screen_custom_bottom_navbar_switch_label">Skonto help screen custom bottom navigation bar</string>
<string name="onboarding_screens_at_every_launch_switch_label">Onboarding screens at every launch</string>
<string name="onboarding_screens_at_first_launch_switch_label">Onboarding screens at first launch</string>
<string name="onboarding_screens_at_every_launch_switch_description">Overwrites \'Onboarding screens at first launch\'.</string>
Expand Down
12 changes: 12 additions & 0 deletions bank-sdk/sdk/src/main/java/net/gini/android/bank/sdk/GiniBank.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import net.gini.android.bank.sdk.capture.digitalinvoice.view.DefaultDigitalInvoi
import net.gini.android.bank.sdk.capture.digitalinvoice.view.DigitalInvoiceNavigationBarBottomAdapter
import net.gini.android.bank.sdk.capture.digitalinvoice.view.DigitalInvoiceOnboardingNavigationBarBottomAdapter
import net.gini.android.bank.sdk.capture.skonto.SkontoNavigationBarBottomAdapter
import net.gini.android.bank.sdk.capture.skonto.help.SkontoHelpNavigationBarBottomAdapter
import net.gini.android.bank.sdk.error.AmountParsingException
import net.gini.android.bank.sdk.pay.getBusinessIntent
import net.gini.android.bank.sdk.pay.getRequestId
Expand Down Expand Up @@ -114,6 +115,17 @@ object GiniBank {
get() = skontoNavigationBarBottomAdapterInstance?.viewAdapter


internal var skontoHelpNavigationBarBottomAdapterInstance: InjectedViewAdapterInstance<SkontoHelpNavigationBarBottomAdapter>? =
null

var skontoHelpNavigationBarBottomAdapter: SkontoHelpNavigationBarBottomAdapter?
set(value) {
skontoHelpNavigationBarBottomAdapterInstance =
value?.let { InjectedViewAdapterInstance(it) }
}
get() = skontoHelpNavigationBarBottomAdapterInstance?.viewAdapter


internal fun getCaptureConfiguration() = captureConfiguration

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.FrameLayout
import androidx.activity.compose.BackHandler
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
Expand All @@ -28,16 +30,17 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.fragment.app.Fragment
import androidx.navigation.findNavController
import net.gini.android.bank.sdk.GiniBank
import net.gini.android.bank.sdk.R
import net.gini.android.bank.sdk.capture.skonto.SkontoNavigationBarBottomAdapter
import net.gini.android.bank.sdk.capture.skonto.help.colors.SkontoHelpScreenColors
import net.gini.android.bank.sdk.capture.skonto.help.colors.section.SkontoHelpDescriptionSectionColors
import net.gini.android.bank.sdk.capture.skonto.help.colors.section.SkontoHelpFooterSectionColors
Expand All @@ -57,8 +60,8 @@ class SkontoHelpFragment : Fragment() {
private val isBottomNavigationBarEnabled =
GiniCapture.getInstance().isBottomNavigationBarEnabled

private val customBottomNavBarAdapter: InjectedViewAdapterInstance<SkontoNavigationBarBottomAdapter>? =
GiniBank.skontoNavigationBarBottomAdapterInstance
private val customBottomNavBarAdapter: InjectedViewAdapterInstance<SkontoHelpNavigationBarBottomAdapter>? =
GiniBank.skontoHelpNavigationBarBottomAdapterInstance
private var customBottomNavigationBarView: View? = null


Expand Down Expand Up @@ -131,7 +134,7 @@ private fun ScreenContent(
modifier: Modifier = Modifier,
screenColorScheme: SkontoHelpScreenColors = SkontoHelpScreenColors.colors(),
isBottomNavigationBarEnabled: Boolean,
customBottomNavBarAdapter: InjectedViewAdapterInstance<SkontoNavigationBarBottomAdapter>?,
customBottomNavBarAdapter: InjectedViewAdapterInstance<SkontoHelpNavigationBarBottomAdapter>?,
) {

BackHandler { navigateBack() }
Expand All @@ -149,7 +152,7 @@ private fun ScreenContent(
private fun ScreenStateContent(
onBackClicked: () -> Unit,
isBottomNavigationBarEnabled: Boolean,
customBottomNavBarAdapter: InjectedViewAdapterInstance<SkontoNavigationBarBottomAdapter>?,
customBottomNavBarAdapter: InjectedViewAdapterInstance<SkontoHelpNavigationBarBottomAdapter>?,
modifier: Modifier = Modifier,
screenColorScheme: SkontoHelpScreenColors = SkontoHelpScreenColors.colors()
) {
Expand All @@ -164,6 +167,8 @@ private fun ScreenStateContent(
colors = screenColorScheme.topAppBarColors,
onBackClicked = onBackClicked,
)
}, bottomBar = {
HelpCustomNavBarSection(customBottomNavBarAdapter, onBackClicked)
}) {
Column(
modifier = Modifier
Expand Down Expand Up @@ -197,6 +202,22 @@ private fun ScreenStateContent(

}

@Composable
private fun HelpCustomNavBarSection(
customBottomNavBarAdapter: InjectedViewAdapterInstance<SkontoHelpNavigationBarBottomAdapter>?,
onBackClicked: () -> Unit,
) {
if (customBottomNavBarAdapter != null) {
val ctx = LocalContext.current
AndroidView(factory = {
customBottomNavBarAdapter.viewAdapter.onCreateView(FrameLayout(ctx))
}, update = {
with(customBottomNavBarAdapter.viewAdapter) {
setOnBackClickListener(onBackClicked)
}
})
}
}

@Composable
private fun HelpFooterSection(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package net.gini.android.bank.sdk.capture.skonto.help

import net.gini.android.capture.view.InjectedViewAdapter

interface SkontoHelpNavigationBarBottomAdapter : InjectedViewAdapter {

/**
* Set the click listener for the back button.
*
* @param onClick the click function for the back button
*/
fun setOnBackClickListener(onClick: () -> Unit)

}

0 comments on commit 183ed1e

Please sign in to comment.