Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(internal-sdk): Built share with landscape UI #636

Open
wants to merge 44 commits into
base: feat(internal-payment-sdk)-Landscape-mode
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
44f4293
feature(bank-sdk): Skonto. Amounts validation message
ndubkov-distcotech Nov 5, 2024
9ba08b2
Merge branch 'main' into PP-763-skonto-validation
ndubkov-distcotech Nov 5, 2024
252ae9f
feature(bank-sdk): Code refactor
ndubkov-distcotech Nov 5, 2024
7a84154
feature(bank-sdk): Implemented keyboard hide detection
ndubkov-distcotech Nov 6, 2024
92ce8c1
feature(bank-sdk): Added tests
ndubkov-distcotech Nov 6, 2024
109538e
feature(bank-sdk): Tests refactor
ndubkov-distcotech Nov 7, 2024
115cafe
feature(bank-sdk): Skonto + RA validation implementation
ndubkov-distcotech Nov 12, 2024
bfd1930
feature(bank-sdk): Validators refactor
ndubkov-distcotech Nov 12, 2024
ede938b
Merge branch 'PP-763-skonto-validation' into PP-795-skonto-ra-validation
ndubkov-distcotech Nov 12, 2024
c79be12
feature(bank-sdk): Code refactor
ndubkov-distcotech Nov 12, 2024
67e6ec5
feature(bank-sdk): Code refactor
ndubkov-distcotech Nov 12, 2024
f70c625
Merge branch 'PP-763-skonto-validation' into PP-795-skonto-ra-validation
ndubkov-distcotech Nov 12, 2024
6897ffe
feature(bank-sdk): Skonto. MVI Orbit implementation
ndubkov-distcotech Nov 13, 2024
84f627c
feature(bank-sdk): Skonto. Code refactor
ndubkov-distcotech Nov 15, 2024
c0418d5
feature(bank-sdk): Skonto. Code refactor
ndubkov-distcotech Nov 15, 2024
fa382b0
feature(bank-sdk): Skonto. Code refactor
ndubkov-distcotech Nov 17, 2024
2677e9d
Merge branch 'PP-763-skonto-validation' into PP-763-skonto-validation…
ndubkov-distcotech Nov 17, 2024
9aa0ad7
feature(bank-sdk): Skonto. Tests fix
ndubkov-distcotech Nov 18, 2024
b6a6158
Merge branch 'PP-763-skonto-validation-mvi-orbit' into PP-795-skonto-…
ndubkov-distcotech Nov 18, 2024
ca620ae
feature(bank-sdk): Skonto + RA. MVI orbit update
ndubkov-distcotech Nov 18, 2024
4636487
feature(bank-sdk): Skonto + RA. Code refactor
ndubkov-distcotech Nov 20, 2024
d945049
feature(bank-sdk): Skonto + RA. Code refactor
ndubkov-distcotech Nov 21, 2024
6550f08
doc(health-sdk): Updated documentation about payment state handling
llevente Nov 28, 2024
e67305c
fix(health-sdk): Added crash prevention to back handling
llevente Nov 28, 2024
92bcf2c
docs(health-sdk): Fixed code block in docs
llevente Nov 28, 2024
ec8c6a9
docs(health-sdk): Fix
llevente Nov 28, 2024
af0330f
docs(health-sdk): Fixed block from java to kotlin
llevente Nov 28, 2024
84c97bb
docs(health-sdk): Review changes
llevente Nov 28, 2024
9ca03a9
feature(bank-sdk): Skonto + RA. Code refactor
ndubkov-distcotech Dec 2, 2024
00a13ed
feature(bank-sdk): Skonto + RA. Code refactor
ndubkov-distcotech Dec 2, 2024
b9546ee
feature(bank-sdk): Skonto + RA. Code refactor
ndubkov-distcotech Dec 2, 2024
69ac396
feature(bank-sdk): Skonto + RA. Code refactor
ndubkov-distcotech Dec 2, 2024
f8b7d64
feature(bank-sdk): Skonto + RA. Code refactor
ndubkov-distcotech Dec 2, 2024
e7c2733
Merge pull request #632 from gini/IPC-490-update-docs--and-code
llevente Dec 2, 2024
fa6c792
feat(internal-sdk): Buiilt share with landscape UI
llevente Dec 3, 2024
3be6e18
feature(bank-sdk): Skonto + RA. Code refactor
ndubkov-distcotech Dec 3, 2024
a9757f4
Merge branch 'main' into PP-795-skonto-ra-validation
ndubkov-distcotech Dec 3, 2024
25d0458
feature(bank-sdk): Skonto + RA. Code refactor
ndubkov-distcotech Dec 3, 2024
029551d
Merge pull request #618 from gini/PP-795-skonto-ra-validation
ndubkov-distcotech Dec 3, 2024
ed089c1
feat(internal-payment-sdk): Added alternative text for accesibility
llevente Dec 6, 2024
7441447
feat(health-sdk): Added alternative text for accesibility
llevente Dec 6, 2024
11c3b92
Merge branch 'IPC-407-alternative-texts' into IPC-480-landscape-share…
llevente Dec 6, 2024
1e50d8f
feat(internal-payment-sdk): Added alternative text to QR image
llevente Dec 6, 2024
4d4dd73
fix(internal-payment-sdk): Detekt fix
llevente Dec 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bank-sdk/sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ dependencies {
implementation(libs.koin.android)
implementation(libs.koin.androidx.compose)

implementation(libs.orbitmvi.test)
implementation(libs.orbitmvi.compose)
implementation(libs.orbitmvi.viewmodel)

testImplementation(libs.junit)
testImplementation(libs.mockk)
testImplementation(libs.kotlinx.coroutines.test)
Expand Down
2 changes: 1 addition & 1 deletion bank-sdk/sdk/detekt-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
<ID>NewLineAtEndOfFile:SkontoFragment.kt$net.gini.android.bank.sdk.capture.skonto.SkontoFragment.kt</ID>
<ID>NewLineAtEndOfFile:SkontoFragmentContract.kt$net.gini.android.bank.sdk.capture.skonto.SkontoFragmentContract.kt</ID>
<ID>NewLineAtEndOfFile:SkontoFragmentListener.kt$net.gini.android.bank.sdk.capture.skonto.SkontoFragmentListener.kt</ID>
<ID>NewLineAtEndOfFile:SkontoFragmentViewModel.kt$net.gini.android.bank.sdk.capture.skonto.SkontoFragmentViewModel.kt</ID>
<ID>NewLineAtEndOfFile:SkontoFragmentViewModel.kt$net.gini.android.bank.sdk.capture.skonto.viewmodel.SkontoFragmentViewModel.kt</ID>
<ID>NewLineAtEndOfFile:SkontoInfoDialogColors.kt$net.gini.android.bank.sdk.capture.skonto.colors.section.SkontoInfoDialogColors.kt</ID>
<ID>NewLineAtEndOfFile:SkontoInvoiceScanSectionColors.kt$net.gini.android.bank.sdk.capture.skonto.colors.section.SkontoInvoiceScanSectionColors.kt</ID>
<ID>NewLineAtEndOfFile:SkontoNavigationBarBottomAdapter.kt$net.gini.android.bank.sdk.capture.skonto.SkontoNavigationBarBottomAdapter.kt</ID>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

package net.gini.android.bank.sdk.capture.digitalinvoice.skonto

import android.annotation.SuppressLint
import android.content.res.Configuration.UI_MODE_NIGHT_YES
import android.icu.util.Calendar
import android.os.Bundle
Expand Down Expand Up @@ -44,7 +43,6 @@ import androidx.compose.material3.SelectableDates
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand All @@ -55,7 +53,6 @@ import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.pluralStringResource
Expand All @@ -65,23 +62,26 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import androidx.core.os.bundleOf
import androidx.fragment.app.Fragment
import androidx.fragment.app.setFragmentResult
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import androidx.navigation.findNavController
import androidx.navigation.fragment.navArgs
import net.gini.android.bank.sdk.GiniBank
import net.gini.android.bank.sdk.R
import net.gini.android.bank.sdk.capture.digitalinvoice.skonto.args.DigitalInvoiceSkontoResultArgs
import net.gini.android.bank.sdk.capture.digitalinvoice.skonto.colors.DigitalInvoiceSkontoScreenColors
import net.gini.android.bank.sdk.capture.digitalinvoice.skonto.colors.section.DigitalInvoiceSkontoFooterSectionColors
import net.gini.android.bank.sdk.capture.digitalinvoice.skonto.colors.section.DigitalInvoiceSkontoInfoDialogColors
import net.gini.android.bank.sdk.capture.digitalinvoice.skonto.colors.section.DigitalInvoiceSkontoInvoicePreviewSectionColors
import net.gini.android.bank.sdk.capture.digitalinvoice.skonto.colors.section.DigitalInvoiceSkontoSectionColors
import net.gini.android.bank.sdk.capture.digitalinvoice.skonto.mapper.toErrorMessage
import net.gini.android.bank.sdk.capture.digitalinvoice.skonto.viewmodel.DigitalInvoiceSkontoViewModel
import net.gini.android.bank.sdk.capture.skonto.model.SkontoData
import net.gini.android.bank.sdk.capture.skonto.model.SkontoEdgeCase
import net.gini.android.bank.sdk.di.koin.giniBankViewModel
import net.gini.android.bank.sdk.util.disallowScreenshots
import net.gini.android.bank.sdk.util.ui.keyboardAsState
import net.gini.android.capture.Amount
import net.gini.android.capture.GiniCapture
import net.gini.android.capture.internal.util.ActivityHelper
Expand All @@ -93,8 +93,11 @@ import net.gini.android.capture.ui.components.topbar.GiniTopBar
import net.gini.android.capture.ui.components.topbar.GiniTopBarColors
import net.gini.android.capture.ui.theme.GiniTheme
import net.gini.android.capture.ui.theme.modifier.tabletMaxWidth
import net.gini.android.capture.util.compose.keyboardPadding
import net.gini.android.capture.view.InjectedViewAdapterInstance
import org.koin.core.parameter.parametersOf
import org.orbitmvi.orbit.compose.collectAsState
import org.orbitmvi.orbit.compose.collectSideEffect
import java.math.BigDecimal
import java.math.RoundingMode
import java.time.LocalDate
Expand Down Expand Up @@ -149,12 +152,9 @@ class DigitalInvoiceSkontoFragment : Fragment() {
isBottomNavigationBarEnabled = isBottomNavigationBarEnabled,
customBottomNavBarAdapter = customBottomNavBarAdapter,
navigateBack = {
setFragmentResult(REQUEST_KEY, Bundle().apply {
putParcelable(
RESULT_KEY,
viewModel.provideFragmentResult()
)
}
setFragmentResult(
REQUEST_KEY,
bundleOf(RESULT_KEY to it)
)
findNavController().popBackStack()
},
Expand Down Expand Up @@ -182,27 +182,11 @@ class DigitalInvoiceSkontoFragment : Fragment() {
}
}

@Composable
@SuppressLint("ComposableNaming")
private fun DigitalInvoiceSkontoViewModel.collectSideEffect(
action: (DigitalInvoiceSkontoSideEffect) -> Unit
) {

val lifecycleOwner = LocalLifecycleOwner.current

LaunchedEffect(sideEffectFlow, lifecycleOwner) {
lifecycleOwner.lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED) {
sideEffectFlow.collect {
action(it)
}
}
}
}

@Composable
private fun ScreenContent(
isBottomNavigationBarEnabled: Boolean,
navigateBack: () -> Unit,
navigateBack: (DigitalInvoiceSkontoResultArgs) -> Unit,
navigateToHelpScreen: () -> Unit,
navigateToInvoiceScreen: (documentId: String, infoTextLines: List<String>) -> Unit,
viewModel: DigitalInvoiceSkontoViewModel,
Expand All @@ -211,16 +195,24 @@ private fun ScreenContent(
screenColorScheme: DigitalInvoiceSkontoScreenColors = DigitalInvoiceSkontoScreenColors.colors(),
) {

BackHandler { navigateBack() }
BackHandler { viewModel.onBackClicked() }

val state by viewModel.stateFlow.collectAsState()
val state by viewModel.collectAsState()
val keyboardState by keyboardAsState()

LaunchedEffect(keyboardState) {
viewModel.onKeyboardStateChanged(keyboardState)
}

viewModel.collectSideEffect {
when (it) {
is DigitalInvoiceSkontoSideEffect.OpenInvoiceScreen ->
is SkontoSideEffect.OpenInvoiceScreen ->
navigateToInvoiceScreen(it.documentId, it.infoTextLines)

DigitalInvoiceSkontoSideEffect.OpenHelpScreen ->
is SkontoSideEffect.NavigateBack ->
navigateBack(it.args)

SkontoSideEffect.OpenHelpScreen ->
navigateToHelpScreen()
}
}
Expand All @@ -232,18 +224,18 @@ private fun ScreenContent(
onSkontoAmountChange = viewModel::onSkontoAmountFieldChanged,
onDueDateChanged = viewModel::onSkontoDueDateChanged,
isBottomNavigationBarEnabled = isBottomNavigationBarEnabled,
onBackClicked = navigateBack,
onBackClicked = viewModel::onBackClicked,
onInfoBannerClicked = viewModel::onInfoBannerClicked,
onInfoDialogDismissed = viewModel::onInfoDialogDismissed,
onInvoiceClicked = viewModel::onInvoiceClicked,
customBottomNavBarAdapter = customBottomNavBarAdapter,
onHelpClicked = viewModel::onHelpClicked
onHelpClicked = viewModel::onHelpClicked,
)
}

@Composable
private fun ScreenStateContent(
state: DigitalInvoiceSkontoScreenState,
state: SkontoScreenState,
isBottomNavigationBarEnabled: Boolean,
onSkontoAmountChange: (BigDecimal) -> Unit,
onDueDateChanged: (LocalDate) -> Unit,
Expand All @@ -257,7 +249,7 @@ private fun ScreenStateContent(
screenColorScheme: DigitalInvoiceSkontoScreenColors = DigitalInvoiceSkontoScreenColors.colors()
) {
when (state) {
is DigitalInvoiceSkontoScreenState.Ready -> ScreenReadyState(
is SkontoScreenState.Ready -> ScreenReadyState(
modifier = modifier,
state = state,
screenColorScheme = screenColorScheme,
Expand All @@ -277,7 +269,7 @@ private fun ScreenStateContent(

@Composable
private fun ScreenReadyState(
state: DigitalInvoiceSkontoScreenState.Ready,
state: SkontoScreenState.Ready,
onBackClicked: () -> Unit,
onInvoiceClicked: () -> Unit,
onHelpClicked: () -> Unit,
Expand All @@ -292,6 +284,8 @@ private fun ScreenReadyState(
) {

val scrollState = rememberScrollState()
val keyboardPadding by keyboardPadding(108.dp, scrollState)

Scaffold(
modifier = modifier,
containerColor = screenColorScheme.backgroundColor,
Expand All @@ -316,7 +310,8 @@ private fun ScreenReadyState(
Column(
modifier = Modifier
.padding(it)
.verticalScroll(scrollState),
.verticalScroll(scrollState)
.padding(bottom = keyboardPadding),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Column(
Expand Down Expand Up @@ -352,6 +347,7 @@ private fun ScreenReadyState(
onDueDateChanged = onDueDateChanged,
edgeCase = state.edgeCase,
onInfoBannerClicked = onInfoBannerClicked,
skontoAmountValidationError = state.skontoAmountValidationError,
)
}
}
Expand Down Expand Up @@ -534,9 +530,11 @@ private fun SkontoSection(
onInfoBannerClicked: () -> Unit,
edgeCase: SkontoEdgeCase?,
colors: DigitalInvoiceSkontoSectionColors,
skontoAmountValidationError: SkontoScreenState.Ready.SkontoAmountValidationError?,
modifier: Modifier = Modifier,
) {
val dateFormatter = DateTimeFormatter.ofPattern("dd.MM.yyyy")
val resources = LocalContext.current.resources

var isDatePickerVisible by remember { mutableStateOf(false) }
Card(
Expand Down Expand Up @@ -651,6 +649,10 @@ private fun SkontoSection(
)
}
},
isError = skontoAmountValidationError != null,
supportingText = skontoAmountValidationError?.toErrorMessage(
resources = resources,
)
)

val dueDateOnClickSource = remember { MutableInteractionSource() }
Expand Down Expand Up @@ -891,7 +893,7 @@ private fun Float.formatAsDiscountPercentage(): String {
return "${value.toString().trimEnd('0').trimEnd('.')}%"
}

private val previewState = DigitalInvoiceSkontoScreenState.Ready(
private val previewState = SkontoScreenState.Ready(
isSkontoSectionActive = true,
paymentInDays = 14,
skontoPercentage = BigDecimal("3"),
Expand All @@ -901,4 +903,5 @@ private val previewState = DigitalInvoiceSkontoScreenState.Ready(
paymentMethod = SkontoData.SkontoPaymentMethod.PayPal,
edgeCase = SkontoEdgeCase.PayByCashOnly,
edgeCaseInfoDialogVisible = false,
skontoAmountValidationError = null
)
Original file line number Diff line number Diff line change
@@ -1,18 +1,57 @@
package net.gini.android.bank.sdk.capture.digitalinvoice.skonto

import net.gini.android.bank.sdk.capture.digitalinvoice.skonto.args.DigitalInvoiceSkontoArgs
import net.gini.android.bank.sdk.capture.digitalinvoice.skonto.validation.DigitalInvoiceSkontoAmountValidator
import net.gini.android.bank.sdk.capture.digitalinvoice.skonto.viewmodel.DigitalInvoiceSkontoViewModel
import net.gini.android.bank.sdk.capture.digitalinvoice.skonto.viewmodel.SkontoScreenInitialStateFactory
import net.gini.android.bank.sdk.capture.digitalinvoice.skonto.viewmodel.intent.BackClickIntent
import net.gini.android.bank.sdk.capture.digitalinvoice.skonto.viewmodel.intent.InfoBannerInteractionIntent
import net.gini.android.bank.sdk.capture.digitalinvoice.skonto.viewmodel.intent.InvoiceClickIntent
import net.gini.android.bank.sdk.capture.digitalinvoice.skonto.viewmodel.intent.KeyboardStateChangeIntent
import net.gini.android.bank.sdk.capture.digitalinvoice.skonto.viewmodel.intent.SkontoAmountFieldChangeIntent
import net.gini.android.bank.sdk.capture.digitalinvoice.skonto.viewmodel.intent.SkontoDueDateChangeIntent
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.dsl.module

val digitalInvoiceSkontoScreenModule = module {
viewModel { (data: DigitalInvoiceSkontoArgs) ->
DigitalInvoiceSkontoViewModel(
args = data,
getSkontoDiscountPercentageUseCase = get(),
getSkontoEdgeCaseUseCase = get(),
getSkontoRemainingDaysUseCase = get(),
skontoScreenInitialStateFactory = get(),
invoiceClickIntent = get(),
backClickIntent = get(),
infoBannerInteractionIntent = get(),
keyboardStateChangeIntent = get(),
skontoDueDateChangeIntent = get(),
skontoAmountFieldChangeIntent = get()
)
}
factory { DigitalInvoiceSkontoAmountValidator() }
factory {
SkontoScreenInitialStateFactory(
getSkontoEdgeCaseUseCase = get()
)
}
factory {
InvoiceClickIntent(
lastAnalyzedDocumentProvider = get(),
skontoInvoicePreviewTextLinesFactory = get()
skontoInvoicePreviewTextLinesFactory = get(),
)
}
factory { BackClickIntent() }
factory { InfoBannerInteractionIntent() }
factory { KeyboardStateChangeIntent() }
factory {
SkontoDueDateChangeIntent(
getSkontoRemainingDaysUseCase = get(),
getSkontoEdgeCaseUseCase = get(),
)
}
factory {
SkontoAmountFieldChangeIntent(
digitalInvoiceSkontoAmountValidator = get(),
getSkontoDiscountPercentageUseCase = get(),
)
}

}
Loading
Loading