-
Notifications
You must be signed in to change notification settings - Fork 618
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
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
37c9f66
cmp-migration about
kapmaurya f54fe8c
cmp-migration about
kapmaurya 581c1bd
cmp-migration about
kapmaurya f99b966
cmp-about migration
kapmaurya a45c976
Merge branch 'kmp-impl' into cmp-about
kapmaurya 30a9e47
fixed issues
itsPronay 63abbd5
removed extra part
itsPronay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
41 changes: 41 additions & 0 deletions
41
feature/about/src/commonMain/kotlin/com/mifos/feature/about/AboutData.kt
This file contains hidden or 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,41 @@ | ||
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, | ||
), | ||
) |
This file contains hidden or 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
136 changes: 136 additions & 0 deletions
136
feature/about/src/commonMain/kotlin/com/mifos/feature/about/AboutScreen.kt
This file contains hidden or 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,136 @@ | ||
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.* | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.foundation.lazy.items | ||
import androidx.compose.material3.* | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.platform.LocalUriHandler | ||
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 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, | ||
) { | ||
val uriHandler = LocalUriHandler.current | ||
|
||
kapmaurya marked this conversation as resolved.
Show resolved
Hide resolved
|
||
MifosScaffold( | ||
title = stringResource(Res.string.feature_about), | ||
onBackPressed = onBackPressed, | ||
snackbarHostState = remember { SnackbarHostState() }, | ||
) { paddingValues -> | ||
Column( | ||
modifier = Modifier.padding(paddingValues), | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
) { | ||
Image( | ||
modifier = Modifier.size(100.dp), | ||
painter = painterResource(Res.drawable.feature_about_ic_launcher), | ||
contentDescription = null, | ||
) | ||
kapmaurya marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 = TextStyle(fontSize = 16.sp), | ||
color = Color.Blue, | ||
kapmaurya marked this conversation as resolved.
Show resolved
Hide resolved
|
||
textAlign = TextAlign.Center, | ||
kapmaurya marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
LazyColumn { | ||
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 = null, | ||
) | ||
} | ||
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, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or 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
87 changes: 87 additions & 0 deletions
87
feature/about/src/commonMain/kotlin/com/mifos/feature/about/AboutViewModel.kt
This file contains hidden or 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,87 @@ | ||
/* | ||
* 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/android-client/blob/master/LICENSE.md | ||
*/ | ||
package com.mifos.feature.about | ||
|
||
import androidclient.feature.about.generated.resources.feature_about_app_version | ||
import androidclient.feature.about.generated.resources.feature_about_failed_to_load | ||
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 | ||
import androidx.compose.ui.graphics.Color.Companion.White | ||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.asStateFlow | ||
import kotlinx.coroutines.launch | ||
|
||
class AboutViewModel : ViewModel() { | ||
|
||
private val _aboutUiState = MutableStateFlow<AboutUiState>(AboutUiState.Loading) | ||
val aboutUiState = _aboutUiState.asStateFlow() | ||
|
||
fun getAboutOptions() = viewModelScope.launch { | ||
kapmaurya marked this conversation as resolved.
Show resolved
Hide resolved
|
||
try { | ||
val options = listOf( | ||
AboutItem( | ||
icon = null, | ||
title = androidclient.feature.about.generated.resources.Res.string.feature_about_app_version, | ||
subtitle = null, | ||
// color = Color.Blue, | ||
id = AboutItems.APP_VERSION, | ||
), | ||
AboutItem( | ||
icon = androidclient.feature.about.generated.resources.Res.drawable.feature_about_ic_website, | ||
title = androidclient.feature.about.generated.resources.Res.string.feature_about_website, | ||
subtitle = null, | ||
// color = White, | ||
id = AboutItems.OFFICIAL_WEBSITE, | ||
), | ||
AboutItem( | ||
icon = androidclient.feature.about.generated.resources.Res.drawable.feature_about_icon_twitter, | ||
title = androidclient.feature.about.generated.resources.Res.string.feature_about_support_twitter, | ||
subtitle = null, | ||
color = White, | ||
id = AboutItems.TWITTER, | ||
), | ||
AboutItem( | ||
icon = androidclient.feature.about.generated.resources.Res.drawable.feature_about_ic_source_code, | ||
title = androidclient.feature.about.generated.resources.Res.string.feature_about_support_github, | ||
subtitle = null, | ||
// color = White, | ||
id = AboutItems.SOURCE_CODE, | ||
), | ||
AboutItem( | ||
icon = null, | ||
title = androidclient.feature.about.generated.resources.Res.string.feature_about_license, | ||
subtitle = androidclient.feature.about.generated.resources.Res.string.feature_about_license_sub, | ||
// color = Color.Blue, | ||
kapmaurya marked this conversation as resolved.
Show resolved
Hide resolved
|
||
id = AboutItems.LICENSE, | ||
), | ||
) | ||
_aboutUiState.value = AboutUiState.AboutOptions(options) | ||
} catch (exception: Exception) { | ||
_aboutUiState.value = AboutUiState.Error(androidclient.feature.about.generated.resources.Res.string.feature_about_failed_to_load) | ||
} | ||
kapmaurya marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
enum class AboutItems { | ||
CONTRIBUTIONS, | ||
APP_VERSION, | ||
OFFICIAL_WEBSITE, | ||
TWITTER, | ||
SOURCE_CODE, | ||
LICENSE, | ||
} |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.