|
10 | 10 | package com.mifos.feature.recurringDeposit.newRecurringDepositAccount.pages |
11 | 11 |
|
12 | 12 | import androidclient.feature.recurringdeposit.generated.resources.Res |
13 | | -import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_next_button |
14 | | -import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_terms_page |
| 13 | +import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_back |
| 14 | +import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_calculation_days_in_year |
| 15 | +import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_interest_calculation |
| 16 | +import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_interest_compounding_period |
| 17 | +import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_interest_posting_period |
| 18 | +import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_next |
15 | 19 | import androidx.compose.foundation.layout.Column |
16 | 20 | import androidx.compose.foundation.layout.Spacer |
17 | 21 | import androidx.compose.foundation.layout.height |
18 | | -import androidx.compose.material3.Button |
19 | | -import androidx.compose.material3.Text |
| 22 | +import androidx.compose.foundation.layout.padding |
20 | 23 | import androidx.compose.runtime.Composable |
21 | 24 | import androidx.compose.ui.Alignment |
22 | 25 | import androidx.compose.ui.Modifier |
23 | | -import androidx.compose.ui.unit.dp |
| 26 | +import com.mifos.core.designsystem.component.MifosTextFieldDropdown |
| 27 | +import com.mifos.core.designsystem.theme.DesignToken |
| 28 | +import com.mifos.core.ui.components.MifosProgressIndicatorMini |
| 29 | +import com.mifos.core.ui.components.MifosTwoButtonRow |
| 30 | +import com.mifos.feature.recurringDeposit.newRecurringDepositAccount.RecurringAccountAction |
| 31 | +import com.mifos.feature.recurringDeposit.newRecurringDepositAccount.RecurringAccountState |
24 | 32 | import org.jetbrains.compose.resources.stringResource |
25 | 33 |
|
26 | 34 | @Composable |
27 | | -fun TermsPage(onNext: () -> Unit) { |
| 35 | +fun TermsPage( |
| 36 | + state: RecurringAccountState, |
| 37 | + onAction: (RecurringAccountAction) -> Unit, |
| 38 | +) { |
28 | 39 | Column(horizontalAlignment = Alignment.CenterHorizontally) { |
29 | | - Text(stringResource(Res.string.feature_recurring_deposit_terms_page)) |
30 | | - Spacer(Modifier.height(8.dp)) |
31 | | - Button(onClick = onNext) { |
32 | | - Text(stringResource(Res.string.feature_recurring_deposit_next_button)) |
| 40 | + MifosTextFieldDropdown( |
| 41 | + value = if (state.recurringDepositAccountInterestChart.interestCompoundingPeriodType == -1) { |
| 42 | + "" |
| 43 | + } else { |
| 44 | + state.template.interestCompoundingPeriodTypeOptions?.get(state.recurringDepositAccountInterestChart.interestCompoundingPeriodType)?.value |
| 45 | + ?: "" |
| 46 | + }, |
| 47 | + onValueChanged = { }, |
| 48 | + onOptionSelected = { index, value -> |
| 49 | + onAction( |
| 50 | + RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCompoundingPeriodType( |
| 51 | + index, |
| 52 | + ), |
| 53 | + ) |
| 54 | + }, |
| 55 | + options = state.template.interestCompoundingPeriodTypeOptions?.map { |
| 56 | + it.value ?: "" |
| 57 | + } ?: emptyList(), |
| 58 | + label = stringResource(Res.string.feature_recurring_deposit_interest_compounding_period), |
| 59 | + ) |
| 60 | + Spacer(modifier = Modifier.height(DesignToken.padding.large)) |
| 61 | + MifosTextFieldDropdown( |
| 62 | + value = if (state.recurringDepositAccountInterestChart.interestPostingPeriodType == -1) { |
| 63 | + "" |
| 64 | + } else { |
| 65 | + state.template.interestPostingPeriodTypeOptions?.get(state.recurringDepositAccountInterestChart.interestPostingPeriodType)?.value |
| 66 | + ?: "" |
| 67 | + }, |
| 68 | + onValueChanged = { }, |
| 69 | + onOptionSelected = { index, value -> |
| 70 | + onAction( |
| 71 | + RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestPostingPeriodType( |
| 72 | + index, |
| 73 | + ), |
| 74 | + ) |
| 75 | + }, |
| 76 | + options = state.template.interestPostingPeriodTypeOptions?.map { |
| 77 | + it.value ?: "" |
| 78 | + } ?: emptyList(), |
| 79 | + label = stringResource(Res.string.feature_recurring_deposit_interest_posting_period), |
| 80 | + ) |
| 81 | + Spacer(modifier = Modifier.height(DesignToken.padding.large)) |
| 82 | + MifosTextFieldDropdown( |
| 83 | + value = if (state.recurringDepositAccountInterestChart.interestCalculationType == -1) { |
| 84 | + "" |
| 85 | + } else { |
| 86 | + state.template.interestCalculationTypeOptions?.get(state.recurringDepositAccountInterestChart.interestCalculationType)?.value |
| 87 | + ?: "" |
| 88 | + }, |
| 89 | + onValueChanged = { }, |
| 90 | + onOptionSelected = { index, value -> |
| 91 | + onAction( |
| 92 | + RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCalculationType( |
| 93 | + index, |
| 94 | + ), |
| 95 | + ) |
| 96 | + }, |
| 97 | + options = state.template.interestCalculationTypeOptions?.map { |
| 98 | + it.value ?: "" |
| 99 | + } ?: emptyList(), |
| 100 | + label = stringResource(Res.string.feature_recurring_deposit_interest_calculation), |
| 101 | + ) |
| 102 | + Spacer(modifier = Modifier.height(DesignToken.padding.large)) |
| 103 | + MifosTextFieldDropdown( |
| 104 | + value = if (state.recurringDepositAccountInterestChart.interestCalculationDaysInYearType == -1) { |
| 105 | + "" |
| 106 | + } else { |
| 107 | + state.template.interestCalculationDaysInYearTypeOptions?.get(state.recurringDepositAccountInterestChart.interestCalculationDaysInYearType)?.value |
| 108 | + ?: "" |
| 109 | + }, |
| 110 | + onValueChanged = { }, |
| 111 | + onOptionSelected = { index, value -> |
| 112 | + onAction( |
| 113 | + RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCalculationDaysInYearType( |
| 114 | + index, |
| 115 | + ), |
| 116 | + ) |
| 117 | + }, |
| 118 | + options = state.template.interestCalculationDaysInYearTypeOptions?.map { |
| 119 | + it.value ?: "" |
| 120 | + } ?: emptyList(), |
| 121 | + label = stringResource(Res.string.feature_recurring_deposit_calculation_days_in_year), |
| 122 | + ) |
| 123 | + if (state.recurringDepositAccountDetail.isMiniLoaderActive) { |
| 124 | + MifosProgressIndicatorMini() |
33 | 125 | } |
| 126 | + |
| 127 | + MifosTwoButtonRow( |
| 128 | + firstBtnText = stringResource(Res.string.feature_recurring_deposit_back), |
| 129 | + secondBtnText = stringResource(Res.string.feature_recurring_deposit_next), |
| 130 | + onFirstBtnClick = { onAction(RecurringAccountAction.OnBackPress) }, |
| 131 | + onSecondBtnClick = { onAction(RecurringAccountAction.OnNextPress) }, |
| 132 | + isSecondButtonEnabled = state.recurringDepositAccountInterestChart.isTermsButtonEnabled, |
| 133 | + isButtonIconVisible = true, |
| 134 | + |
| 135 | + ) |
34 | 136 | } |
35 | 137 | } |
0 commit comments