-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
351 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 0 additions & 97 deletions
97
core/ui/src/commonMain/kotlin/org/mifospay/core/ui/FaqItemScreen.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
feature/faq/src/commonMain/kotlin/org/mifospay/feature/faq/FAQViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright 2024 Mifos Initiative | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* See https://github.com/openMF/mobile-wallet/blob/master/LICENSE.md | ||
*/ | ||
package org.mifospay.feature.faq | ||
|
||
import kotlinx.coroutines.flow.update | ||
import mobile_wallet.feature.faq.generated.resources.Res | ||
import mobile_wallet.feature.faq.generated.resources.feature_faq_answer1 | ||
import mobile_wallet.feature.faq.generated.resources.feature_faq_answer2 | ||
import mobile_wallet.feature.faq.generated.resources.feature_faq_answer3 | ||
import mobile_wallet.feature.faq.generated.resources.feature_faq_answer4 | ||
import mobile_wallet.feature.faq.generated.resources.feature_faq_question1 | ||
import mobile_wallet.feature.faq.generated.resources.feature_faq_question2 | ||
import mobile_wallet.feature.faq.generated.resources.feature_faq_question3 | ||
import mobile_wallet.feature.faq.generated.resources.feature_faq_question4 | ||
import org.mifospay.core.ui.utils.BaseViewModel | ||
|
||
internal class FAQViewModel : BaseViewModel<FaqState, FaqEvent, FaqAction>( | ||
initialState = FaqState(sampleFaqList), | ||
) { | ||
override fun handleAction(action: FaqAction) { | ||
when (action) { | ||
is FaqAction.ExpandFaq -> { | ||
mutableStateFlow.update { | ||
if (it.expandedFaq == action.faqId) { | ||
it.copy(expandedFaq = null) | ||
} else { | ||
it.copy(expandedFaq = action.faqId) | ||
} | ||
} | ||
} | ||
|
||
is FaqAction.NavigateBack -> { | ||
sendEvent(FaqEvent.OnNavigateBack) | ||
} | ||
} | ||
} | ||
} | ||
|
||
internal data class FaqState( | ||
val faqList: List<FAQ>, | ||
val expandedFaq: Int? = null, | ||
) | ||
|
||
internal sealed interface FaqEvent { | ||
data object OnNavigateBack : FaqEvent | ||
} | ||
|
||
internal sealed interface FaqAction { | ||
data class ExpandFaq(val faqId: Int) : FaqAction | ||
data object NavigateBack : FaqAction | ||
} | ||
|
||
/** | ||
* Retrieves a list of Frequently Asked Questions (FAQs). | ||
* | ||
* Currently, the FAQs are statically defined within this function. This is a temporary | ||
* implementation for demonstration or testing purposes. In the future, this method will | ||
* be updated to fetch the FAQ data from a backend service once the backend functionality | ||
* is implemented. This will allow for dynamic and up-to-date FAQ content. | ||
* | ||
* @return A list of [FAQ] objects containing the questions and answers. | ||
*/ | ||
internal val sampleFaqList = listOf( | ||
FAQ(1, Res.string.feature_faq_question1, Res.string.feature_faq_answer1), | ||
FAQ(2, Res.string.feature_faq_question2, Res.string.feature_faq_answer2), | ||
FAQ(3, Res.string.feature_faq_question3, Res.string.feature_faq_answer3), | ||
FAQ(4, Res.string.feature_faq_question4, Res.string.feature_faq_answer4), | ||
) |
Oops, something went wrong.