Skip to content

Commit

Permalink
feat(bank-sdk): Skonto screen. Fix currency display
Browse files Browse the repository at this point in the history
PP-648
  • Loading branch information
ndubkov-distcotech committed Jul 23, 2024
1 parent 3b7b61d commit 1bd20b3
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ private fun SkontoSection(
)
GiniAmountTextInput(
amount = amount.amount,
currencyCode = amount.currencyCode,
modifier = Modifier
.fillMaxWidth()
.padding(top = 16.dp),
Expand Down Expand Up @@ -691,6 +692,7 @@ private fun WithoutSkontoSection(
enabled = isActive,
colors = colors.amountFieldColors,
amount = amount.amount,
currencyCode = amount.currencyCode,
onValueChange = onFullAmountChange,
label = stringResource(id = R.string.gbs_skonto_section_without_discount_field_amount_hint),
trailingContent = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ import androidx.compose.material3.rememberDatePickerState
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import net.gini.android.capture.R
import net.gini.android.capture.ui.theme.GiniTheme
import java.time.Instant
import java.time.LocalDate
Expand Down Expand Up @@ -79,7 +81,7 @@ fun GiniDatePickerDialog(
modifier = Modifier.padding(horizontal = 8.dp),
onClick = { onDismissRequest() }) {
Text(
text = "Cancel",
text = stringResource(id = R.string.gc_date_picker_cancel),
style = GiniTheme.typography.body1
)
}
Expand All @@ -94,7 +96,7 @@ fun GiniDatePickerDialog(
}
}) {
Text(
text = "Select",
text = stringResource(id = R.string.gc_date_picker_select),
style = GiniTheme.typography.body1
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ import androidx.compose.ui.text.input.VisualTransformation
import java.text.DecimalFormatSymbols

class DecimalInputVisualTransformation(
private val currencyCode: String,
private val isCurrencyCodeDisplay: Boolean,
private val decimalFormatter: DecimalFormatter,
) : VisualTransformation {

override fun filter(text: AnnotatedString): TransformedText {
val source = text.text
val formatted = decimalFormatter.formatDigits(source)
var formatted = decimalFormatter.formatDigits(source).trim()
if (isCurrencyCodeDisplay) {
formatted += " $currencyCode"
}

val offsetMapping = CustomOffsetMapping(
source = source,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import java.text.NumberFormat
@Composable
fun GiniAmountTextInput(
amount: BigDecimal,
currencyCode: String,
label: String,
modifier: Modifier = Modifier,
onValueChange: (BigDecimal) -> Unit,
Expand Down Expand Up @@ -63,7 +64,11 @@ fun GiniAmountTextInput(
},
trailingContent = trailingContent,
colors = colors,
visualTransformation = DecimalInputVisualTransformation(decimalFormatter = decimalFormatter),
visualTransformation = DecimalInputVisualTransformation(
decimalFormatter = decimalFormatter,
currencyCode = currencyCode,
isCurrencyCodeDisplay = !enabled,
),
)
}

Expand Down Expand Up @@ -91,6 +96,7 @@ private fun GiniTextInputPreview() {
amount = BigDecimal("1234"),
label = "Label Text",
trailingContent = { },
currencyCode = "EUR",
onValueChange = {}
)
}
Expand Down
4 changes: 4 additions & 0 deletions capture-sdk/sdk/src/main/res/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,8 @@
<string name="gc_useful_tips">Useful tips</string>
<string name="gc_iban_detected_please_take_picture">\n\nTake a photo</string>
<string name="gc_iban_detected">IBAN detected</string>
<!-- region Date Picker -->
<string name="gc_date_picker_select">Select</string>
<string name="gc_date_picker_cancel">Cancel</string>
<!-- endregion -->
</resources>
4 changes: 4 additions & 0 deletions capture-sdk/sdk/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,8 @@
<string name="gc_menu_item_close_button_content_description">Schließen, Schaltfläche</string>
<string name="gc_iban_detected_please_take_picture">\n\nMachen Sie ein Foto</string>
<string name="gc_iban_detected">IBAN erkannt</string>
<!-- region Date Picker -->
<string name="gc_date_picker_select">Auswählen</string>
<string name="gc_date_picker_cancel">Abbrechen</string>
<!-- endregion -->
</resources>

0 comments on commit 1bd20b3

Please sign in to comment.