Skip to content

Commit ee85628

Browse files
authored
feat: Refactored customizer script for improved KMP project customization (#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. ```
1 parent 496af55 commit ee85628

File tree

7 files changed

+437
-517
lines changed

7 files changed

+437
-517
lines changed

.run/cmp-android.run.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="cmp-android" type="AndroidRunConfigurationType" factoryName="Android App" activateToolWindowBeforeRun="false">
3-
<module name="mobile-cmp-template.kmp-project-template.cmp-android" />
3+
<module name="kmp-project-template.cmp-android" />
44
<option name="ANDROID_RUN_CONFIGURATION_SCHEMA_VERSION" value="1" />
55
<option name="DEPLOY" value="true" />
66
<option name="DEPLOY_APK_FROM_BUNDLE" value="false" />

cmp-android/dependencies/prodReleaseRuntimeClasspath.tree.txt

+241-241
Large diffs are not rendered by default.

cmp-desktop/src/jvmMain/kotlin/main.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fun main() {
4040
Window(
4141
onCloseRequest = ::exitApplication,
4242
state = windowState,
43-
title = "MifosAppTemplate",
43+
title = "DesktopApp",
4444
) {
4545
// Sets the content of the window.
4646
SharedApp()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2025 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See See https://github.com/openMF/kmp-project-template/blob/main/LICENSE
9+
*/
10+
package cmp.navigation
11+
12+
import androidx.compose.runtime.Composable
13+
import androidx.compose.ui.Modifier
14+
import androidx.navigation.compose.rememberNavController
15+
import cmp.navigation.navigation.RootNavGraph
16+
import org.koin.compose.koinInject
17+
import org.mifos.core.data.utils.NetworkMonitor
18+
import org.mifos.core.data.utils.TimeZoneMonitor
19+
import org.mifos.core.designsystem.theme.MifosTheme
20+
21+
@Composable
22+
fun ComposeApp(
23+
modifier: Modifier = Modifier,
24+
networkMonitor: NetworkMonitor = koinInject(),
25+
timeZoneMonitor: TimeZoneMonitor = koinInject(),
26+
) {
27+
MifosTheme {
28+
RootNavGraph(
29+
networkMonitor = networkMonitor,
30+
timeZoneMonitor = timeZoneMonitor,
31+
navHostController = rememberNavController(),
32+
modifier = modifier,
33+
)
34+
}
35+
}

cmp-shared/build.gradle.kts

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ kotlin {
3030
commonMain.dependencies {
3131
// Navigation Modules
3232
implementation(projects.cmpNavigation)
33-
api(projects.core.data)
3433
implementation(compose.components.resources)
3534
}
3635

cmp-shared/src/commonMain/kotlin/cmp/shared/SharedApp.kt

+2-29
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,11 @@ package cmp.shared
1111

1212
import androidx.compose.runtime.Composable
1313
import androidx.compose.ui.Modifier
14-
import androidx.navigation.compose.rememberNavController
15-
import cmp.navigation.navigation.RootNavGraph
16-
import org.koin.compose.koinInject
17-
import org.mifos.core.data.utils.NetworkMonitor
18-
import org.mifos.core.data.utils.TimeZoneMonitor
19-
import org.mifos.core.designsystem.theme.MifosTheme
14+
import cmp.navigation.ComposeApp
2015

2116
@Composable
2217
fun SharedApp(
2318
modifier: Modifier = Modifier,
24-
networkMonitor: NetworkMonitor = koinInject(),
25-
timeZoneMonitor: TimeZoneMonitor = koinInject(),
2619
) {
27-
RootApp(
28-
networkMonitor = networkMonitor,
29-
timeZoneMonitor = timeZoneMonitor,
30-
modifier = modifier,
31-
)
32-
}
33-
34-
@Composable
35-
private fun RootApp(
36-
networkMonitor: NetworkMonitor,
37-
timeZoneMonitor: TimeZoneMonitor,
38-
modifier: Modifier = Modifier,
39-
) {
40-
MifosTheme {
41-
RootNavGraph(
42-
networkMonitor = networkMonitor,
43-
timeZoneMonitor = timeZoneMonitor,
44-
navHostController = rememberNavController(),
45-
modifier = modifier,
46-
)
47-
}
20+
ComposeApp(modifier = modifier)
4821
}

0 commit comments

Comments
 (0)