Skip to content
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

Feat: [:core:ui] - Migrated to KMP #2749

Draft
wants to merge 3 commits into
base: kmp-impl
Choose a base branch
from
Draft
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
8 changes: 8 additions & 0 deletions androidApp/dependencies/demoDebugRuntimeClasspath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ com.caverock:androidsvg-aar:1.4
com.google.accompanist:accompanist-drawablepainter:0.36.0
com.google.accompanist:accompanist-pager:0.34.0
com.google.accompanist:accompanist-permissions:0.34.0
com.google.accompanist:accompanist-systemuicontroller:0.30.1
com.google.android.gms:play-services-ads-identifier:18.0.0
com.google.android.gms:play-services-base:18.5.0
com.google.android.gms:play-services-basement:18.4.0
Expand Down Expand Up @@ -216,6 +217,10 @@ io.coil-kt.coil3:coil-svg-android:3.0.4
io.coil-kt.coil3:coil-svg:3.0.4
io.coil-kt.coil3:coil:3.0.4
io.github.mr0xf00:easycrop:0.1.1
io.github.vinceglb:filekit-compose-android:0.8.7
io.github.vinceglb:filekit-compose:0.8.7
io.github.vinceglb:filekit-core-android:0.8.7
io.github.vinceglb:filekit-core:0.8.7
io.insert-koin:koin-android:4.0.1-RC1
io.insert-koin:koin-androidx-compose:4.0.1-RC1
io.insert-koin:koin-annotations-jvm:1.4.0-RC4
Expand Down Expand Up @@ -261,6 +266,9 @@ org.jetbrains.androidx.lifecycle:lifecycle-runtime:2.8.3-rc01
org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-compose:2.8.3
org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-savedstate:2.8.3
org.jetbrains.androidx.lifecycle:lifecycle-viewmodel:2.8.3
org.jetbrains.androidx.navigation:navigation-common:2.8.0-alpha10
org.jetbrains.androidx.navigation:navigation-compose:2.8.0-alpha10
org.jetbrains.androidx.navigation:navigation-runtime:2.8.0-alpha10
org.jetbrains.androidx.savedstate:savedstate:1.2.2
org.jetbrains.compose.animation:animation-core:1.7.0-rc01
org.jetbrains.compose.animation:animation:1.7.0-rc01
Expand Down
8 changes: 8 additions & 0 deletions androidApp/dependencies/demoReleaseRuntimeClasspath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ com.caverock:androidsvg-aar:1.4
com.google.accompanist:accompanist-drawablepainter:0.36.0
com.google.accompanist:accompanist-pager:0.34.0
com.google.accompanist:accompanist-permissions:0.34.0
com.google.accompanist:accompanist-systemuicontroller:0.30.1
com.google.android.gms:play-services-ads-identifier:18.0.0
com.google.android.gms:play-services-base:18.5.0
com.google.android.gms:play-services-basement:18.4.0
Expand Down Expand Up @@ -211,6 +212,10 @@ io.coil-kt.coil3:coil-svg-android:3.0.4
io.coil-kt.coil3:coil-svg:3.0.4
io.coil-kt.coil3:coil:3.0.4
io.github.mr0xf00:easycrop:0.1.1
io.github.vinceglb:filekit-compose-android:0.8.7
io.github.vinceglb:filekit-compose:0.8.7
io.github.vinceglb:filekit-core-android:0.8.7
io.github.vinceglb:filekit-core:0.8.7
io.insert-koin:koin-android:4.0.1-RC1
io.insert-koin:koin-androidx-compose:4.0.1-RC1
io.insert-koin:koin-annotations-jvm:1.4.0-RC4
Expand Down Expand Up @@ -256,6 +261,9 @@ org.jetbrains.androidx.lifecycle:lifecycle-runtime:2.8.3-rc01
org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-compose:2.8.3
org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-savedstate:2.8.3
org.jetbrains.androidx.lifecycle:lifecycle-viewmodel:2.8.3
org.jetbrains.androidx.navigation:navigation-common:2.8.0-alpha10
org.jetbrains.androidx.navigation:navigation-compose:2.8.0-alpha10
org.jetbrains.androidx.navigation:navigation-runtime:2.8.0-alpha10
org.jetbrains.androidx.savedstate:savedstate:1.2.2
org.jetbrains.compose.animation:animation-core:1.7.0-rc01
org.jetbrains.compose.animation:animation:1.7.0-rc01
Expand Down
8 changes: 8 additions & 0 deletions androidApp/dependencies/prodDebugRuntimeClasspath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ com.caverock:androidsvg-aar:1.4
com.google.accompanist:accompanist-drawablepainter:0.36.0
com.google.accompanist:accompanist-pager:0.34.0
com.google.accompanist:accompanist-permissions:0.34.0
com.google.accompanist:accompanist-systemuicontroller:0.30.1
com.google.android.gms:play-services-ads-identifier:18.0.0
com.google.android.gms:play-services-base:18.5.0
com.google.android.gms:play-services-basement:18.4.0
Expand Down Expand Up @@ -216,6 +217,10 @@ io.coil-kt.coil3:coil-svg-android:3.0.4
io.coil-kt.coil3:coil-svg:3.0.4
io.coil-kt.coil3:coil:3.0.4
io.github.mr0xf00:easycrop:0.1.1
io.github.vinceglb:filekit-compose-android:0.8.7
io.github.vinceglb:filekit-compose:0.8.7
io.github.vinceglb:filekit-core-android:0.8.7
io.github.vinceglb:filekit-core:0.8.7
io.insert-koin:koin-android:4.0.1-RC1
io.insert-koin:koin-androidx-compose:4.0.1-RC1
io.insert-koin:koin-annotations-jvm:1.4.0-RC4
Expand Down Expand Up @@ -261,6 +266,9 @@ org.jetbrains.androidx.lifecycle:lifecycle-runtime:2.8.3-rc01
org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-compose:2.8.3
org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-savedstate:2.8.3
org.jetbrains.androidx.lifecycle:lifecycle-viewmodel:2.8.3
org.jetbrains.androidx.navigation:navigation-common:2.8.0-alpha10
org.jetbrains.androidx.navigation:navigation-compose:2.8.0-alpha10
org.jetbrains.androidx.navigation:navigation-runtime:2.8.0-alpha10
org.jetbrains.androidx.savedstate:savedstate:1.2.2
org.jetbrains.compose.animation:animation-core:1.7.0-rc01
org.jetbrains.compose.animation:animation:1.7.0-rc01
Expand Down
8 changes: 8 additions & 0 deletions androidApp/dependencies/prodReleaseRuntimeClasspath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ com.caverock:androidsvg-aar:1.4
com.google.accompanist:accompanist-drawablepainter:0.36.0
com.google.accompanist:accompanist-pager:0.34.0
com.google.accompanist:accompanist-permissions:0.34.0
com.google.accompanist:accompanist-systemuicontroller:0.30.1
com.google.android.gms:play-services-ads-identifier:18.0.0
com.google.android.gms:play-services-base:18.5.0
com.google.android.gms:play-services-basement:18.4.0
Expand Down Expand Up @@ -211,6 +212,10 @@ io.coil-kt.coil3:coil-svg-android:3.0.4
io.coil-kt.coil3:coil-svg:3.0.4
io.coil-kt.coil3:coil:3.0.4
io.github.mr0xf00:easycrop:0.1.1
io.github.vinceglb:filekit-compose-android:0.8.7
io.github.vinceglb:filekit-compose:0.8.7
io.github.vinceglb:filekit-core-android:0.8.7
io.github.vinceglb:filekit-core:0.8.7
io.insert-koin:koin-android:4.0.1-RC1
io.insert-koin:koin-androidx-compose:4.0.1-RC1
io.insert-koin:koin-annotations-jvm:1.4.0-RC4
Expand Down Expand Up @@ -256,6 +261,9 @@ org.jetbrains.androidx.lifecycle:lifecycle-runtime:2.8.3-rc01
org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-compose:2.8.3
org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-savedstate:2.8.3
org.jetbrains.androidx.lifecycle:lifecycle-viewmodel:2.8.3
org.jetbrains.androidx.navigation:navigation-common:2.8.0-alpha10
org.jetbrains.androidx.navigation:navigation-compose:2.8.0-alpha10
org.jetbrains.androidx.navigation:navigation-runtime:2.8.0-alpha10
org.jetbrains.androidx.savedstate:savedstate:1.2.2
org.jetbrains.compose.animation:animation-core:1.7.0-rc01
org.jetbrains.compose.animation:animation:1.7.0-rc01
Expand Down
42 changes: 31 additions & 11 deletions core/ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,43 @@
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
*/
plugins {
alias(libs.plugins.mifos.android.library)
alias(libs.plugins.mifos.android.library.compose)
alias(libs.plugins.mifos.kmp.library)
// alias(libs.plugins.mifos.android.library.compose)
alias(libs.plugins.jetbrainsCompose)
alias(libs.plugins.compose.compiler)
}

