Skip to content

Commit 657eb15

Browse files
authored
Implement repayment schedule (#2513)
1 parent 37df893 commit 657eb15

File tree

15 files changed

+479
-124
lines changed

15 files changed

+479
-124
lines changed

cmp-navigation/src/commonMain/kotlin/cmp/navigation/components/MifosBottomBar.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ fun MifosBottomBar(
8787
shape = DesignToken.shapes.bottomSheet,
8888
shadow = Shadow(
8989
radius = 10.dp,
90-
spread = 5.dp,
91-
color = Color.Gray.copy(alpha = 0.40f),
92-
offset = DpOffset(x = 4.dp, 4.dp),
90+
spread = 0.dp,
91+
color = Color.Black.copy(alpha = 0.25f),
92+
offset = DpOffset(0.dp, 2.dp),
9393
),
9494
),
9595
) {

core/common/src/commonMain/kotlin/com/mifos/core/common/utils/DateHelper.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import kotlinx.datetime.LocalDate
1414
import kotlinx.datetime.LocalDateTime
1515
import kotlinx.datetime.Month
1616
import kotlinx.datetime.TimeZone
17+
import kotlinx.datetime.atStartOfDayIn
1718
import kotlinx.datetime.format
1819
import kotlinx.datetime.format.FormatStringsInDatetimeFormats
1920
import kotlinx.datetime.format.byUnicodePattern
@@ -437,4 +438,17 @@ object DateHelper {
437438

438439
return "$day $monthName $year"
439440
}
441+
442+
@OptIn(ExperimentalTime::class)
443+
fun getDateAsLongFromList(integersOfDate: List<Int>?): Long? {
444+
if (integersOfDate == null) return null
445+
val dateStr = getDateAsString(integersOfDate)
446+
return try {
447+
val dateList = getDateAsList(dateStr)
448+
val localDate = LocalDate(dateList[0], dateList[1], dateList[2])
449+
localDate.atStartOfDayIn(TimeZone.UTC).toEpochMilliseconds()
450+
} catch (e: Exception) {
451+
null
452+
}
453+
}
440454
}

