Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import androidx.navigation.NavOptions
import org.mifos.mobile.core.ui.composableWithPushTransitions
import org.mifos.mobile.feature.settings.componenets.SettingsItems

/**
* Defines the "About Us" screen destination in the navigation graph.
*
* @param onBackClick Lambda to handle back navigation.
*/
internal fun NavGraphBuilder.aboutDestination(
onBackClick: () -> Unit,
) {
Expand All @@ -25,5 +30,10 @@ internal fun NavGraphBuilder.aboutDestination(
}
}

/**
* Navigates to the "About Us" screen.
*
* @param navOptions Optional navigation options.
*/
internal fun NavController.navigateToAbout(navOptions: NavOptions? = null) =
navigate(SettingsItems.AboutUs, navOptions)
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ import org.mifos.mobile.core.designsystem.theme.DesignToken
import org.mifos.mobile.core.designsystem.theme.MifosMobileTheme
import org.mifos.mobile.core.designsystem.theme.MifosTypography

/**
* The main entry point for the "About Us" screen. This composable function serves as a wrapper
* around the actual content, allowing for separation of concerns and easier testing.
*
* @param modifier The [Modifier] to be applied to the screen.
* @param onBackClick A lambda function to be invoked when the back button is pressed,
* triggering navigation to the previous screen.
*/
@Composable
fun AboutScreen(
modifier: Modifier = Modifier,
Expand All @@ -60,6 +68,13 @@ fun AboutScreen(
)
}

/**
* Renders the UI content for the "About Us" screen. This includes the screen's scaffold,
* top bar, and the informational content about the Mifos Initiative.
*
* @param modifier The [Modifier] to be applied to the content layout.
* @param onBackClick A lambda function to handle the back navigation event from the scaffold.
*/
@Composable
internal fun AboutScreenContent(
modifier: Modifier = Modifier,
Expand Down Expand Up @@ -154,6 +169,11 @@ internal fun AboutScreenContent(
}
}

/**
* A Jetpack Compose preview function for the [AboutScreenContent]. This allows for
* visualizing the UI component in Android Studio's preview pane without needing to
* run the entire application.
*/
@Preview
@Composable
internal fun AboutScreenContentPreview() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,24 @@ import androidx.navigation.NavOptions
import org.mifos.mobile.core.ui.composableWithPushTransitions
import org.mifos.mobile.feature.settings.componenets.SettingsItems

/**
* Navigates to the App Info screen. This is an extension function on [NavController]
* that simplifies the process of navigating to the app info destination.
*
* @param navOptions Optional [NavOptions] to apply to this navigation operation,
* allowing for customization of aspects like launch modes and animations.
*/
internal fun NavController.navigateToAppInfo(navOptions: NavOptions? = null) =
navigate(SettingsItems.AppInfo, navOptions)

