From beafd87ab1f930a1e4ea216243fbc96d68290a44 Mon Sep 17 00:00:00 2001 From: Lexonchik Date: Tue, 27 Feb 2024 17:41:27 +0100 Subject: [PATCH 1/6] removing unused onThemeChange --- app/src/main/assets/ai | 2 +- app/src/main/java/fr/medicapp/medicapp/MainActivity.kt | 5 ----- .../fr/medicapp/medicapp/ui/navigation/DoctorNavGraph.kt | 2 -- .../java/fr/medicapp/medicapp/ui/navigation/HomeNavGraph.kt | 6 +----- .../medicapp/ui/navigation/PrescriptionEditNavGraph.kt | 2 -- .../medicapp/medicapp/ui/navigation/PrescriptionNavGraph.kt | 5 +---- .../medicapp/medicapp/ui/navigation/RootNavigationGraph.kt | 2 +- .../medicapp/medicapp/ui/navigation/SideEffectNavGraph.kt | 2 -- .../java/fr/medicapp/medicapp/ui/navigation/UserNavGraph.kt | 3 --- 9 files changed, 4 insertions(+), 25 deletions(-) diff --git a/app/src/main/assets/ai b/app/src/main/assets/ai index 28db521c..b7d81a73 160000 --- a/app/src/main/assets/ai +++ b/app/src/main/assets/ai @@ -1 +1 @@ -Subproject commit 28db521c43b3993e58fd5ac4d9bb7913c0c1d7bb +Subproject commit b7d81a73edccf4b643a62acacfcc28feee4eef53 diff --git a/app/src/main/java/fr/medicapp/medicapp/MainActivity.kt b/app/src/main/java/fr/medicapp/medicapp/MainActivity.kt index fef3405c..a4b3575e 100644 --- a/app/src/main/java/fr/medicapp/medicapp/MainActivity.kt +++ b/app/src/main/java/fr/medicapp/medicapp/MainActivity.kt @@ -24,11 +24,6 @@ import fr.medicapp.medicapp.ui.theme.MedicAppTheme */ class MainActivity : ComponentActivity() { - /** - * Indique si les données ont été téléchargées. - */ - - /** * Crée l'activité. Cette méthode est appelée lorsque l'activité est créée. * diff --git a/app/src/main/java/fr/medicapp/medicapp/ui/navigation/DoctorNavGraph.kt b/app/src/main/java/fr/medicapp/medicapp/ui/navigation/DoctorNavGraph.kt index 433d5ee9..db0555df 100644 --- a/app/src/main/java/fr/medicapp/medicapp/ui/navigation/DoctorNavGraph.kt +++ b/app/src/main/java/fr/medicapp/medicapp/ui/navigation/DoctorNavGraph.kt @@ -9,7 +9,6 @@ import androidx.navigation.navigation import fr.medicapp.medicapp.ui.screen.doctor.DoctorDetail import fr.medicapp.medicapp.ui.screen.doctor.DoctorHome import fr.medicapp.medicapp.ui.screen.root.RootRoute -import fr.medicapp.medicapp.ui.theme.ThemeColorScheme import fr.medicapp.medicapp.viewModel.SharedDoctorDetailViewModel /** @@ -20,7 +19,6 @@ import fr.medicapp.medicapp.viewModel.SharedDoctorDetailViewModel @RequiresApi(Build.VERSION_CODES.O) fun NavGraphBuilder.doctorNavGraph( navController: NavHostController, - onThemeChange: (ThemeColorScheme) -> Unit ) { /** * Définit la navigation pour le graphe de prescription. diff --git a/app/src/main/java/fr/medicapp/medicapp/ui/navigation/HomeNavGraph.kt b/app/src/main/java/fr/medicapp/medicapp/ui/navigation/HomeNavGraph.kt index 730fe531..73d9f05b 100644 --- a/app/src/main/java/fr/medicapp/medicapp/ui/navigation/HomeNavGraph.kt +++ b/app/src/main/java/fr/medicapp/medicapp/ui/navigation/HomeNavGraph.kt @@ -12,7 +12,6 @@ import fr.medicapp.medicapp.database.repositories.prescription.PrescriptionRepos import fr.medicapp.medicapp.model.prescription.relationship.Prescription import fr.medicapp.medicapp.ui.screen.home.HomeScreen import fr.medicapp.medicapp.ui.screen.root.RootRoute -import fr.medicapp.medicapp.ui.theme.ThemeColorScheme /** * Ceci est une classe de navigation pour l'écran d'accueil. @@ -20,7 +19,7 @@ import fr.medicapp.medicapp.ui.theme.ThemeColorScheme */ @RequiresApi(Build.VERSION_CODES.Q) @Composable -fun HomeNavGraph(navController: NavHostController, onThemeChange: (ThemeColorScheme) -> Unit) { +fun HomeNavGraph(navController: NavHostController) { /** * Construit le graphe de navigation pour l'écran d'accueil. * @@ -56,7 +55,6 @@ fun HomeNavGraph(navController: NavHostController, onThemeChange: (ThemeColorSch */ prescriptionNavGraph( navController = navController, - onThemeChange = onThemeChange ) /** @@ -64,12 +62,10 @@ fun HomeNavGraph(navController: NavHostController, onThemeChange: (ThemeColorSch */ sideEffectNavGraph( navController = navController, - onThemeChange = onThemeChange ) doctorNavGraph( navController = navController, - onThemeChange = onThemeChange ) } } diff --git a/app/src/main/java/fr/medicapp/medicapp/ui/navigation/PrescriptionEditNavGraph.kt b/app/src/main/java/fr/medicapp/medicapp/ui/navigation/PrescriptionEditNavGraph.kt index 0e3a3399..e4530906 100644 --- a/app/src/main/java/fr/medicapp/medicapp/ui/navigation/PrescriptionEditNavGraph.kt +++ b/app/src/main/java/fr/medicapp/medicapp/ui/navigation/PrescriptionEditNavGraph.kt @@ -14,13 +14,11 @@ import androidx.navigation.navigation import fr.medicapp.medicapp.ui.screen.prescription.PrescriptionEditInformation import fr.medicapp.medicapp.ui.screen.prescription.PrescriptionEditLoading import fr.medicapp.medicapp.ui.screen.prescription.PrescriptionEditNotification -import fr.medicapp.medicapp.ui.theme.ThemeColorScheme import fr.medicapp.medicapp.viewModel.SharedPrescriptionEditViewModel @RequiresApi(Build.VERSION_CODES.O) fun NavGraphBuilder.prescriptionEditNavGraph( navController: NavHostController, - onThemeChange: (ThemeColorScheme) -> Unit ) { navigation( route = PrescriptionRoute.PrescriptionEditRoute.route, diff --git a/app/src/main/java/fr/medicapp/medicapp/ui/navigation/PrescriptionNavGraph.kt b/app/src/main/java/fr/medicapp/medicapp/ui/navigation/PrescriptionNavGraph.kt index 1713f13e..5e375d0a 100644 --- a/app/src/main/java/fr/medicapp/medicapp/ui/navigation/PrescriptionNavGraph.kt +++ b/app/src/main/java/fr/medicapp/medicapp/ui/navigation/PrescriptionNavGraph.kt @@ -14,7 +14,6 @@ import fr.medicapp.medicapp.model.prescription.relationship.Prescription import fr.medicapp.medicapp.ui.screen.prescription.PrescriptionDetail import fr.medicapp.medicapp.ui.screen.prescription.PrescriptionHome import fr.medicapp.medicapp.ui.screen.root.RootRoute -import fr.medicapp.medicapp.ui.theme.ThemeColorScheme import fr.medicapp.medicapp.viewModel.SharedPrescriptionDetailViewModel /** @@ -25,7 +24,6 @@ import fr.medicapp.medicapp.viewModel.SharedPrescriptionDetailViewModel @RequiresApi(Build.VERSION_CODES.Q) fun NavGraphBuilder.prescriptionNavGraph( navController: NavHostController, - onThemeChange: (ThemeColorScheme) -> Unit ) { /** * Définit la navigation pour le graphe de prescription. @@ -87,8 +85,7 @@ fun NavGraphBuilder.prescriptionNavGraph( } prescriptionEditNavGraph( - navController = navController, - onThemeChange = onThemeChange + navController = navController ) } } diff --git a/app/src/main/java/fr/medicapp/medicapp/ui/navigation/RootNavigationGraph.kt b/app/src/main/java/fr/medicapp/medicapp/ui/navigation/RootNavigationGraph.kt index ddc2bf7b..8da6e164 100644 --- a/app/src/main/java/fr/medicapp/medicapp/ui/navigation/RootNavigationGraph.kt +++ b/app/src/main/java/fr/medicapp/medicapp/ui/navigation/RootNavigationGraph.kt @@ -45,7 +45,7 @@ fun RootNavGraph( ) } - userNavGraph(navController, onThemeChange, isUser, isDownload, context) + userNavGraph(navController, isUser, isDownload, context) } } diff --git a/app/src/main/java/fr/medicapp/medicapp/ui/navigation/SideEffectNavGraph.kt b/app/src/main/java/fr/medicapp/medicapp/ui/navigation/SideEffectNavGraph.kt index 0a5db268..3fcbcc6c 100644 --- a/app/src/main/java/fr/medicapp/medicapp/ui/navigation/SideEffectNavGraph.kt +++ b/app/src/main/java/fr/medicapp/medicapp/ui/navigation/SideEffectNavGraph.kt @@ -15,7 +15,6 @@ import fr.medicapp.medicapp.ui.screen.root.RootRoute import fr.medicapp.medicapp.ui.screen.sideeffect.SideEffectDetail import fr.medicapp.medicapp.ui.screen.sideeffect.SideEffectEdit import fr.medicapp.medicapp.ui.screen.sideeffect.SideEffectHome -import fr.medicapp.medicapp.ui.theme.ThemeColorScheme import fr.medicapp.medicapp.viewModel.SharedSideEffectDetailViewModel import fr.medicapp.medicapp.viewModel.SharedSideEffectEditViewModel @@ -27,7 +26,6 @@ import fr.medicapp.medicapp.viewModel.SharedSideEffectEditViewModel @RequiresApi(Build.VERSION_CODES.O) fun NavGraphBuilder.sideEffectNavGraph( navController: NavHostController, - onThemeChange: (ThemeColorScheme) -> Unit ) { /** * Définit la navigation pour le graphe de prescription. diff --git a/app/src/main/java/fr/medicapp/medicapp/ui/navigation/UserNavGraph.kt b/app/src/main/java/fr/medicapp/medicapp/ui/navigation/UserNavGraph.kt index c6e55cd6..b1d782d3 100644 --- a/app/src/main/java/fr/medicapp/medicapp/ui/navigation/UserNavGraph.kt +++ b/app/src/main/java/fr/medicapp/medicapp/ui/navigation/UserNavGraph.kt @@ -13,7 +13,6 @@ import androidx.navigation.navigation import fr.medicapp.medicapp.ui.components.screen.Loading import fr.medicapp.medicapp.ui.screen.user.UserEditAllergy import fr.medicapp.medicapp.ui.screen.user.UserEditGeneralInformation -import fr.medicapp.medicapp.ui.theme.ThemeColorScheme import fr.medicapp.medicapp.viewModel.SharedUserEditViewModel /** @@ -25,12 +24,10 @@ import fr.medicapp.medicapp.viewModel.SharedUserEditViewModel @RequiresApi(Build.VERSION_CODES.O) fun NavGraphBuilder.userNavGraph( navController: NavHostController, - onThemeChange: (ThemeColorScheme) -> Unit, isUser: Boolean, isDownload: Boolean, context: Context ) { - var isDataDownloaded = false navigation( route = Graph.USER, From 4e9e8d27810b47ff79c317fc8f301ec23c09b875 Mon Sep 17 00:00:00 2001 From: Lexonchik Date: Tue, 27 Feb 2024 17:42:32 +0100 Subject: [PATCH 2/6] reformatting --- .../main/java/fr/medicapp/medicapp/ui/navigation/UserNavGraph.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/fr/medicapp/medicapp/ui/navigation/UserNavGraph.kt b/app/src/main/java/fr/medicapp/medicapp/ui/navigation/UserNavGraph.kt index b1d782d3..027b0745 100644 --- a/app/src/main/java/fr/medicapp/medicapp/ui/navigation/UserNavGraph.kt +++ b/app/src/main/java/fr/medicapp/medicapp/ui/navigation/UserNavGraph.kt @@ -19,7 +19,6 @@ import fr.medicapp.medicapp.viewModel.SharedUserEditViewModel * Cette fonction construit le graphe de navigation pour l'écran utilisateur. * * @param navController Le contrôleur de navigation. - * @param onThemeChange La fonction de changement de thème. */ @RequiresApi(Build.VERSION_CODES.O) fun NavGraphBuilder.userNavGraph( From 1df68cb5c7198706ba219f38daff5bc5fc46db05 Mon Sep 17 00:00:00 2001 From: Lexonchik Date: Tue, 27 Feb 2024 21:24:55 +0100 Subject: [PATCH 3/6] remove th unused lambda parameter line 74 --- .../java/fr/medicapp/medicapp/ui/navigation/UserNavGraph.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/fr/medicapp/medicapp/ui/navigation/UserNavGraph.kt b/app/src/main/java/fr/medicapp/medicapp/ui/navigation/UserNavGraph.kt index 027b0745..8413993d 100644 --- a/app/src/main/java/fr/medicapp/medicapp/ui/navigation/UserNavGraph.kt +++ b/app/src/main/java/fr/medicapp/medicapp/ui/navigation/UserNavGraph.kt @@ -71,7 +71,7 @@ fun NavGraphBuilder.userNavGraph( context.getSharedPreferences("medicapp", Context.MODE_PRIVATE) snapshotFlow { sharedPreferences.getBoolean("isDataDownloaded", false) - }.collect { isDataDownloaded -> + }.collect { Log.d("Guegueintervention", "ça change !!!!!!!") navController.navigate(Graph.HOME) { popUpTo(Graph.HOME) { From 4c96bb78a57b3b3131a55cd287c91220572a64e4 Mon Sep 17 00:00:00 2001 From: Lexonchik Date: Tue, 27 Feb 2024 22:29:08 +0100 Subject: [PATCH 4/6] modal show only when a new medoc is added and it has redondant --- .../ui/screen/prescription/PrescriptionHome.kt | 16 ++++++++++++++-- .../medicapp/ui/screen/root/RootScreen.kt | 1 - .../viewModel/SharedPrescriptionEditViewModel.kt | 2 ++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/fr/medicapp/medicapp/ui/screen/prescription/PrescriptionHome.kt b/app/src/main/java/fr/medicapp/medicapp/ui/screen/prescription/PrescriptionHome.kt index e0ecbab3..03fca1bd 100644 --- a/app/src/main/java/fr/medicapp/medicapp/ui/screen/prescription/PrescriptionHome.kt +++ b/app/src/main/java/fr/medicapp/medicapp/ui/screen/prescription/PrescriptionHome.kt @@ -1,5 +1,6 @@ package fr.medicapp.medicapp.ui.screen.prescription +import android.content.Context import android.os.Build import androidx.annotation.RequiresApi import androidx.compose.foundation.layout.Column @@ -47,6 +48,10 @@ fun PrescriptionHome( var alertRedondantOpen by remember { mutableStateOf(false) } var isReportModalOpen by remember { mutableStateOf(false) } val context = LocalContext.current + val sharedPrefs = context.getSharedPreferences("medicapp", Context.MODE_PRIVATE) + val isNewMedicationAdded = sharedPrefs + .getBoolean("isNewMedicationAdded", false) + Home( title = "Prescriptions", floatingActionButtons = { @@ -90,13 +95,14 @@ fun PrescriptionHome( prescription.medication?.medicationCompositions?.any { it.substanceCode in (lastMedocCompo ?: emptyList()) } == true - } + } && isNewMedicationAdded } PrescriptionList( prescriptions = prescriptions, onPrescriptionClick = onPrescriptionClick ) + } else -> { @@ -117,7 +123,13 @@ fun PrescriptionHome( content = "Attention, le médicament que vous venez de rajouter contient le même principe actif qu'un déjà présent dans vos traitements", dismissText = "", confirmText = "Compris", - onConfirm = { alertRedondantOpen = false } + onConfirm = { + alertRedondantOpen = false + with(sharedPrefs.edit()) { + putBoolean("isNewMedicationAdded", false) + apply() + } + } ) } } diff --git a/app/src/main/java/fr/medicapp/medicapp/ui/screen/root/RootScreen.kt b/app/src/main/java/fr/medicapp/medicapp/ui/screen/root/RootScreen.kt index 7c336b01..aae08aa1 100644 --- a/app/src/main/java/fr/medicapp/medicapp/ui/screen/root/RootScreen.kt +++ b/app/src/main/java/fr/medicapp/medicapp/ui/screen/root/RootScreen.kt @@ -117,7 +117,6 @@ fun RootScreen( ) { HomeNavGraph( navController = navController, - onThemeChange = onThemeChange ) } } diff --git a/app/src/main/java/fr/medicapp/medicapp/viewModel/SharedPrescriptionEditViewModel.kt b/app/src/main/java/fr/medicapp/medicapp/viewModel/SharedPrescriptionEditViewModel.kt index 60e26123..62f7f5fd 100644 --- a/app/src/main/java/fr/medicapp/medicapp/viewModel/SharedPrescriptionEditViewModel.kt +++ b/app/src/main/java/fr/medicapp/medicapp/viewModel/SharedPrescriptionEditViewModel.kt @@ -148,6 +148,8 @@ class SharedPrescriptionEditViewModel( _sharedState.value[0] = PrescriptionRepository(context).getById(id) addToNotificationManager(context) _sharedState.value.removeAt(0) + context.getSharedPreferences("medicapp", Context.MODE_PRIVATE).edit() + .putBoolean("isNewMedicationAdded", true).apply() } } From b23ccd49bce0be414bcf5ea34e8fe92761adcd60 Mon Sep 17 00:00:00 2001 From: Lexonchik Date: Tue, 27 Feb 2024 22:30:56 +0100 Subject: [PATCH 5/6] removing onthemechange for RootScreen --- .../fr/medicapp/medicapp/ui/navigation/RootNavigationGraph.kt | 1 - .../java/fr/medicapp/medicapp/ui/screen/root/RootScreen.kt | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/src/main/java/fr/medicapp/medicapp/ui/navigation/RootNavigationGraph.kt b/app/src/main/java/fr/medicapp/medicapp/ui/navigation/RootNavigationGraph.kt index 8da6e164..ec647b5b 100644 --- a/app/src/main/java/fr/medicapp/medicapp/ui/navigation/RootNavigationGraph.kt +++ b/app/src/main/java/fr/medicapp/medicapp/ui/navigation/RootNavigationGraph.kt @@ -41,7 +41,6 @@ fun RootNavGraph( composable(route = Graph.HOME) { RootScreen( theme = theme, - onThemeChange = onThemeChange ) } diff --git a/app/src/main/java/fr/medicapp/medicapp/ui/screen/root/RootScreen.kt b/app/src/main/java/fr/medicapp/medicapp/ui/screen/root/RootScreen.kt index aae08aa1..77801ba8 100644 --- a/app/src/main/java/fr/medicapp/medicapp/ui/screen/root/RootScreen.kt +++ b/app/src/main/java/fr/medicapp/medicapp/ui/screen/root/RootScreen.kt @@ -37,7 +37,6 @@ import kotlinx.coroutines.launch fun RootScreen( navController: NavHostController = rememberNavController(), theme: ThemeColorScheme, - onThemeChange: (ThemeColorScheme) -> Unit, ) { val scope = rememberCoroutineScope() @@ -131,5 +130,5 @@ fun RootScreen( @Preview @Composable private fun RootPreview() { - RootScreen(theme = EUYellowColorShema, onThemeChange = {}) + RootScreen(theme = EUYellowColorShema) } From 909a4c54b0b320d630854588f4ce45a90be82852 Mon Sep 17 00:00:00 2001 From: Lexonchik Date: Tue, 27 Feb 2024 22:33:45 +0100 Subject: [PATCH 6/6] removing onthemechange for RootNavGraph --- app/src/main/java/fr/medicapp/medicapp/MainActivity.kt | 1 - .../fr/medicapp/medicapp/ui/navigation/RootNavigationGraph.kt | 1 - 2 files changed, 2 deletions(-) diff --git a/app/src/main/java/fr/medicapp/medicapp/MainActivity.kt b/app/src/main/java/fr/medicapp/medicapp/MainActivity.kt index a4b3575e..7aebae34 100644 --- a/app/src/main/java/fr/medicapp/medicapp/MainActivity.kt +++ b/app/src/main/java/fr/medicapp/medicapp/MainActivity.kt @@ -60,7 +60,6 @@ class MainActivity : ComponentActivity() { RootNavGraph( navController = rememberNavController(), theme = theme, - onThemeChange = { theme = it }, isUser = isUser, isDownload = isDownloaded, context = this diff --git a/app/src/main/java/fr/medicapp/medicapp/ui/navigation/RootNavigationGraph.kt b/app/src/main/java/fr/medicapp/medicapp/ui/navigation/RootNavigationGraph.kt index ec647b5b..89b809d0 100644 --- a/app/src/main/java/fr/medicapp/medicapp/ui/navigation/RootNavigationGraph.kt +++ b/app/src/main/java/fr/medicapp/medicapp/ui/navigation/RootNavigationGraph.kt @@ -20,7 +20,6 @@ import fr.medicapp.medicapp.ui.theme.ThemeColorScheme fun RootNavGraph( navController: NavHostController, theme: ThemeColorScheme, - onThemeChange: (ThemeColorScheme) -> Unit, isUser: Boolean, isDownload: Boolean, context: Context