Skip to content

Commit

Permalink
Merge pull request #526 from gini/PP-626-skonto-help-screen
Browse files Browse the repository at this point in the history
feat(bank-sdk): Add help screen to Skonto
  • Loading branch information
abolfazlimahdi authored Aug 23, 2024
2 parents 4b09fb4 + 7dcda3d commit 4fe266f
Show file tree
Hide file tree
Showing 25 changed files with 842 additions and 11 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 @@ -25,7 +25,7 @@ class CustomSkontoNavigationBarBottomAdapter : SkontoNavigationBarBottomAdapter
}

override fun setOnHelpClickListener(onClick: () -> Unit) {
// Unused now
binding?.gbsHelpBtn?.setOnClickListener { onClick() }
}

override fun onSkontoPercentageBadgeUpdated(text: String) {
Expand Down
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/colorError"
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/colorOnBackground"
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 @@ -84,7 +84,6 @@
android:background="@android:color/transparent"
android:contentDescription="@string/gbs_digital_invoice_help_info"
android:padding="@dimen/gc_medium"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@+id/gbs_pay"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/gbs_pay"
Expand Down
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 @@ -27,6 +27,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
Expand Down Expand Up @@ -155,6 +156,9 @@ class SkontoFragment : Fragment() {
navigateBack = {
findNavController()
.navigate(SkontoFragmentDirections.toCaptureFragment())
},
navigateToHelp = {
findNavController().navigate(SkontoFragmentDirections.toSkontoHelpFragment())
}
)
}
Expand All @@ -166,6 +170,7 @@ class SkontoFragment : Fragment() {
@Composable
private fun ScreenContent(
navigateBack: () -> Unit,
navigateToHelp: () -> Unit,
viewModel: SkontoFragmentViewModel,
modifier: Modifier = Modifier,
screenColorScheme: SkontoScreenColors = SkontoScreenColors.colors(),
Expand All @@ -186,6 +191,7 @@ private fun ScreenContent(
onFullAmountChange = viewModel::onFullAmountFieldChanged,
isBottomNavigationBarEnabled = isBottomNavigationBarEnabled,
onBackClicked = navigateBack,
onHelpClicked = navigateToHelp,
customBottomNavBarAdapter = customBottomNavBarAdapter,
onProceedClicked = { viewModel.onProceedClicked() },
onInfoBannerClicked = viewModel::onInfoBannerClicked,
Expand All @@ -201,6 +207,7 @@ private fun ScreenStateContent(
onFullAmountChange: (BigDecimal) -> Unit,
onDueDateChanged: (LocalDate) -> Unit,
onBackClicked: () -> Unit,
onHelpClicked: () -> Unit,
onProceedClicked: () -> Unit,
isBottomNavigationBarEnabled: Boolean,
customBottomNavBarAdapter: InjectedViewAdapterInstance<SkontoNavigationBarBottomAdapter>?,
Expand All @@ -219,6 +226,7 @@ private fun ScreenStateContent(
onDueDateChanged = onDueDateChanged,
onFullAmountChange = onFullAmountChange,
onBackClicked = onBackClicked,
onHelpClicked = onHelpClicked,
isBottomNavigationBarEnabled = isBottomNavigationBarEnabled,
customBottomNavBarAdapter = customBottomNavBarAdapter,
onProceedClicked = onProceedClicked,
Expand All @@ -232,6 +240,7 @@ private fun ScreenStateContent(
@Composable
private fun ScreenReadyState(
onBackClicked: () -> Unit,
onHelpClicked: () -> Unit,
onProceedClicked: () -> Unit,
state: SkontoFragmentContract.State.Ready,
onDiscountSectionActiveChange: (Boolean) -> Unit,
Expand All @@ -254,6 +263,7 @@ private fun ScreenReadyState(
isBottomNavigationBarEnabled = isBottomNavigationBarEnabled,
colors = screenColorScheme.topAppBarColors,
onBackClicked = onBackClicked,
onHelpClicked = onHelpClicked
)
},
bottomBar = {
Expand All @@ -263,6 +273,7 @@ private fun ScreenReadyState(
totalAmount = state.totalAmount,
isBottomNavigationBarEnabled = isBottomNavigationBarEnabled,
onBackClicked = onBackClicked,
onHelpClicked = onHelpClicked,
customBottomNavBarAdapter = customBottomNavBarAdapter,
onProceedClicked = onProceedClicked,
isSkontoSectionActive = state.isSkontoSectionActive,
Expand Down Expand Up @@ -335,6 +346,7 @@ private fun ScreenReadyState(
@Composable
private fun TopAppBar(
onBackClicked: () -> Unit,
onHelpClicked: () -> Unit,
modifier: Modifier = Modifier,
isBottomNavigationBarEnabled: Boolean,
colors: GiniTopBarColors,
Expand All @@ -345,18 +357,46 @@ private fun TopAppBar(
title = stringResource(id = R.string.gbs_skonto_screen_title),
navigationIcon = {
AnimatedVisibility(visible = !isBottomNavigationBarEnabled) {
NavigationActionBack(onClick = onBackClicked)
NavigationActionBack(modifier = Modifier.padding(start = 16.dp),onClick = onBackClicked)
}
},
actions = {
AnimatedVisibility(visible = !isBottomNavigationBarEnabled) {
NavigationActionHelp(
modifier = Modifier.padding(end = 16.dp),
onClick = onHelpClicked
)
}
})
}

@Composable
private fun NavigationActionHelp(
onClick: () -> Unit,
modifier: Modifier = Modifier,
) {
IconButton(
modifier = modifier
.width(24.dp)
.height(24.dp),
onClick = onClick
) {
Icon(
painter = painterResource(R.drawable.gbs_help_question_icon),
contentDescription = null,
)
}
}

@Composable
private fun NavigationActionBack(
onClick: () -> Unit,
modifier: Modifier = Modifier,
) {
IconButton(
modifier = modifier,
modifier = modifier
.width(24.dp)
.height(24.dp),
onClick = onClick
) {
Icon(
Expand Down Expand Up @@ -762,6 +802,7 @@ private fun FooterSection(
isBottomNavigationBarEnabled: Boolean,
isSkontoSectionActive: Boolean,
onBackClicked: () -> Unit,
onHelpClicked: () -> Unit,
onProceedClicked: () -> Unit,
modifier: Modifier = Modifier,
customBottomNavBarAdapter: InjectedViewAdapterInstance<SkontoNavigationBarBottomAdapter>?,
Expand Down Expand Up @@ -801,6 +842,7 @@ private fun FooterSection(
with(customBottomNavBarAdapter.viewAdapter) {
setOnProceedClickListener(onProceedClicked)
setOnBackClickListener(onBackClicked)
setOnHelpClickListener(onHelpClicked)
onTotalAmountUpdated(totalPriceText)
onSkontoPercentageBadgeUpdated(discountLabelText)
onSkontoPercentageBadgeVisibilityUpdate(isSkontoSectionActive)
Expand Down Expand Up @@ -875,15 +917,15 @@ private fun FooterSection(
)
}
}
val buttonPaddingStart = if (isBottomNavigationBarEnabled) 0.dp else 20.dp
val buttonPaddingEnd = if (isBottomNavigationBarEnabled) 48.dp else 24.dp
val buttonPaddingStart = if (isBottomNavigationBarEnabled) 16.dp else 20.dp
val buttonPaddingEnd = if (isBottomNavigationBarEnabled) 16.dp else 20.dp
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceEvenly
horizontalArrangement = Arrangement.Center
) {
AnimatedVisibility(visible = isBottomNavigationBarEnabled) {
NavigationActionBack(
modifier = Modifier.padding(horizontal = 4.dp),
modifier = Modifier.padding(start = 16.dp),
onClick = onBackClicked
)
}
Expand All @@ -895,6 +937,12 @@ private fun FooterSection(
onClick = onProceedClicked,
giniButtonColors = colors.continueButtonColors
)
AnimatedVisibility(visible = isBottomNavigationBarEnabled) {
NavigationActionHelp(
modifier = Modifier.padding(end = 16.dp),
onClick = onHelpClicked
)
}
}
}
}
Expand Down Expand Up @@ -927,6 +975,7 @@ private fun ScreenReadyStatePreview() {
onDueDateChanged = {},
onFullAmountChange = {},
onBackClicked = {},
onHelpClicked = {},
isBottomNavigationBarEnabled = true,
onProceedClicked = {},
customBottomNavBarAdapter = null,
Expand Down
Loading

0 comments on commit 4fe266f

Please sign in to comment.