/**
* Defines the composable destination for the "App Info" screen within the navigation graph.
* This sets up the route and the content to be displayed, along with screen transitions.
*
* @param onBackClick A lambda function to be invoked when the user initiates a back action.
* @param navigateToPrivacyPolicy A lambda function to navigate to the Privacy Policy screen.
* @param navigateToTermsAndConditions A lambda function to navigate to the Terms and Conditions screen.
*/
internal fun NavGraphBuilder.appInfoDestination(
onBackClick: () -> Unit,
navigateToPrivacyPolicy: () -> Unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ import org.mifos.mobile.core.designsystem.theme.DesignToken
import org.mifos.mobile.core.designsystem.theme.MifosTypography
import org.mifos.mobile.feature.settings.util.appVersion

/**
* The main composable for the App Info screen, which acts as a stateful wrapper
* around the core UI content.
*
* @param onBackClick Lambda to handle back navigation events.
* @param navigateToPrivacyPolicy Lambda to navigate to the Privacy Policy screen.
* @param modifier The [Modifier] to be applied to this screen.
* @param navigateToTermsAndConditions Lambda to navigate to the Terms and Conditions screen.
*/
@Composable
internal fun AppInfoScreen(
onBackClick: () -> Unit,
Expand All @@ -63,6 +72,15 @@ internal fun AppInfoScreen(
)
}

/**
* Renders the stateless UI content for the App Info screen. This includes details
* about the app, version, and links to legal documents.
*
* @param onBackClick Lambda to handle back navigation from the top bar.
* @param navigateToPrivacyPolicy Lambda to navigate to the Privacy Policy screen.
* @param modifier The [Modifier] to be applied to the layout.
* @param navigateToTermsAndConditions Lambda to navigate to the Terms and Conditions screen.
*/
@Suppress("UnusedParameter")
@Composable
internal fun AppInfoContent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ import org.mifos.mobile.core.designsystem.theme.AppColors
import org.mifos.mobile.core.designsystem.theme.DesignToken
import org.mifos.mobile.core.designsystem.theme.MifosTypography

/**
* A composable function that displays a confirmation dialog for logging out.
* The dialog's visibility and content are controlled by the [LogoutDialogState].
*
* @param visibilityState The state that determines whether the dialog is shown or hidden,
* and provides the necessary content and actions.
*/
@Composable
fun MifosLogoutDialog(
visibilityState: LogoutDialogState,
Expand Down Expand Up @@ -117,10 +124,27 @@ fun MifosLogoutDialog(
}
}

/**
* Represents the state of the [MifosLogoutDialog].
*/
sealed interface LogoutDialogState {

/**
* The dialog is hidden.
*/
data object Hidden : LogoutDialogState

/**
* The dialog is visible.
*
* @param description The main descriptive text of the dialog.
* @param title The title of the dialog.
* @param message A message typically shown below the main action button.
* @param messageActionText Clickable text accompanying the message.
* @param onLogout Lambda to be executed when the logout button is clicked.
* @param onNavigateToHome Lambda to be executed when the message action text is clicked.
* @param onDismiss Lambda to be executed when the dialog is dismissed.
*/
data class Shown(
val description: StringResource,
val title: StringResource,
Expand All @@ -132,6 +156,9 @@ sealed interface LogoutDialogState {
) : LogoutDialogState
}

/**
* A Jetpack Compose preview for the [MifosLogoutDialog].
*/
@Preview
@Composable
fun MifosLogoutDialogPreview() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ import org.jetbrains.compose.resources.StringResource
import org.mifos.mobile.core.common.Constants
import org.mifos.mobile.core.designsystem.icon.MifosIcons

/**
* A sealed class representing all navigable items available on the settings screen.
* Each object holds metadata for a specific setting, such as its title, subtitle, icon,
* and navigation route, making it easy to generate UI components dynamically.
*
* This class is serializable to support navigation graph persistence.
*
* @property title The string resource for the setting's title.
* @property subTitle The string resource for the setting's descriptive subtitle.
* @property icon The vector graphic icon representing the setting.
* @property route The unique navigation route string for the destination screen.
*/
@Serializable
sealed class SettingsItems(
@Contextual val title: StringResource,
Expand All @@ -53,6 +65,7 @@ sealed class SettingsItems(
// route = Constants.PROFILE,
// )

/** Represents the 'Change Password' setting. */
@Serializable
data object Password : SettingsItems(
title = Res.string.feature_settings_action_password,
Expand All @@ -61,6 +74,7 @@ sealed class SettingsItems(
route = Constants.PASSWORD,
)

/** Represents the 'Set Passcode' setting for app authentication. */
@Serializable
data object AuthPasscode : SettingsItems(
title = Res.string.feature_settings_action_auth_passcode,
Expand All @@ -69,6 +83,7 @@ sealed class SettingsItems(
route = Constants.AUTH_PASSCODE,
)

/** Represents the 'Language' selection setting. */
@Serializable
data object Language : SettingsItems(
title = Res.string.feature_settings_action_language,
Expand All @@ -78,6 +93,7 @@ sealed class SettingsItems(
)

// TODO : uncomment once ui/ux team provide a valid colours for dark theme
/** Represents the 'Display Theme' setting (e.g., light/dark mode). */
@Serializable
data object Theme : SettingsItems(
title = Res.string.feature_settings_action_theme,
Expand All @@ -94,6 +110,7 @@ sealed class SettingsItems(
// route = Constants.ENDPOINT,
// )

/** Represents the 'About Us' information screen. */
@Serializable
data object AboutUs : SettingsItems(
title = Res.string.feature_settings_action_about_us,
Expand All @@ -102,6 +119,7 @@ sealed class SettingsItems(
route = Constants.ABOUT_US,
)

/** Represents the 'FAQ' (Frequently Asked Questions) screen. */
@Serializable
data object FAQ : SettingsItems(
title = Res.string.feature_settings_action_faq,
Expand All @@ -110,6 +128,7 @@ sealed class SettingsItems(
route = Constants.FAQ,
)

/** Represents the 'Help' or support screen. */
@Serializable
data object Help : SettingsItems(
title = Res.string.feature_settings_action_help,
Expand All @@ -118,6 +137,7 @@ sealed class SettingsItems(
route = Constants.HELP,
)

/** Represents the 'App Info' screen with version and legal details. */
@Serializable
data object AppInfo : SettingsItems(
title = Res.string.feature_settings_action_app_info,
Expand All @@ -126,6 +146,7 @@ sealed class SettingsItems(
route = Constants.APP_INFO,
)

/** Represents the 'Logout' action. */
@Serializable
data object Logout : SettingsItems(
title = Res.string.feature_settings_action_logout,
Expand All @@ -135,6 +156,10 @@ sealed class SettingsItems(
)
}

/**
* An immutable list defining the order and content of items displayed on the settings screen.
* This list is used to dynamically render the settings menu.
*/
internal val settingsItems: ImmutableList<SettingsItems> = persistentListOf(
// SettingsItems.Profile,
SettingsItems.Password,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ import org.mifos.mobile.feature.settings.password.ChangePasswordViewModel
import org.mifos.mobile.feature.settings.settings.SettingsViewModel
import org.mifos.mobile.feature.settings.theme.ChangeThemeViewModel

/**
* Koin module for providing dependencies related to the settings feature.
* This module declares all the ViewModels used across the settings screens,
* making them available for dependency injection.
*/
val SettingsModule = module {
viewModelOf(::SettingsViewModel)
viewModelOf(::UpdatePasscodeViewModel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ import androidx.navigation.NavOptions
import org.mifos.mobile.core.ui.composableWithPushTransitions
import org.mifos.mobile.feature.settings.componenets.SettingsItems

/**
* Defines the composable destination for the "FAQ" (Frequently Asked Questions) screen
* within the navigation graph.
*
* @param onBackClick A lambda function to be invoked when the user initiates a back action.
* @param contact A lambda function to handle navigation to a contact or help screen.
*/
fun NavGraphBuilder.faqDestination(
onBackClick: () -> Unit,
contact: () -> Unit,
Expand All @@ -26,5 +33,12 @@ fun NavGraphBuilder.faqDestination(
)
}
}

/**
* Navigates to the "FAQ" screen. This is an extension function on [NavController]
* that simplifies the process of navigating to the FAQ destination.
*
* @param navOptions Optional [NavOptions] to apply to this navigation operation.
*/
fun NavController.navigateToFaq(navOptions: NavOptions? = null) =
navigate(SettingsItems.FAQ, navOptions)
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ import org.mifos.mobile.core.ui.component.FaqItemHolder
import org.mifos.mobile.core.ui.utils.DevicePreview
import org.mifos.mobile.core.ui.utils.EventsEffect

/**
* A stateful composable that displays the FAQ screen. It collects state and events from
* the [FaqViewModel] and delegates the UI rendering to [FaqScreenContent].
*
* @param onNavigateBack Callback to handle back navigation.
* @param onClickHelp Callback to navigate to the help/contact screen.
* @param modifier The [Modifier] to be applied to this screen.
* @param viewModel The ViewModel responsible for the screen's logic and state.
*/
@Composable
internal fun FaqScreen(
onNavigateBack: () -> Unit,
Expand All @@ -71,6 +80,13 @@ internal fun FaqScreen(
)
}

/**
* A stateless composable that renders the UI for the FAQ screen based on the provided [uiState].
*
* @param uiState The current state of the FAQ screen.
* @param onAction Callback to send actions to the ViewModel.
* @param modifier The [Modifier] to be applied to the layout.
*/
@Composable
private fun FaqScreenContent(
uiState: FaqState,
Expand All @@ -95,6 +111,14 @@ private fun FaqScreenContent(
)
}

/**
* Renders the main content of the FAQ screen, including the list of questions and answers
* or an empty state view if no FAQs are available.
*
* @param faqArrayList The list of [FAQ] items to display.
* @param selectedFaqPosition The index of the currently expanded FAQ item.
* @param onAction Callback to send actions to the ViewModel.
*/
@Composable
private fun FaqContent(
faqArrayList: List<FAQ>,
Expand Down Expand Up @@ -150,6 +174,10 @@ private fun FaqContent(
}
}

/**
* A Jetpack Compose preview for the [FaqScreenContent]. This allows for
* visualizing the UI component in Android Studio's preview pane.
*/
@DevicePreview
@Composable
fun FaqScreenPreview() {
Expand Down
Loading
Loading