Skip to content

Commit

Permalink
feat: Refactored customizer script for improved KMP project customiza…
Browse files Browse the repository at this point in the history
…tion (openMF#32)

This commit refactors the `customizer.sh` script, enhancing its functionality for customizing Kotlin Multiplatform (KMP) projects. Key improvements include:

-   **Enhanced UI and Feedback:** Added colors, emojis, and formatting for a better user experience, making the script more visually appealing and informative.
-   **Modular Processing:** Refactored the script into modular functions, improving organization and maintainability.
-   **Improved Logic:** Streamlined the script's logic for more accurate and reliable project customization.
-   **New Features:**
    -   Added functions to update package namespace and root project name.
    -   Implemented `print_success`, `print_warning`, `print_info`, and `print_processing` to provide clear feedback.
    -   Introduced a `print_welcome_banner` for a more engaging start.
-   **Robust Error Handling:** Improved error handling and backup/restore mechanisms, enhancing the script's robustness.
-   **Module and File Renaming:** Added a function to rename files more accurately.
-   **Final Summary:** Improved the final summary, providing clearer information on changes made.
    -   Refactor `sync-cmp-dir.sh`, `sync-cmp-dirs.sh` and `sync-dir.sh` scripts for improved KMP project syncs.
    -   Added `ComposeApp` navigation component.
    -   Removed old code and improved documentation.
    -   Updated `cmp-shared/build.gradle.kts` dependencies.
    -   Removed `cmp-shared/src/commonMain/kotlin/cmp/shared/SharedApp.kt` content and update navigation.
    -   Removed `cmp-desktop/src/jvmMain/kotlin/main.kt` content and updated app title.
    -   Updated `.run/cmp-android.run.xml` module name.
-   **Backup Management:** Added improved file backup and restore functionality, increasing data safety.
```
  • Loading branch information
niyajali authored Jan 21, 2025
1 parent 496af55 commit ee85628
Show file tree
Hide file tree
Showing 7 changed files with 437 additions and 517 deletions.
2 changes: 1 addition & 1 deletion .run/cmp-android.run.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="cmp-android" type="AndroidRunConfigurationType" factoryName="Android App" activateToolWindowBeforeRun="false">
<module name="mobile-cmp-template.kmp-project-template.cmp-android" />
<module name="kmp-project-template.cmp-android" />
<option name="ANDROID_RUN_CONFIGURATION_SCHEMA_VERSION" value="1" />
<option name="DEPLOY" value="true" />
<option name="DEPLOY_APK_FROM_BUNDLE" value="false" />
Expand Down
482 changes: 241 additions & 241 deletions cmp-android/dependencies/prodReleaseRuntimeClasspath.tree.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cmp-desktop/src/jvmMain/kotlin/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fun main() {
Window(
onCloseRequest = ::exitApplication,
state = windowState,
title = "MifosAppTemplate",
title = "DesktopApp",
) {
// Sets the content of the window.
SharedApp()
Expand Down
35 changes: 35 additions & 0 deletions cmp-navigation/src/commonMain/kotlin/cmp/navigation/ComposeApp.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* 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 See https://github.com/openMF/kmp-project-template/blob/main/LICENSE
*/
package cmp.navigation

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.compose.rememberNavController
import cmp.navigation.navigation.RootNavGraph
import org.koin.compose.koinInject
import org.mifos.core.data.utils.NetworkMonitor
import org.mifos.core.data.utils.TimeZoneMonitor
import org.mifos.core.designsystem.theme.MifosTheme

@Composable
fun ComposeApp(
modifier: Modifier = Modifier,
networkMonitor: NetworkMonitor = koinInject(),
timeZoneMonitor: TimeZoneMonitor = koinInject(),
) {
MifosTheme {
RootNavGraph(
networkMonitor = networkMonitor,
timeZoneMonitor = timeZoneMonitor,
navHostController = rememberNavController(),
modifier = modifier,
)
}
}
1 change: 0 additions & 1 deletion cmp-shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ kotlin {
commonMain.dependencies {
// Navigation Modules
implementation(projects.cmpNavigation)
api(projects.core.data)
implementation(compose.components.resources)
}

Expand Down
31 changes: 2 additions & 29 deletions cmp-shared/src/commonMain/kotlin/cmp/shared/SharedApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,11 @@ package cmp.shared

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.compose.rememberNavController
import cmp.navigation.navigation.RootNavGraph
import org.koin.compose.koinInject
import org.mifos.core.data.utils.NetworkMonitor
import org.mifos.core.data.utils.TimeZoneMonitor
import org.mifos.core.designsystem.theme.MifosTheme
import cmp.navigation.ComposeApp

@Composable
fun SharedApp(
modifier: Modifier = Modifier,
networkMonitor: NetworkMonitor = koinInject(),
timeZoneMonitor: TimeZoneMonitor = koinInject(),
) {
RootApp(
networkMonitor = networkMonitor,
timeZoneMonitor = timeZoneMonitor,
modifier = modifier,
)
}

@Composable
private fun RootApp(
networkMonitor: NetworkMonitor,
timeZoneMonitor: TimeZoneMonitor,
modifier: Modifier = Modifier,
) {
MifosTheme {
RootNavGraph(
networkMonitor = networkMonitor,
timeZoneMonitor = timeZoneMonitor,
navHostController = rememberNavController(),
modifier = modifier,
)
}
ComposeApp(modifier = modifier)
}
Loading

0 comments on commit ee85628

Please sign in to comment.