android {
defaultConfig {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
namespace = "org.mifos.mobile.core"
namespace = "org.mifos.mobile.core.ui"
}

dependencies {
api(projects.core.designsystem)
// api(projects.core.model)
api(projects.core.common)
api(libs.androidx.metrics)

testImplementation(libs.androidx.compose.ui.test)
androidTestImplementation(libs.bundles.androidx.compose.ui.test)
kotlin{
sourceSets{
androidMain.dependencies {
api(libs.androidx.metrics)
implementation(libs.androidx.compose.runtime)
implementation(libs.accompanist.pager)
}
commonMain.dependencies {
// api(projects.core.designsystem)
api(projects.core.model)
api(projects.core.common)
implementation(libs.jb.composeViewmodel)
implementation(libs.jb.lifecycleViewmodel)
implementation(libs.jb.lifecycleViewmodelSavedState)
implementation(libs.coil.kt)
implementation(libs.coil.kt.compose)
implementation(compose.material3)
implementation(compose.components.resources)
implementation(compose.components.uiToolingPreview)
implementation(libs.jb.composeNavigation)
implementation(libs.filekit.compose)
implementation(libs.filekit.core)
implementation(libs.accompanist.systemuicontroller)
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package org.mifos.mobile.core.ui.utils

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
<string name="retry">Retry</string>
<string name="no_data">No Data</string>
<string name="something_went_wrong">Something went wrong</string>
<string name="core_common_working">Core Common Working</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
*/
package org.mifos.mobile.core.ui.component

import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand All @@ -19,23 +17,25 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import org.jetbrains.compose.resources.DrawableResource
import org.jetbrains.compose.resources.StringResource
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.resources.stringResource
import org.mifos.mobile.core.designsystem.theme.MifosMobileTheme
import org.mifos.mobile.core.ui.utils.DevicePreviews

@Composable
fun AboutUsItemCard(
title: String,
@StringRes subtitle: Int?,
@DrawableRes iconUrl: Int?,
subtitle: StringResource?,
iconUrl: DrawableResource?,
modifier: Modifier = Modifier,
) {
Row(
modifier = modifier.padding(16.dp),
) {
iconUrl?.let { painterResource(id = it) }?.let {
iconUrl?.let { painterResource(it) }?.let {
Image(
painter = it,
contentDescription = null,
Expand All @@ -50,7 +50,7 @@ fun AboutUsItemCard(
)
if (subtitle != null) {
Text(
text = stringResource(id = subtitle),
text = stringResource(subtitle),
style = MaterialTheme.typography.bodyLarge,
modifier = Modifier.padding(end = 8.dp),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
*/
package org.mifos.mobile.core.ui.component

import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
Expand All @@ -22,25 +20,25 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import org.mifos.mobile.core.R
import mifos_mobile.core.ui.generated.resources.Res
import mifos_mobile.core.ui.generated.resources.no_internet
import org.jetbrains.compose.resources.DrawableResource
import org.jetbrains.compose.resources.StringResource
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.resources.stringResource
import org.mifos.mobile.core.designsystem.icons.MifosIcons
import org.mifos.mobile.core.designsystem.theme.MifosMobileTheme
import org.mifos.mobile.core.ui.utils.DevicePreviews

@Composable
fun EmptyDataView(
@StringRes
error: Int,
error: StringResource,
modifier: Modifier = Modifier.fillMaxSize(),
@DrawableRes
icon: Int? = null,
icon: DrawableResource? = null,
errorString: String? = null,
) {
Column(
Expand All @@ -52,8 +50,8 @@ fun EmptyDataView(
modifier = Modifier
.size(100.dp)
.padding(bottom = 12.dp),
imageVector = if (icon != null) {
ImageVector.vectorResource(id = icon)
painter = if (icon != null) {
painterResource(icon)
} else {
MifosIcons.Error
},
Expand All @@ -63,7 +61,7 @@ fun EmptyDataView(

Text(
modifier = Modifier.padding(horizontal = 20.dp),
text = errorString ?: stringResource(id = error),
text = errorString ?: stringResource(error),
style = TextStyle(fontSize = 20.sp),
color = MaterialTheme.colorScheme.onSecondary,
textAlign = TextAlign.Center,
Expand All @@ -78,7 +76,7 @@ private fun EmptyDataViewPreview(
) {
MifosMobileTheme {
EmptyDataView(
error = R.string.no_internet,
error = Res.string.no_internet,
modifier = modifier,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import androidx.compose.animation.core.spring
import androidx.compose.animation.expandVertically
import androidx.compose.animation.fadeIn
import androidx.compose.foundation.clickable
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
Expand All @@ -28,7 +27,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.scale
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import org.mifos.mobile.core.designsystem.icons.MifosIcons
import org.mifos.mobile.core.designsystem.theme.MifosMobileTheme
Expand Down Expand Up @@ -59,7 +57,6 @@ fun FaqItemHolder(
Text(
text = question.orEmpty(),
style = MaterialTheme.typography.bodyMedium,
color = if (isSystemInDarkTheme()) Color.White else Color.Black,
modifier = Modifier
.fillMaxWidth()
.weight(1f),
Expand All @@ -68,7 +65,6 @@ fun FaqItemHolder(
Icon(
imageVector = MifosIcons.ArrowDropDown,
contentDescription = "drop down",
tint = if (isSystemInDarkTheme()) Color.White else Color.Gray,
modifier = Modifier
.scale(1f, if (isSelected) -1f else 1f),
)
Expand All @@ -85,7 +81,6 @@ fun FaqItemHolder(
Text(
text = answer.orEmpty(),
style = MaterialTheme.typography.bodyMedium,
color = if (isSystemInDarkTheme()) Color.White else Color.Black,
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 8.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/
package org.mifos.mobile.core.ui.component

import androidx.annotation.StringRes
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Box
Expand All @@ -31,8 +30,9 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import org.jetbrains.compose.resources.StringResource
import org.jetbrains.compose.resources.stringResource
import org.mifos.mobile.core.designsystem.icons.MifosIcons
import org.mifos.mobile.core.designsystem.theme.MifosMobileTheme
import org.mifos.mobile.core.ui.utils.DevicePreviews
Expand All @@ -41,8 +41,7 @@ import org.mifos.mobile.core.ui.utils.DevicePreviews
fun MifosDropDownTextField(
onClick: (Int, String) -> Unit,
modifier: Modifier = Modifier,
@StringRes
labelResId: Int = 0,
labelResId: StringResource,
isEnabled: Boolean = true,
supportingText: String? = null,
error: Boolean = false,
Expand All @@ -63,7 +62,7 @@ fun MifosDropDownTextField(
OutlinedTextField(
value = selectedOption ?: "",
onValueChange = { },
label = { Text(stringResource(id = labelResId)) },
label = { Text(stringResource(labelResId)) },
interactionSource = interactionSource,
modifier = Modifier
.fillMaxWidth(),
Expand Down Expand Up @@ -108,8 +107,7 @@ fun MifosDropDownTextField(
fun MifosDropDownDoubleTextField(
onClick: (Int, Pair<String, String>) -> Unit,
modifier: Modifier = Modifier,
@StringRes
labelResId: Int = 0,
labelResId: StringResource,
isEnabled: Boolean = true,
supportingText: String? = null,
error: Boolean = false,
Expand All @@ -130,7 +128,7 @@ fun MifosDropDownDoubleTextField(
OutlinedTextField(
value = selectedOption ?: "",
onValueChange = { },
label = { Text(stringResource(id = labelResId)) },
label = { Text(stringResource(labelResId)) },
interactionSource = interactionSource,
modifier = Modifier
.fillMaxWidth(),
Expand Down
Loading
Loading