Skip to content

feat: about migrate to cmp #2377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 25, 2025
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 @@ -17,7 +17,7 @@ class CMPFeatureConventionPlugin : Plugin<Project> {
dependencies {
add("commonMainImplementation", project(":core:ui"))
add("commonMainImplementation", project(":core:designsystem"))
add("commonMainImplementation", project(":core:data"))
add("commonMainImplementation", project(":core:data"))

add("commonMainImplementation", libs.findLibrary("koin.compose").get())
add("commonMainImplementation", libs.findLibrary("koin.compose.viewmodel").get())
Expand Down
2 changes: 1 addition & 1 deletion cmp-navigation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ kotlin {
implementation(projects.core.database)
implementation(projects.core.network)

// implementation(projects.feature.about)
implementation(projects.feature.about)
// implementation(projects.feature.activate)
implementation(projects.feature.auth)
// implementation(projects.feature.center)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import cmp.navigation.AppState
import com.mifos.feature.about.navigation.aboutNavGraph

const val WELCOME_ROUTE = "home_route"

Expand All @@ -38,6 +39,8 @@ internal fun FeatureNavHost(
modifier = modifier,
) {
homeScreen()

aboutNavGraph(onBackPressed = appState.navController::popBackStack)
}
}

Expand Down
16 changes: 9 additions & 7 deletions feature/about/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
plugins {
alias(libs.plugins.mifos.android.feature)
alias(libs.plugins.mifos.android.library.compose)
alias(libs.plugins.mifos.android.library.jacoco)
alias(libs.plugins.mifos.cmp.feature)
}

android {
namespace = "com.mifos.feature.about"
}

dependencies {
// testImplementation(libs.hilt.android.testing)
// testImplementation(projects.core.testing)
// androidTestImplementation(projects.core.testing)
kotlin {
sourceSets {
commonMain.dependencies {
implementation(compose.material3)
implementation(compose.components.resources)
implementation(compose.ui)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright 2025 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/android-client/blob/master/LICENSE.md
*/
package com.mifos.feature.about

import androidclient.feature.about.generated.resources.Res
import androidclient.feature.about.generated.resources.feature_about_app_version
import androidclient.feature.about.generated.resources.feature_about_ic_source_code
import androidclient.feature.about.generated.resources.feature_about_ic_website
import androidclient.feature.about.generated.resources.feature_about_icon_twitter
import androidclient.feature.about.generated.resources.feature_about_license
import androidclient.feature.about.generated.resources.feature_about_license_sub
import androidclient.feature.about.generated.resources.feature_about_support_github
import androidclient.feature.about.generated.resources.feature_about_support_twitter
import androidclient.feature.about.generated.resources.feature_about_website

val aboutItems = listOf(
AboutItem(
icon = null,
title = Res.string.feature_about_app_version,
id = AboutItems.APP_VERSION,
),
AboutItem(
icon = Res.drawable.feature_about_ic_website,
title = Res.string.feature_about_website,
id = AboutItems.OFFICIAL_WEBSITE,
),
AboutItem(
icon = Res.drawable.feature_about_icon_twitter,
title = Res.string.feature_about_support_twitter,
id = AboutItems.TWITTER,
),
AboutItem(
icon = Res.drawable.feature_about_ic_source_code,
title = Res.string.feature_about_support_github,
id = AboutItems.SOURCE_CODE,
),
AboutItem(
icon = null,
title = Res.string.feature_about_license,
subtitle = Res.string.feature_about_license_sub,
id = AboutItems.LICENSE,
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,22 @@
package com.mifos.feature.about

import androidx.compose.ui.graphics.Color
import org.jetbrains.compose.resources.DrawableResource
import org.jetbrains.compose.resources.StringResource

data class AboutItem(
val icon: Int?,
val title: Int,
val subtitle: Int?,
val color: Color,
val icon: DrawableResource? = null,
val title: StringResource,
val subtitle: StringResource? = null,
val color: Color? = null,
val id: AboutItems,
)

enum class AboutItems {
CONTRIBUTIONS,
APP_VERSION,
OFFICIAL_WEBSITE,
TWITTER,
SOURCE_CODE,
LICENSE,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/*
* Copyright 2025 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/android-client/blob/master/LICENSE.md
*/
package com.mifos.feature.about

import androidclient.feature.about.generated.resources.Res
import androidclient.feature.about.generated.resources.feature_about
import androidclient.feature.about.generated.resources.feature_about_app
import androidclient.feature.about.generated.resources.feature_about_ic_launcher
import androidclient.feature.about.generated.resources.feature_about_mifos
import androidclient.feature.about.generated.resources.feature_about_mifos_x_droid
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ElevatedCard
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.mifos.core.designsystem.component.MifosScaffold
import com.mifos.core.designsystem.theme.aboutItemTextStyle
import com.mifos.core.designsystem.theme.aboutItemTextStyleBold
import com.mifos.core.ui.util.ShareUtils
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.resources.stringResource

@Composable
internal fun AboutScreen(
onBackPressed: () -> Unit,
) {
MifosScaffold(
title = stringResource(Res.string.feature_about),
onBackPressed = onBackPressed,
snackbarHostState = remember { SnackbarHostState() },
) { paddingValues ->
LazyColumn(
modifier = Modifier
.padding(paddingValues),
horizontalAlignment = Alignment.CenterHorizontally,
) {
item {
Box(modifier = Modifier.fillMaxWidth()) {
Image(
modifier = Modifier.size(100.dp).align(Alignment.Center),
painter = painterResource(Res.drawable.feature_about_ic_launcher),
contentDescription = "App icon",
)
}

Text(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
text = stringResource(Res.string.feature_about_mifos_x_droid),
style = aboutItemTextStyleBold,
)
Text(
modifier = Modifier
.fillMaxWidth()
.padding(start = 16.dp, end = 16.dp),
text = stringResource(Res.string.feature_about_app),
style = aboutItemTextStyle,
)
Text(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp)
.clickable {
ShareUtils.openUrl("https://github.com/openMF/android-client/graphs/contributors")
},
text = stringResource(Res.string.feature_about_mifos),
style = MaterialTheme.typography.bodyMedium,
textAlign = TextAlign.Center,
)
}
items(aboutItems) { about ->
AboutCardItem(about = about) {
when (it) {
AboutItems.CONTRIBUTIONS -> ShareUtils.openUrl("https://github.com/openMF/android-client/graphs/contributors")
AboutItems.APP_VERSION -> Unit
AboutItems.OFFICIAL_WEBSITE -> ShareUtils.openUrl("https://openmf.github.io/mobileapps.github.io/")
AboutItems.TWITTER -> ShareUtils.openUrl("https://twitter.com/mifos")
AboutItems.SOURCE_CODE -> ShareUtils.openUrl("https://github.com/openMF/android-client")
AboutItems.LICENSE -> ShareUtils.openUrl("https://github.com/openMF/android-client/blob/master/LICENSE.md")
}
}
}
}
}
}

@Composable
private fun AboutCardItem(
about: AboutItem,
onOptionClick: (AboutItems) -> Unit,
) {
ElevatedCard(
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),
elevation = CardDefaults.elevatedCardElevation(0.dp),
onClick = { onOptionClick(about.id) },
) {
Row(
modifier = Modifier.padding(16.dp),
verticalAlignment = Alignment.CenterVertically,
) {
about.icon?.let {
Icon(
painter = painterResource(it),
contentDescription = stringResource(about.title),
)
}
Column {
Text(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
text = stringResource(about.title),
style = MaterialTheme.typography.titleMedium,
)
about.subtitle?.let {
Text(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
text = stringResource(it),
style = MaterialTheme.typography.bodyMedium,
)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
*/
package com.mifos.feature.about

import org.jetbrains.compose.resources.StringResource

sealed class AboutUiState {

data object Loading : AboutUiState()

data class Error(val message: Int) : AboutUiState()
data class Error(val message: StringResource) : AboutUiState()

data class AboutOptions(val aboutOptions: List<AboutItem>) : AboutUiState()
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@
*/
package com.mifos.feature.about.navigation

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import com.mifos.feature.about.AboutScreen

/**
* Created by Pronay Sarker on 10/08/2024 (7:56 AM)
*/
fun NavGraphBuilder.aboutScreen(
fun NavController.navigateToAboutScreen() {
navigate(AboutScreens.AboutScreen.route)
}

fun NavGraphBuilder.aboutNavGraph(
onBackPressed: () -> Unit,
) {
composable(AboutScreens.AboutScreen.route) {
Expand Down
Loading