core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/theme/DesignToken.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ data class AppSizes(
302302
val avatarLarge: Dp = 64.dp,
303303
val avatarLargeLarge: Dp = 128.dp,
304304
val buttonHeight: Dp = 56.dp,
305+
val buttonHeightMedium: Dp = 40.dp,
305306
val inputHeight: Dp = 56.dp,
306307
val cardMinHeight: Dp = 120.dp,
307308
val profile: Dp = 72.dp,

core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosListingComponent.kt

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import androidclient.core.ui.generated.resources.core_ui_total_value
4646
import androidclient.core.ui.generated.resources.core_ui_transfer_external_id
4747
import androidclient.core.ui.generated.resources.core_ui_type
4848
import androidclient.core.ui.generated.resources.core_ui_waived
49+
import androidx.compose.foundation.background
4950
import androidx.compose.foundation.border
5051
import androidx.compose.foundation.layout.Arrangement
5152
import androidx.compose.foundation.layout.Box
@@ -62,6 +63,7 @@ import androidx.compose.runtime.Composable
6263
import androidx.compose.ui.Alignment
6364
import androidx.compose.ui.Modifier
6465
import androidx.compose.ui.graphics.Color
66+
import androidx.compose.ui.graphics.Shape
6567
import androidx.compose.ui.text.TextStyle
6668
import androidx.compose.ui.text.style.TextOverflow
6769
import androidx.compose.ui.unit.dp
@@ -77,7 +79,9 @@ import org.jetbrains.compose.ui.tooling.preview.Preview
7779
@Composable
7880
fun MifosListingComponentOutline(
7981
modifier: Modifier = Modifier,
80-
color: Color = MaterialTheme.colorScheme.secondaryContainer,
82+
borderColor: Color = MaterialTheme.colorScheme.secondaryContainer,
83+
backgroundColor: Color = AppColors.customWhite,
84+
shape: Shape = DesignToken.shapes.medium,
8185
content: @Composable () -> Unit,
8286
) {
8387
Box(
@@ -86,9 +90,10 @@ fun MifosListingComponentOutline(
8690
.padding(DesignToken.padding.extraExtraSmall)
8791
.border(
8892
width = 1.dp,
89-
shape = DesignToken.shapes.medium,
90-
color = color,
93+
shape = shape,
94+
color = borderColor,
9195
)
96+
.background(color = backgroundColor, shape = shape)
9297
.padding(DesignToken.padding.large),
9398
) {
9499
content()
@@ -220,7 +225,7 @@ fun MifosDefaultListingComponent(
220225
data: Map<String, String>,
221226
) {
222227
MifosListingComponentOutline(
223-
color = color,
228+
borderColor = color,
224229
) {
225230
Column(
226231
modifier = Modifier.fillMaxWidth(),
@@ -238,15 +243,18 @@ fun MifosDefaultListingComponent(
238243

239244
@Composable
240245
fun MifosDefaultListingComponentFromStringResources(
241-
color: Color = MaterialTheme.colorScheme.primary.copy(alpha = 0.5f),
246+
borderColor: Color = MaterialTheme.colorScheme.primary.copy(alpha = 0.5f),
247+
verticalArrangement: Arrangement.Vertical = Arrangement.spacedBy(DesignToken.padding.extraExtraSmall),
248+
backgroundColor: Color = AppColors.customWhite,
242249
data: Map<StringResource, String>,
243250
) {
244251
MifosListingComponentOutline(
245-
color = color,
252+
borderColor = borderColor,
253+
backgroundColor = backgroundColor,
246254
) {
247255
Column(
248256
modifier = Modifier.fillMaxWidth(),
249-
verticalArrangement = Arrangement.spacedBy(DesignToken.padding.extraExtraSmall),
257+
verticalArrangement = verticalArrangement,
250258
) {
251259
data.forEach { (key, value) ->
252260
MifosListingRowItem(

core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosStepper.kt

Lines changed: 53 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ package com.mifos.core.ui.components
1111

1212
import androidx.compose.foundation.background
1313
import androidx.compose.foundation.clickable
14+
import androidx.compose.foundation.layout.Arrangement
1415
import androidx.compose.foundation.layout.Box
1516
import androidx.compose.foundation.layout.Column
1617
import androidx.compose.foundation.layout.Row
@@ -73,59 +74,63 @@ fun MifosStepper(
7374
.padding(vertical = DesignToken.padding.largeIncreasedExtra)
7475
.padding(start = DesignToken.padding.small)
7576
.fillMaxWidth(),
77+
horizontalArrangement = Arrangement.SpaceBetween,
7678
) {
7779
steps.forEachIndexed { index, step ->
78-
item {
79-
Row(
80-
verticalAlignment = Alignment.Top,
81-
) {
82-
Column(
83-
horizontalAlignment = Alignment.CenterHorizontally,
84-
modifier = Modifier.width(DesignToken.sizes.avatarMediumExtra),
80+
repeat(2) { it ->
81+
item {
82+
Row(
83+
verticalAlignment = Alignment.Top,
8584
) {
86-
Box(
87-
modifier = Modifier
88-
.size(DesignToken.sizes.iconLarge)
89-
.clip(CircleShape)
90-
.background(
91-
when {
92-
index == currentIndex -> AppColors.customWhite
93-
else -> AppColors.stepperColor
94-
},
85+
if (it == 0) {
86+
Column(
87+
horizontalAlignment = Alignment.CenterHorizontally,
88+
modifier = Modifier.width(DesignToken.sizes.avatarMediumExtra),
89+
) {
90+
Box(
91+
modifier = Modifier
92+
.size(DesignToken.sizes.iconLarge)
93+
.clip(CircleShape)
94+
.background(
95+
when {
96+
index == currentIndex -> AppColors.customWhite
97+
else -> AppColors.stepperColor
98+
},
99+
)
100+
.clickable(enabled = index < currentIndex) {
101+
if (index < currentIndex) onStepChange(index)
102+
},
103+
contentAlignment = Alignment.Center,
104+
) {
105+
Text(
106+
text = (index + 1).toString(),
107+
color = MaterialTheme.colorScheme.primary,
108+
)
109+
}
110+
111+
Spacer(modifier = Modifier.height(DesignToken.padding.small))
112+
BasicText(
113+
text = step.name,
114+
autoSize = TextAutoSize.StepBased(
115+
minFontSize = 2.sp,
116+
maxFontSize = 11.sp,
117+
),
118+
style = MifosTypography.labelSmall.copy(
119+
color = AppColors.customWhite,
120+
),
121+
)
122+
}
123+
} else {
124+
if (index != steps.lastIndex) {
125+
Box(
126+
modifier = Modifier
127+
.padding(vertical = DesignToken.padding.large)
128+
.width(DesignToken.padding.small)
129+
.height(1.dp)
130+
.background(AppColors.stepperColor),
95131
)
96-
.clickable(enabled = index < currentIndex) {
97-
if (index < currentIndex) onStepChange(index)
98-
},
99-
contentAlignment = Alignment.Center,
100-
) {
101-
Text(
102-
text = (index + 1).toString(),
103-
color = MaterialTheme.colorScheme.primary,
104-
)
132+
}
105133
}
106-
107-
Spacer(modifier = Modifier.height(DesignToken.padding.small))
108-
BasicText(
109-
text = step.name,
110-
autoSize = TextAutoSize.StepBased(
111-
minFontSize = 2.sp,
112-
maxFontSize = 11.sp,
113-
),
114-
style = MifosTypography.labelSmall.copy(
115-
color = AppColors.customWhite,
116-
),
117-
)
118-
}
119-
if (index != steps.lastIndex) {
120-
Box(
121-
modifier = Modifier
122-
.padding(vertical = DesignToken.padding.large)
123-
.width(DesignToken.padding.small)
124-
.height(1.dp)
125-
.background(AppColors.stepperColor),
126-
)
127-
} else {
128-
Spacer(Modifier.width(DesignToken.padding.small))
129134
}
130135
}
131136
}

core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosTwoButtonRow.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import androidx.compose.material3.MaterialTheme
2020
import androidx.compose.material3.Text
2121
import androidx.compose.runtime.Composable
2222
import androidx.compose.ui.Modifier
23-
import androidx.compose.ui.unit.dp
2423
import com.mifos.core.designsystem.component.MifosOutlinedButton
2524
import com.mifos.core.designsystem.component.MifosTextButton
2625
import com.mifos.core.designsystem.icon.MifosIcons
@@ -62,7 +61,7 @@ fun MifosTwoButtonRow(
6261
style = MifosTypography.labelLarge,
6362
)
6463
},
65-
modifier = Modifier.weight(1f).height(40.dp),
64+
modifier = Modifier.weight(1f).height(DesignToken.sizes.buttonHeightMedium),
6665
enabled = isFirstButtonEnabled,
6766
)
6867
Spacer(Modifier.padding(DesignToken.padding.small))
@@ -85,7 +84,7 @@ fun MifosTwoButtonRow(
8584
style = MifosTypography.labelLarge,
8685
)
8786
},
88-
modifier = Modifier.weight(1f).height(40.dp),
87+
modifier = Modifier.weight(1f).height(DesignToken.sizes.buttonHeightMedium),
8988
enabled = isSecondButtonEnabled,
9089
)
9190
}

feature/loan/src/commonMain/composeResources/values/strings.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,19 @@
221221
<string name="type">Type</string>
222222
<string name="collected_on">Collected On</string>
223223

224+
<!-- Repayment Schedule -->
225+
<string name="repayment_schedule">Repayment Schedule</string>
226+
<string name="account_number">Account Number</string>
227+
<string name="disbursement_date">Disbursement Date</string>
228+
<string name="principle_paid_off">Principle Paid Off</string>">
229+
<string name="installment_paid">Installment Paid</string>
230+
<string name="installment_left">Installment Left</string>
231+
<string name="total_installments">Total Installments</string>
232+
<string name="installment">%1$s Installment</string>
233+
<string name="paid">Paid</string>
234+
<string name="due">Due</string>
235+
<string name="repayment_pay">Pay %1$s</string>
236+
224237
<!-- Apply new loan Preview screen-->
225238
<string name="loan_new_loan_on_principal_payment">On principal payment</string>
226239
<string name="loan_new_loan_on_interest_payment">On interest payment</string>

0 commit comments

Comments
 (0)