Skip to content

Commit e38f2cb

Browse files
refactor #1537: migrated faq screen to compose
1 parent 96f627e commit e38f2cb

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

mifospay/src/main/java/org/mifos/mobilewallet/mifospay/faq/presenter/FAQViewModel.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class FAQViewModel @Inject constructor() : ViewModel() {
1414
FAQ(R.string.question1, R.string.answer1),
1515
FAQ(R.string.question2, R.string.answer2),
1616
FAQ(R.string.question3, R.string.answer3),
17-
FAQ(R.string.question4, R.string.answer4),
17+
FAQ(R.string.question4, R.string.answer4)
1818
)
1919
}
2020
}

mifospay/src/main/java/org/mifos/mobilewallet/mifospay/faq/ui/FaqScreen.kt

+27-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import org.mifos.mobilewallet.mifospay.R
1414
import org.mifos.mobilewallet.mifospay.designsystem.component.FaqItemScreen
1515
import org.mifos.mobilewallet.mifospay.designsystem.component.MifosTopBar
1616
import org.mifos.mobilewallet.mifospay.faq.presenter.FAQViewModel
17+
import org.mifos.mobilewallet.mifospay.utils.FAQUtils.getFAQPreviewList
1718

1819
@Composable
1920
fun FaqScreen(
@@ -29,7 +30,31 @@ fun FaqScreen(
2930
.weight(1f)
3031
.fillMaxWidth()
3132
) {
32-
itemsIndexed(items = faqViewModel.getFAQ()) { index, faqItem ->
33+
itemsIndexed(items = faqViewModel.getFAQ()) { _, faqItem ->
34+
FaqItemScreen(
35+
question = stringResource(id = faqItem.question),
36+
answer = faqItem.answer?.let { stringResource(id = it) }
37+
)
38+
}
39+
}
40+
}
41+
}
42+
43+
@Composable
44+
fun FaqScreen(
45+
navigateBack: () -> Unit,
46+
faqList: List<FAQ>
47+
) {
48+
Column(modifier = Modifier.fillMaxSize()) {
49+
MifosTopBar(
50+
topBarTitle = R.string.frequently_asked_questions,
51+
backPress = { navigateBack.invoke() })
52+
LazyColumn(
53+
modifier = Modifier
54+
.weight(1f)
55+
.fillMaxWidth()
56+
) {
57+
itemsIndexed(items = faqList) { _, faqItem ->
3358
FaqItemScreen(
3459
question = stringResource(id = faqItem.question),
3560
answer = faqItem.answer?.let { stringResource(id = it) }
@@ -42,5 +67,5 @@ fun FaqScreen(
4267
@Preview(showSystemUi = true)
4368
@Composable
4469
fun FaqScreenPreview() {
45-
FaqScreen({}, hiltViewModel())
70+
FaqScreen({}, getFAQPreviewList())
4671
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.mifos.mobilewallet.mifospay.utils
2+
3+
import org.mifos.mobilewallet.mifospay.R
4+
import org.mifos.mobilewallet.mifospay.faq.ui.FAQ
5+
6+
object FAQUtils {
7+
fun getFAQPreviewList(): List<FAQ> {
8+
return listOf(
9+
FAQ(R.string.question1, R.string.answer1),
10+
FAQ(R.string.question2, R.string.answer2),
11+
FAQ(R.string.question3, R.string.answer3),
12+
FAQ(R.string.question4, R.string.answer4)
13+
)
14+
}
15+
}

0 commit comments

Comments
 (0)