Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/AddPrescription-View' into AddPr…
Browse files Browse the repository at this point in the history
…escription-View
  • Loading branch information
E211439A authored and E211439A committed Jan 12, 2024
2 parents 53f1ab9 + c617ff2 commit bcae87c
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 25 deletions.
22 changes: 20 additions & 2 deletions app/src/main/java/fr/medicapp/medicapp/ui/home/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import fr.medicapp.medicapp.ui.theme.EUGreen120
@Composable
fun HomeScreen(
onAddPrescriptionClick: () -> Unit,
onAddSideEffectClick: () -> Unit
onAddSideEffectClick: () -> Unit,
onAddNotification: () -> Unit
) {
Column(
modifier = Modifier
Expand Down Expand Up @@ -78,6 +79,22 @@ fun HomeScreen(
) {
Text(text = "Signaler un effet indésirable")
}
Button(
onClick = {
onAddNotification()
},
modifier = Modifier
.fillMaxWidth()
.padding(top = 10.dp, bottom = 0.dp),
colors = ButtonDefaults.buttonColors(
containerColor = EUGreen100
),
shape = RoundedCornerShape(10.dp)
) {
Text(
text = "Ajouter un rappel",
)
}
}
}

Expand All @@ -86,6 +103,7 @@ fun HomeScreen(
private fun HomeScreenPreview() {
HomeScreen(
onAddPrescriptionClick = { },
onAddSideEffectClick = { }
onAddSideEffectClick = { },
onAddNotification = { }
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ fun HomeNavGraph(navController: NavHostController) {
onAddSideEffectClick = {
navController.navigate(SideEffectRoute.AddSideEffect.route)
},
onAddNotification = {
navController.navigate(NotificationRoute.AddNotification.route)
}
)
}
prescriptionNavGraph(navController)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ fun NavGraphBuilder.notificationNavGraph(
Notifications(
notifications = notification,
onClose = {
navController.popBackStack()
navController.navigate(NotificationRoute.Main.route) {
popUpTo(NotificationRoute.ShowNotification.route) {
inclusive = true
}
}
},
onRemove = {
notification.forEach {
Expand All @@ -152,7 +156,11 @@ fun NavGraphBuilder.notificationNavGraph(
repositoryNotification.delete(side)
}
}.start()
navController.popBackStack()
navController.navigate(NotificationRoute.Main.route) {
popUpTo(NotificationRoute.ShowNotification.route) {
inclusive = true
}
}
}
)
}
Expand Down Expand Up @@ -227,8 +235,19 @@ fun NavGraphBuilder.notificationNavGraph(
Thread {
repository.add(state.toEntity())
}.start()
navController.navigate(NotificationRoute.Main.route)
}
navController.navigate(NotificationRoute.Main.route) {
popUpTo(NotificationRoute.AddNotification.route) {
inclusive = true
}
}
},
onCancel = {
navController.navigate(NotificationRoute.Main.route) {
popUpTo(NotificationRoute.AddNotification.route) {
inclusive = true
}
}
},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ fun NavGraphBuilder.prescriptionNavGraph(
Prescription(
consultation = prescription,
onClose = {
navController.popBackStack()
navController.navigate(PrescriptionRoute.Main.route) {
popUpTo(PrescriptionRoute.Prescription.route) {
inclusive = true
}
}
},
onRemove = {
Thread {
Expand Down Expand Up @@ -182,7 +186,11 @@ fun NavGraphBuilder.prescriptionNavGraph(
}
}
}.start()
navController.popBackStack()
navController.navigate(PrescriptionRoute.Main.route) {
popUpTo(PrescriptionRoute.Prescription.route) {
inclusive = true
}
}
},
onUpdate = {treatmentId, notificationValue ->
Thread {
Expand Down Expand Up @@ -383,7 +391,25 @@ fun NavGraphBuilder.prescriptionNavGraph(
repository.addAll(*state.treatments.map { it.toEntity() }
.toTypedArray())
}.start()
navController.popBackStack()
state.treatments.forEach {
Log.d("TEST", it.notification.toString())
}

Log.d("TEST", "Notification: ${state.treatments.any { it.notification }}")

if (state.treatments.any { it.notification }) {
navController.navigate(NotificationRoute.AddNotification.route) {
popUpTo(PrescriptionRoute.AddPrescription.route) {
inclusive = true
}
}
} else {
navController.navigate(PrescriptionRoute.Main.route) {
popUpTo(PrescriptionRoute.AddPrescription.route) {
inclusive = true
}
}
}
},
onCameraPicker = {
imageUri = context.createImageFile()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,23 @@ fun NavGraphBuilder.sideEffectNavGraph(
navController.navigate(PrescriptionRoute.Prescription.route.replace("{id}", id))
},
onClose = {
navController.popBackStack()
navController.navigate(SideEffectRoute.Main.route) {
popUpTo(SideEffectRoute.SideEffect.route) {
inclusive = true
}
}
},
onRemove = {
Thread {
sideEffect.map { side -> side.toEntity() }.forEach { side ->
repositorySideEffect.delete(side)
}
}.start()
navController.popBackStack()
navController.navigate(SideEffectRoute.Main.route) {
popUpTo(SideEffectRoute.SideEffect.route) {
inclusive = true
}
}
}
)
}
Expand Down Expand Up @@ -139,11 +147,20 @@ fun NavGraphBuilder.sideEffectNavGraph(
Thread {
repositorySideEffect.add(state.toEntity())
}.start()
navController.popBackStack()
navController.navigate(SideEffectRoute.Main.route) {
popUpTo(SideEffectRoute.AddSideEffect.route) {
inclusive = true
}
}
},
) {
navController.popBackStack()
}
onCancel = {
navController.navigate(SideEffectRoute.Main.route) {
popUpTo(SideEffectRoute.AddSideEffect.route) {
inclusive = true
}
}
}
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
Expand Down Expand Up @@ -231,11 +232,10 @@ fun Notifications(
Row(
Modifier
.fillMaxWidth()
.padding(vertical = 8.dp)
.padding(vertical = 8.dp),
horizontalArrangement = Arrangement.SpaceBetween
) {
DayOfWeek.values().forEachIndexed { index, dayOfWeek ->
/*Text(text = getFrenchDayOfWeek(dayOfWeek), modifier = Modifier.align(
Alignment.CenterVertically))*/
val checked = notification.frequency.contains(dayOfWeek)

val tint by animateColorAsState(if (checked) EUYellow120 else EUYellow100)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
Expand Down Expand Up @@ -85,11 +86,13 @@ import fr.medicapp.medicapp.ui.theme.EUGreen100
import fr.medicapp.medicapp.ui.theme.EUGreen40
import fr.medicapp.medicapp.ui.theme.EURed100
import fr.medicapp.medicapp.ui.theme.EURed20
import fr.medicapp.medicapp.ui.theme.EURed40
import fr.medicapp.medicapp.ui.theme.EURed80
import fr.medicapp.medicapp.ui.theme.EUYellow100
import fr.medicapp.medicapp.ui.theme.EUYellow110
import fr.medicapp.medicapp.ui.theme.EUYellow120
import fr.medicapp.medicapp.ui.theme.EUYellow140
import fr.medicapp.medicapp.ui.theme.EUYellow20
import fr.medicapp.medicapp.ui.theme.EUYellow40
import fr.medicapp.medicapp.ui.theme.EUYellow80
import java.time.DayOfWeek
Expand All @@ -102,6 +105,7 @@ import java.util.Date
fun NotificationsEdit(
notification: Notification,
onConfirm: () -> Unit,
onCancel: () -> Unit = {},
treatments: MutableList<Treatment> = mutableListOf()
) {
var darkmode : Boolean = isSystemInDarkTheme()
Expand Down Expand Up @@ -163,7 +167,7 @@ fun NotificationsEdit(
) {
Button(
onClick = {
//onCancel()
onCancel()
},
shape = RoundedCornerShape(20),
colors = ButtonDefaults.buttonColors(
Expand Down Expand Up @@ -332,7 +336,8 @@ fun NotificationsEdit(
Row(
Modifier
.fillMaxWidth()
.padding(vertical = 8.dp)
.padding(vertical = 8.dp),
horizontalArrangement = Arrangement.SpaceBetween
) {
DayOfWeek.values().forEachIndexed { index, dayOfWeek ->
val checked = frequency.contains(dayOfWeek)
Expand Down Expand Up @@ -408,6 +413,10 @@ fun NotificationsEdit(
if (frequencyTimeOpen.value) {
TimePickerModal(
state = frequencyTimeState,
clockBackgroundColor = EUYellow20,
selectorColor = EUYellow100,
timeSelectorSelectedContainerColor = EUYellow40,
timeSelectorUnselectedContainerColor = EUYellow20,
onDismissRequest = {
frequencyTimeOpen.value = false
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ElevatedCard
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
Expand All @@ -33,6 +34,7 @@ import fr.medicapp.medicapp.ui.theme.EUPurple40
import fr.medicapp.medicapp.ui.theme.EUPurple80
import fr.medicapp.medicapp.ui.theme.EUYellow110

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SearchDialog(
options: List<OptionDialog>,
Expand Down Expand Up @@ -62,6 +64,9 @@ fun SearchDialog(
LazyColumn {
items(filteredOptions) { option ->
ElevatedCard(
onClick = {
selectedOption = option
},
modifier = Modifier.fillMaxWidth(),
colors = if (option == selectedOption) {
CardDefaults.cardColors(
Expand All @@ -77,9 +82,7 @@ fun SearchDialog(
) {
Text(
text = option.title,
modifier = Modifier.clickable {
selectedOption = option
}.padding(5.dp),
modifier = Modifier.padding(5.dp),
)

option.description?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TextField
import androidx.compose.material3.TimePicker
import androidx.compose.material3.TimePickerColors
import androidx.compose.material3.TimePickerDefaults
import androidx.compose.material3.TimePickerState
import androidx.compose.material3.rememberDatePickerState
import androidx.compose.material3.rememberTimePickerState
Expand All @@ -31,11 +33,20 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import fr.medicapp.medicapp.ui.theme.EUPurple10
import fr.medicapp.medicapp.ui.theme.EUPurple100
import fr.medicapp.medicapp.ui.theme.EUPurple20
import fr.medicapp.medicapp.ui.theme.EUPurple40
import fr.medicapp.medicapp.ui.theme.EUPurple80

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun TimePickerModal(
state: TimePickerState,
clockBackgroundColor : Color = EUPurple20,
selectorColor : Color = EUPurple100,
timeSelectorSelectedContainerColor : Color = EUPurple40,
timeSelectorUnselectedContainerColor : Color = EUPurple20,
onDismissRequest: () -> Unit = {},
onConfirm: () -> Unit = {},
) {
Expand All @@ -59,7 +70,15 @@ fun TimePickerModal(
) {
// time picker
TimePicker(
state = state
state = state,
colors = TimePickerDefaults.colors(
clockDialColor = clockBackgroundColor, // Couleur de fond de l'horloge
selectorColor = selectorColor, // Couleur du marqueur pour changer l'heure
timeSelectorSelectedContainerColor = timeSelectorSelectedContainerColor, // Couleur du fond de l'objet sélectionné
timeSelectorSelectedContentColor = Color.Black, // Couleur du texte de l'objet sélectionné
timeSelectorUnselectedContainerColor = timeSelectorUnselectedContainerColor, // Couleur du fond de l'objet non sélectionné
timeSelectorUnselectedContentColor = Color.Black // Couleur du texte de l'objet non sélectionné
)
)

// buttons
Expand Down Expand Up @@ -91,6 +110,7 @@ fun TimePickerModal(
@Composable
private fun TimePickerModalPreview() {
TimePickerModal(
TimePickerState(10, 20, true)
TimePickerState(10, 20, true),

)
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import fr.medicapp.medicapp.ui.theme.EUGreen100
import fr.medicapp.medicapp.ui.theme.EUGreen40
import fr.medicapp.medicapp.ui.theme.EURed100
import fr.medicapp.medicapp.ui.theme.EURed20
import fr.medicapp.medicapp.ui.theme.EURed40
import fr.medicapp.medicapp.ui.theme.EURed60
import fr.medicapp.medicapp.ui.theme.EURed80
import java.time.Instant
Expand Down Expand Up @@ -364,6 +365,10 @@ fun SEDEdit(
if (frequencyTimeOpen.value) {
TimePickerModal(
state = frequencyTimeState,
clockBackgroundColor = EURed20,
selectorColor = EURed100,
timeSelectorSelectedContainerColor = EURed40,
timeSelectorUnselectedContainerColor = EURed20,
onDismissRequest = {
frequencyTimeOpen.value = false
},
Expand Down

0 comments on commit bcae87c

Please sign in to comment.