diff --git a/androidApp/src/main/java/org/mifos/mobile/navigation/MifosNavGraph.kt b/androidApp/src/main/java/org/mifos/mobile/navigation/MifosNavGraph.kt index 8710ae0af..547cd5b7e 100644 --- a/androidApp/src/main/java/org/mifos/mobile/navigation/MifosNavGraph.kt +++ b/androidApp/src/main/java/org/mifos/mobile/navigation/MifosNavGraph.kt @@ -120,7 +120,7 @@ fun RootNavGraph( ) settingsNavGraph( - navController = navController, + navigateBack = navController::popBackStack, changePassword = navController::navigateToUpdatePassword, changePasscode = {}, // { navigateToUpdatePasscodeActivity(it, context) }, navigateToLoginScreen = navController::navigateToLoginScreen, diff --git a/feature/settings/build.gradle.kts b/feature/settings/build.gradle.kts index a2d85dc46..78d00f89f 100644 --- a/feature/settings/build.gradle.kts +++ b/feature/settings/build.gradle.kts @@ -1,3 +1,12 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ plugins { alias(libs.plugins.mifos.android.feature) alias(libs.plugins.mifos.android.library.compose) diff --git a/feature/settings/src/androidTest/java/org/mifos/mobile/feature/settings/ExampleInstrumentedTest.kt b/feature/settings/src/androidTest/java/org/mifos/mobile/feature/settings/ExampleInstrumentedTest.kt deleted file mode 100644 index dfe1d4a46..000000000 --- a/feature/settings/src/androidTest/java/org/mifos/mobile/feature/settings/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package org.mifos.mobile.feature.settings - -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.ext.junit.runners.AndroidJUnit4 - -import org.junit.Test -import org.junit.runner.RunWith - -import org.junit.Assert.* - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("org.mifos.mobile.feature.settings.test", appContext.packageName) - } -} \ No newline at end of file diff --git a/feature/settings/src/main/AndroidManifest.xml b/feature/settings/src/main/AndroidManifest.xml index a5918e68a..1f9b243f0 100644 --- a/feature/settings/src/main/AndroidManifest.xml +++ b/feature/settings/src/main/AndroidManifest.xml @@ -1,4 +1,13 @@ + \ No newline at end of file diff --git a/feature/settings/src/main/java/org/mifos/mobile/feature/settings/SettingsScreen.kt b/feature/settings/src/main/java/org/mifos/mobile/feature/settings/SettingsScreen.kt index 05a903cf7..c9be99b45 100644 --- a/feature/settings/src/main/java/org/mifos/mobile/feature/settings/SettingsScreen.kt +++ b/feature/settings/src/main/java/org/mifos/mobile/feature/settings/SettingsScreen.kt @@ -1,6 +1,17 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ package org.mifos.mobile.feature.settings import android.content.Context +import androidx.annotation.DrawableRes +import androidx.annotation.StringRes import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer @@ -28,7 +39,6 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringArrayResource import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.hilt.navigation.compose.hiltViewModel @@ -40,63 +50,72 @@ import org.mifos.mobile.core.designsystem.theme.MifosMobileTheme import org.mifos.mobile.core.model.enums.AppTheme import org.mifos.mobile.core.model.enums.MifosAppLanguage import org.mifos.mobile.core.ui.component.MifosRadioButtonDialog +import org.mifos.mobile.core.ui.utils.DevicePreviews import java.util.Locale @Composable -fun SettingsScreen( - viewModel: SettingsViewModel = hiltViewModel(), +internal fun SettingsScreen( navigateBack: () -> Unit, navigateToLoginScreen: () -> Unit, changePassword: () -> Unit, changePasscode: (String) -> Unit, - languageChanged: () -> Unit + languageChanged: () -> Unit, + modifier: Modifier = Modifier, + viewModel: SettingsViewModel = hiltViewModel(), ) { - - val baseURL = viewModel.baseUrl.collectAsStateWithLifecycle() - val tenant = viewModel.tenant.collectAsStateWithLifecycle() - val passcode = viewModel.passcode.collectAsStateWithLifecycle() - val theme = viewModel.theme.collectAsStateWithLifecycle() - val language = viewModel.language.collectAsStateWithLifecycle() - val context = LocalContext.current + val baseURL by viewModel.baseUrl.collectAsStateWithLifecycle() + val tenant by viewModel.tenant.collectAsStateWithLifecycle() + val passcode by viewModel.passcode.collectAsStateWithLifecycle() + val theme by viewModel.theme.collectAsStateWithLifecycle() + val language by viewModel.language.collectAsStateWithLifecycle() + SettingsScreen( + selectedLanguage = language, + selectedTheme = theme, + baseURL = baseURL ?: "", + tenant = tenant ?: "", navigateBack = navigateBack, - selectedLanguage = language.value, - selectedTheme = theme.value, - baseURL = baseURL.value ?: "", - tenant = tenant.value ?: "", - updateLanguage = { - val isSystemLanguage = viewModel.updateLanguage(it) - updateLanguageLocale(context = context, language = language.value, isSystemLanguage = isSystemLanguage) - languageChanged() - }, - updateTheme = { viewModel.updateTheme(it) }, changePassword = changePassword, - changePasscode = { changePasscode(passcode.value ?: "") }, - handleEndpointUpdate = { baseURL, tenant -> - if(viewModel.tryUpdatingEndpoint(selectedBaseUrl = baseURL, selectedTenant = tenant)) { + changePasscode = { changePasscode(passcode ?: "") }, + handleEndpointUpdate = { url, selectedTenant -> + if (viewModel.tryUpdatingEndpoint( + selectedBaseUrl = url, + selectedTenant = selectedTenant, + ) + ) { navigateToLoginScreen() } }, + updateTheme = viewModel::updateTheme, + updateLanguage = { + val isSystemLanguage = viewModel.updateLanguage(it) + updateLanguageLocale( + context = context, + language = language, + isSystemLanguage = isSystemLanguage, + ) + languageChanged() + }, + modifier = modifier, ) } - @Composable -fun SettingsScreen( - navigateBack: () -> Unit, +private fun SettingsScreen( selectedLanguage: MifosAppLanguage, selectedTheme: AppTheme, baseURL: String, tenant: String, + navigateBack: () -> Unit, changePassword: () -> Unit, changePasscode: () -> Unit, handleEndpointUpdate: (baseURL: String, tenant: String) -> Unit, updateTheme: (theme: AppTheme) -> Unit, - updateLanguage: (language: MifosAppLanguage) -> Unit + updateLanguage: (language: MifosAppLanguage) -> Unit, + modifier: Modifier = Modifier, ) { - var showLanguageUpdateDialog by rememberSaveable { mutableStateOf(false) } var showEndpointUpdateDialog by rememberSaveable { mutableStateOf(false) } var showThemeUpdateDialog by rememberSaveable { mutableStateOf(false) } @@ -105,78 +124,84 @@ fun SettingsScreen( topBar = { MifosTopBarTitle( navigateBack = navigateBack, - topBarTitleResId = R.string.settings + topBarTitleResId = R.string.settings, ) - } + }, + modifier = modifier, ) { Column( - Modifier.padding(it) + Modifier.padding(it), ) { SettingsCards( settingsCardClicked = { item -> - when(item) { + when (item) { SettingsCardItem.PASSWORD -> changePassword() SettingsCardItem.PASSCODE -> changePasscode() SettingsCardItem.LANGUAGE -> showLanguageUpdateDialog = true SettingsCardItem.THEME -> showThemeUpdateDialog = true SettingsCardItem.ENDPOINT -> showEndpointUpdateDialog = true } - } + }, ) } } - if(showLanguageUpdateDialog) { + if (showLanguageUpdateDialog) { MifosRadioButtonDialog( titleResId = R.string.choose_language, items = stringArrayResource(R.array.languages), selectItem = { _, index -> updateLanguage(MifosAppLanguage.entries[index]) }, onDismissRequest = { showLanguageUpdateDialog = false }, - selectedItem = selectedLanguage.displayName + selectedItem = selectedLanguage.displayName, ) } - if(showThemeUpdateDialog) { + if (showThemeUpdateDialog) { MifosRadioButtonDialog( titleResId = R.string.change_app_theme, items = AppTheme.entries.map { it.themeName }.toTypedArray(), selectItem = { _, index -> updateTheme(AppTheme.entries[index]) }, onDismissRequest = { showThemeUpdateDialog = false }, - selectedItem = selectedTheme.themeName + selectedItem = selectedTheme.themeName, ) } - if(showEndpointUpdateDialog) { + if (showEndpointUpdateDialog) { UpdateEndpointDialogScreen( initialBaseURL = baseURL, initialTenant = tenant, onDismissRequest = { showEndpointUpdateDialog = false }, - handleEndpointUpdate = handleEndpointUpdate + handleEndpointUpdate = handleEndpointUpdate, ) } } @Composable -fun SettingsCards( +private fun SettingsCards( settingsCardClicked: (SettingsCardItem) -> Unit, + modifier: Modifier = Modifier, ) { - LazyColumn { + LazyColumn(modifier) { items(SettingsCardItem.entries) { card -> if (card.firstItemInSubclass) { + Spacer(modifier = Modifier.height(16.dp)) TitleCard(title = card.subclassOf) + Spacer(modifier = Modifier.height(12.dp)) } SettingsCardItem( title = card.title, details = card.details, icon = card.icon, - onclick = { settingsCardClicked(card) } + onclick = { settingsCardClicked(card) }, ) if (card.showDividerInBottom) { HorizontalDivider( - modifier = Modifier.fillMaxWidth().height(1.dp), - color = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.4f) + modifier = Modifier + .fillMaxWidth() + .height(1.dp), + color = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.4f), ) } } @@ -184,17 +209,18 @@ fun SettingsCards( } @Composable -fun SettingsCardItem( - title: Int, - details: Int, - icon: Int, - onclick: () -> Unit +private fun SettingsCardItem( + @StringRes title: Int, + @StringRes details: Int, + @DrawableRes icon: Int, + onclick: () -> Unit, + modifier: Modifier = Modifier, ) { Card( - modifier = Modifier.fillMaxWidth(), + modifier = modifier.fillMaxWidth(), colors = CardDefaults.cardColors(containerColor = Color.Transparent), shape = RoundedCornerShape(0.dp), - onClick = { onclick.invoke() } + onClick = { onclick.invoke() }, ) { Row( verticalAlignment = Alignment.CenterVertically, @@ -203,14 +229,14 @@ fun SettingsCardItem( Icon( painter = painterResource(id = icon), contentDescription = null, - modifier = Modifier.weight(0.2f) + modifier = Modifier.weight(0.2f), ) Column( - modifier = Modifier.weight(0.8f) + modifier = Modifier.weight(0.8f), ) { Text( text = stringResource(id = title), - style = MaterialTheme.typography.bodyMedium + style = MaterialTheme.typography.bodyMedium, ) Text( modifier = Modifier.padding(end = 16.dp), @@ -224,22 +250,25 @@ fun SettingsCardItem( } @Composable -fun TitleCard( - title: Int +private fun TitleCard( + @StringRes title: Int, + modifier: Modifier = Modifier, ) { - Spacer(modifier = Modifier.height(16.dp)) - Row(modifier = Modifier.fillMaxWidth()) { + Row(modifier = modifier.fillMaxWidth()) { Spacer(modifier = Modifier.weight(0.2f)) Text( text = stringResource(id = title), modifier = Modifier.weight(0.8f), - fontSize = 14.sp + fontSize = 14.sp, ) } - Spacer(modifier = Modifier.height(12.dp)) } -fun updateLanguageLocale(context: Context, language: MifosAppLanguage, isSystemLanguage: Boolean) { +private fun updateLanguageLocale( + context: Context, + language: MifosAppLanguage, + isSystemLanguage: Boolean, +) { if (!isSystemLanguage) { LanguageHelper.setLocale(context, language.code) } else { @@ -253,20 +282,20 @@ fun updateLanguageLocale(context: Context, language: MifosAppLanguage, isSystemL } @Composable -@Preview(showSystemUi = true, showBackground = true) -fun PreviewSettingsScreen() { +@DevicePreviews +private fun PreviewSettingsScreen() { MifosMobileTheme { SettingsScreen( selectedLanguage = MifosAppLanguage.SYSTEM_LANGUAGE, selectedTheme = AppTheme.SYSTEM, baseURL = "", tenant = "", - handleEndpointUpdate = { _, _ -> }, - updateLanguage = {}, - updateTheme = {}, navigateBack = {}, changePassword = {}, - changePasscode = {} + changePasscode = {}, + handleEndpointUpdate = { _, _ -> }, + updateTheme = {}, + updateLanguage = {}, ) } -} \ No newline at end of file +} diff --git a/feature/settings/src/main/java/org/mifos/mobile/feature/settings/SettingsViewModel.kt b/feature/settings/src/main/java/org/mifos/mobile/feature/settings/SettingsViewModel.kt index 1aeab7574..2e0627206 100644 --- a/feature/settings/src/main/java/org/mifos/mobile/feature/settings/SettingsViewModel.kt +++ b/feature/settings/src/main/java/org/mifos/mobile/feature/settings/SettingsViewModel.kt @@ -1,6 +1,14 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ package org.mifos.mobile.feature.settings - import android.os.Build import androidx.appcompat.app.AppCompatDelegate import androidx.lifecycle.ViewModel @@ -17,7 +25,7 @@ import org.mifos.mobile.core.model.enums.MifosAppLanguage import javax.inject.Inject @HiltViewModel -class SettingsViewModel @Inject constructor( +internal class SettingsViewModel @Inject constructor( private val preferencesHelper: PreferencesHelper, ) : ViewModel() { @@ -45,7 +53,6 @@ class SettingsViewModel @Inject constructor( flow { emit(MifosAppLanguage.fromCode(preferencesHelper.language)) } }.stateIn(viewModelScope, SharingStarted.Eagerly, MifosAppLanguage.SYSTEM_LANGUAGE) - fun tryUpdatingEndpoint(selectedBaseUrl: String, selectedTenant: String): Boolean { if (!(baseUrl.equals(selectedBaseUrl) && tenant.equals(selectedTenant))) { preferencesHelper.updateConfiguration(selectedBaseUrl, selectedTenant) @@ -68,54 +75,54 @@ class SettingsViewModel @Inject constructor( AppTheme.DARK -> AppCompatDelegate.MODE_NIGHT_YES AppTheme.LIGHT -> AppCompatDelegate.MODE_NIGHT_NO else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM - } + }, ) preferencesHelper.appTheme = theme.ordinal preferencesHelper.applyTheme(theme) } } -enum class SettingsCardItem( +internal enum class SettingsCardItem( val title: Int, val details: Int, val icon: Int, val subclassOf: Int, val firstItemInSubclass: Boolean = false, - val showDividerInBottom: Boolean = false + val showDividerInBottom: Boolean = false, ) { PASSWORD( title = R.string.change_password, details = R.string.change_account_password, icon = R.drawable.ic_lock_black_24dp, firstItemInSubclass = true, - subclassOf = R.string.accounts + subclassOf = R.string.accounts, ), PASSCODE( title = R.string.change_passcode, details = R.string.change_app_passcode, icon = R.drawable.ic_passcode, showDividerInBottom = true, - subclassOf = R.string.accounts + subclassOf = R.string.accounts, ), LANGUAGE( title = R.string.language, details = R.string.choose_language, icon = R.drawable.ic_translate, firstItemInSubclass = true, - subclassOf = R.string.other + subclassOf = R.string.other, ), THEME( title = R.string.theme, details = R.string.change_app_theme, icon = R.drawable.ic_baseline_dark_mode_24, - subclassOf = R.string.other + subclassOf = R.string.other, ), ENDPOINT( title = R.string.pref_base_url_title, details = R.string.pref_base_url_desc, icon = R.drawable.ic_update, - subclassOf = R.string.other - ) + subclassOf = R.string.other, + ), } fun PreferencesHelper.applySavedTheme() { @@ -130,8 +137,7 @@ fun PreferencesHelper.applySavedTheme() { ) } - -fun PreferencesHelper.applyTheme(applicationTheme: AppTheme) { +internal fun PreferencesHelper.applyTheme(applicationTheme: AppTheme) { this.appTheme = applicationTheme.ordinal AppCompatDelegate.setDefaultNightMode( when { @@ -142,4 +148,3 @@ fun PreferencesHelper.applyTheme(applicationTheme: AppTheme) { }, ) } - diff --git a/feature/settings/src/main/java/org/mifos/mobile/feature/settings/UpdateEndpointDialog.kt b/feature/settings/src/main/java/org/mifos/mobile/feature/settings/UpdateEndpointDialog.kt index 5df9ec200..671e99885 100644 --- a/feature/settings/src/main/java/org/mifos/mobile/feature/settings/UpdateEndpointDialog.kt +++ b/feature/settings/src/main/java/org/mifos/mobile/feature/settings/UpdateEndpointDialog.kt @@ -1,3 +1,12 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ package org.mifos.mobile.feature.settings import androidx.compose.foundation.layout.Arrangement @@ -7,10 +16,11 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.material3.BasicAlertDialog import androidx.compose.material3.Card +import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Text -import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -18,67 +28,71 @@ import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import androidx.compose.ui.window.Dialog +import org.mifos.mobile.core.designsystem.components.MifosTextButton import org.mifos.mobile.core.designsystem.theme.MifosMobileTheme +import org.mifos.mobile.core.ui.utils.DevicePreviews +@OptIn(ExperimentalMaterial3Api::class) @Composable -fun UpdateEndpointDialogScreen( +internal fun UpdateEndpointDialogScreen( initialBaseURL: String?, initialTenant: String?, onDismissRequest: () -> Unit, - handleEndpointUpdate: (baseURL: String, tenant: String) -> Unit + handleEndpointUpdate: (baseURL: String, tenant: String) -> Unit, + modifier: Modifier = Modifier, ) { var baseURL by rememberSaveable { mutableStateOf(initialBaseURL) } var tenant by rememberSaveable { mutableStateOf(initialTenant) } - Dialog( - onDismissRequest = { onDismissRequest.invoke() } + BasicAlertDialog( + onDismissRequest = onDismissRequest, + modifier = modifier, ) { Card { Column( - modifier = Modifier.fillMaxWidth().padding(20.dp), + modifier = Modifier + .fillMaxWidth() + .padding(20.dp), ) { Text(text = stringResource(id = R.string.pref_base_url_title)) Spacer(modifier = Modifier.height(8.dp)) - baseURL?.let { + baseURL?.let { url -> OutlinedTextField( - value = it, + value = url, onValueChange = { baseURL = it }, - label = { Text(text = stringResource(id = R.string.enter_base_url)) } + label = { Text(text = stringResource(id = R.string.enter_base_url)) }, ) } Spacer(modifier = Modifier.height(8.dp)) - tenant?.let { + tenant?.let { selectedTenant -> OutlinedTextField( - value = it, + value = selectedTenant, onValueChange = { tenant = it }, - label = { Text(text = stringResource(id = R.string.enter_tenant)) } + label = { Text(text = stringResource(id = R.string.enter_tenant)) }, ) } Row( modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.End + horizontalArrangement = Arrangement.End, ) { - TextButton( - onClick = { onDismissRequest.invoke() }) { - Text(text = stringResource(id = R.string.cancel)) - } - TextButton( + MifosTextButton( + text = stringResource(id = R.string.cancel), + onClick = onDismissRequest, + ) + + MifosTextButton( + text = stringResource(id = R.string.dialog_action_ok), onClick = { - if(baseURL != null && tenant != null) { + if (baseURL != null && tenant != null) { handleEndpointUpdate.invoke(baseURL ?: "", tenant ?: "") } - } + }, ) - { - Text(text = stringResource(id = R.string.dialog_action_ok)) - } } } } @@ -86,14 +100,17 @@ fun UpdateEndpointDialogScreen( } @Composable -@Preview() -fun PreviewUpdateEndpointDialogScreen(modifier: Modifier = Modifier) { +@DevicePreviews +private fun PreviewUpdateEndpointDialogScreen( + modifier: Modifier = Modifier, +) { MifosMobileTheme { UpdateEndpointDialogScreen( initialBaseURL = "URL", - initialTenant = "gsoc", + initialTenant = "soc", + modifier = modifier, onDismissRequest = { }, - handleEndpointUpdate = { _, _ -> } + handleEndpointUpdate = { _, _ -> }, ) } } diff --git a/feature/settings/src/main/java/org/mifos/mobile/feature/settings/navigation/SettingsNavGraph.kt b/feature/settings/src/main/java/org/mifos/mobile/feature/settings/navigation/SettingsNavGraph.kt index 58152772a..750b3cbdf 100644 --- a/feature/settings/src/main/java/org/mifos/mobile/feature/settings/navigation/SettingsNavGraph.kt +++ b/feature/settings/src/main/java/org/mifos/mobile/feature/settings/navigation/SettingsNavGraph.kt @@ -1,3 +1,12 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ package org.mifos.mobile.feature.settings.navigation import androidx.navigation.NavController @@ -11,22 +20,22 @@ fun NavController.navigateToSettings() { } fun NavGraphBuilder.settingsNavGraph( - navController: NavController, + navigateBack: () -> Unit, navigateToLoginScreen: () -> Unit, changePassword: () -> Unit, changePasscode: (String) -> Unit, - languageChanged: () -> Unit + languageChanged: () -> Unit, ) { navigation( startDestination = SettingsNavigation.SettingsScreen.route, route = SettingsNavigation.SettingsBase.route, ) { settingsScreenRoute( - navigateBack = navController::popBackStack, + navigateBack = navigateBack, navigateToLoginScreen = navigateToLoginScreen, changePassword = changePassword, changePasscode = changePasscode, - languageChanged = languageChanged + languageChanged = languageChanged, ) } } @@ -36,7 +45,7 @@ fun NavGraphBuilder.settingsScreenRoute( navigateToLoginScreen: () -> Unit, changePassword: () -> Unit, changePasscode: (String) -> Unit, - languageChanged: () -> Unit + languageChanged: () -> Unit, ) { composable( route = SettingsNavigation.SettingsScreen.route, @@ -46,7 +55,7 @@ fun NavGraphBuilder.settingsScreenRoute( navigateToLoginScreen = navigateToLoginScreen, changePassword = changePassword, changePasscode = changePasscode, - languageChanged = languageChanged + languageChanged = languageChanged, ) } -} \ No newline at end of file +} diff --git a/feature/settings/src/main/java/org/mifos/mobile/feature/settings/navigation/SettingsNavigation.kt b/feature/settings/src/main/java/org/mifos/mobile/feature/settings/navigation/SettingsNavigation.kt index d346c6a7f..4ebd81f45 100644 --- a/feature/settings/src/main/java/org/mifos/mobile/feature/settings/navigation/SettingsNavigation.kt +++ b/feature/settings/src/main/java/org/mifos/mobile/feature/settings/navigation/SettingsNavigation.kt @@ -1,3 +1,12 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ package org.mifos.mobile.feature.settings.navigation const val SETTINGS_NAVIGATION_ROUTE_BASE = "settings_base_route" diff --git a/feature/settings/src/main/res/drawable/ic_baseline_dark_mode_24.xml b/feature/settings/src/main/res/drawable/ic_baseline_dark_mode_24.xml index e52c5baff..01bb33722 100644 --- a/feature/settings/src/main/res/drawable/ic_baseline_dark_mode_24.xml +++ b/feature/settings/src/main/res/drawable/ic_baseline_dark_mode_24.xml @@ -1,3 +1,13 @@ + + + + + + + + + + Change theme Settings diff --git a/feature/settings/src/test/java/org/mifos/mobile/feature/settings/ExampleUnitTest.kt b/feature/settings/src/test/java/org/mifos/mobile/feature/settings/ExampleUnitTest.kt deleted file mode 100644 index f4b977b8a..000000000 --- a/feature/settings/src/test/java/org/mifos/mobile/feature/settings/ExampleUnitTest.kt +++ /dev/null @@ -1,17 +0,0 @@ -package org.mifos.mobile.feature.settings - -import org.junit.Test - -import org.junit.Assert.* - -/** - * Example local unit test, which will execute on the development machine (host). - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -class ExampleUnitTest { - @Test - fun addition_isCorrect() { - assertEquals(4, 2 + 2) - } -} \ No newline at end of file