Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.mutableStateSetOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand All @@ -40,6 +44,7 @@
import com.infomaniak.calendar.components.eventdetail.component.TitleEditable
import com.infomaniak.calendar.components.eventdetail.form.component.AddReminderButton
import com.infomaniak.calendar.components.eventdetail.form.component.AllDaySwitch
import com.infomaniak.calendar.components.eventdetail.form.component.ReminderOffsetDialog
import com.infomaniak.calendar.components.eventdetail.models.EventColorChoice
import com.infomaniak.calendar.components.eventdetail.modifier.EventSharedElement
import com.infomaniak.calendar.components.eventdetail.modifier.ProvideEventSharedTransition
Expand Down Expand Up @@ -100,7 +105,18 @@
}

Section(EventSharedElement.Divider3) {
AddReminderButton(onClick = {})
var isReminderOffsetDialogVisible by rememberSaveable { mutableStateOf(false) }

AddReminderButton(onClick = { isReminderOffsetDialogVisible = true })

if (isReminderOffsetDialogVisible) {
ReminderOffsetDialog(
selectedOffset = null,
onOffsetSelect = { isReminderOffsetDialogVisible = false }, // TODO: Wire the selected offset to the event reminders

Check warning on line 115 in CalendarComponents/EventDetail/src/main/kotlin/com/infomaniak/calendar/components/eventdetail/form/EventForm.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this TODO comment.

See more on https://sonarcloud.io/project/issues?id=Infomaniak_android-calendar&issues=AaFo0uP-ktS8koFelbWC&open=AaFo0uP-ktS8koFelbWC&pullRequest=272
onCustomClick = {}, // TODO: Open the custom reminder editor

Check warning on line 116 in CalendarComponents/EventDetail/src/main/kotlin/com/infomaniak/calendar/components/eventdetail/form/EventForm.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this TODO comment.

See more on https://sonarcloud.io/project/issues?id=Infomaniak_android-calendar&issues=AaFo0uP-ktS8koFelbWD&open=AaFo0uP-ktS8koFelbWD&pullRequest=272
onDismissRequest = { isReminderOffsetDialogVisible = false },
)
}
}

Section(EventSharedElement.Divider4) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Infomaniak Calendar - Android
* Copyright (C) 2026 Infomaniak Network SA
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.infomaniak.calendar.components.eventdetail.form.component

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.selection.selectableGroup
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.AlertDialogDefaults
import androidx.compose.material3.BasicAlertDialog
import androidx.compose.material3.ListItem
import androidx.compose.material3.ListItemDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.RadioButton
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import com.infomaniak.calendar.components.foundation.utils.timeFormatter.formatDurationOffset
import com.infomaniak.calendar.components.resources.R
import com.infomaniak.designsystem.core.theme.EsdsTheme
import kotlin.time.Duration
import kotlin.time.Duration.Companion.days
import kotlin.time.Duration.Companion.hours
import kotlin.time.Duration.Companion.minutes

private val reminderOffsetPresets = listOf(
null,
Duration.ZERO,
(-5).minutes,
(-10).minutes,
(-15).minutes,
(-30).minutes,
(-1).hours,
(-1).days,
)

@Composable
internal fun ReminderOffsetDialog(
selectedOffset: Duration?,
onOffsetSelect: (offset: Duration?) -> Unit,
onCustomClick: () -> Unit,
onDismissRequest: () -> Unit,
) {
BasicAlertDialog(onDismissRequest = onDismissRequest) {
Surface(
shape = AlertDialogDefaults.shape,
color = AlertDialogDefaults.containerColor,
tonalElevation = AlertDialogDefaults.TonalElevation,
) {
Column(
Modifier
.selectableGroup()
.verticalScroll(rememberScrollState())
.padding(EsdsTheme.spacing.md),
Comment thread
NicolasBourdin88 marked this conversation as resolved.
Resolved
) {
val colors = ListItemDefaults.colors(containerColor = AlertDialogDefaults.containerColor)

reminderOffsetPresets.forEach { offset ->
val isSelected = offset == selectedOffset

ListItem(
selected = isSelected,
onClick = { onOffsetSelect(offset) },
trailingContent = { RadioButton(selected = isSelected, onClick = null) },
colors = colors,
) {
offset?.let { Text(it.formatDurationOffset()) } ?: Text(stringResource(R.string.alarmOffsetNone))
}
}

ListItem(onClick = onCustomClick, colors = colors) {
Text(stringResource(R.string.customAlarmLabel))
}
}
}
}
}

@Preview
@Composable
private fun Preview() {
MaterialTheme {
ReminderOffsetDialog(selectedOffset = null, onOffsetSelect = {}, onCustomClick = {}, onDismissRequest = {})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
-->
<resources>
<string name="addEventLabel">Tilføj</string>
<string name="alarmOffsetNone">Ingen</string>
<string name="allDayLabel">Hele dagen</string>
<string name="attendees">Deltagere</string>
<plurals name="attendeesAcceptedCount">
Expand Down Expand Up @@ -53,6 +54,7 @@
<string name="contentDescriptionHasLocation">Har en placering</string>
<string name="contentDescriptionSearch">Søg</string>
<string name="contentDescriptionToday">I dag</string>
<string name="customAlarmLabel">Brugerdefineret</string>
<plurals name="dayAmount">
<item quantity="one">%d dag</item>
<item quantity="other">%d dage</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
-->
<resources>
<string name="addEventLabel">Hinzufügen</string>
<string name="alarmOffsetNone">Keine</string>
<string name="allDayLabel">Den ganzen Tag</string>
<string name="attendees">Teilnehmer</string>
<plurals name="attendeesAcceptedCount">
Expand Down Expand Up @@ -53,6 +54,7 @@
<string name="contentDescriptionHasLocation">Hat einen Standort</string>
<string name="contentDescriptionSearch">Suchen</string>
<string name="contentDescriptionToday">Heute</string>
<string name="customAlarmLabel">Benutzerdefiniert</string>
<plurals name="dayAmount">
<item quantity="one">%d Tag</item>
<item quantity="other">%d Tage</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
-->
<resources>
<string name="addEventLabel">Προσθήκη</string>
<string name="alarmOffsetNone">Καμία</string>
<string name="allDayLabel">Όλη την ημέρα</string>
<string name="attendees">Συμμετέχοντες</string>
<plurals name="attendeesAcceptedCount">
Expand Down Expand Up @@ -53,6 +54,7 @@
<string name="contentDescriptionHasLocation">Έχει τοποθεσία</string>
<string name="contentDescriptionSearch">Αναζήτηση</string>
<string name="contentDescriptionToday">Σήμερα</string>
<string name="customAlarmLabel">Προσαρμοσμένο</string>
<plurals name="dayAmount">
<item quantity="one">%d ημέρα</item>
<item quantity="other">%d ημέρες</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
-->
<resources>
<string name="addEventLabel">Añadir</string>
<string name="alarmOffsetNone">Ninguna</string>
<string name="allDayLabel">Todo el día</string>
<string name="attendees">Invitados</string>
<plurals name="attendeesAcceptedCount">
Expand Down Expand Up @@ -53,6 +54,7 @@
<string name="contentDescriptionHasLocation">Tiene una ubicación</string>
<string name="contentDescriptionSearch">Buscar</string>
<string name="contentDescriptionToday">Hoy</string>
<string name="customAlarmLabel">Personalizado</string>
<plurals name="dayAmount">
<item quantity="one">%d día</item>
<item quantity="other">%d días</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
-->
<resources>
<string name="addEventLabel">Lisää</string>
<string name="alarmOffsetNone">Ei mitään</string>
<string name="allDayLabel">Koko päivän</string>
<string name="attendees">Osallistujat</string>
<plurals name="attendeesAcceptedCount">
Expand Down Expand Up @@ -53,6 +54,7 @@
<string name="contentDescriptionHasLocation">On sijainti</string>
<string name="contentDescriptionSearch">Haku</string>
<string name="contentDescriptionToday">Tänään</string>
<string name="customAlarmLabel">Mukautettu</string>
<plurals name="dayAmount">
<item quantity="one">%d päivä</item>
<item quantity="other">%d päivää</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
-->
<resources>
<string name="addEventLabel">Ajouter</string>
<string name="alarmOffsetNone">Aucun</string>
<string name="allDayLabel">Journée</string>
<string name="attendees">Invités</string>
<plurals name="attendeesAcceptedCount">
Expand Down Expand Up @@ -53,6 +54,7 @@
<string name="contentDescriptionHasLocation">A un emplacement</string>
<string name="contentDescriptionSearch">Rechercher</string>
<string name="contentDescriptionToday">Aujourd’hui</string>
<string name="customAlarmLabel">Personnalisé</string>
<plurals name="dayAmount">
<item quantity="one">%d jour</item>
<item quantity="other">%d jours</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
-->
<resources>
<string name="addEventLabel">Aggiungi</string>
<string name="alarmOffsetNone">Nessuno</string>
<string name="allDayLabel">Tutto il giorno</string>
<string name="attendees">Invitati</string>
<plurals name="attendeesAcceptedCount">
Expand Down Expand Up @@ -53,6 +54,7 @@
<string name="contentDescriptionHasLocation">Ha una sede</string>
<string name="contentDescriptionSearch">Cerca</string>
<string name="contentDescriptionToday">Oggi</string>
<string name="customAlarmLabel">Personalizzato</string>
<plurals name="dayAmount">
<item quantity="one">%d giorno</item>
<item quantity="other">%d giorni</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
-->
<resources>
<string name="addEventLabel">Legg til</string>
<string name="alarmOffsetNone">Ingen</string>
<string name="allDayLabel">Hele dagen</string>
<string name="attendees">Deltakere</string>
<plurals name="attendeesAcceptedCount">
Expand Down Expand Up @@ -53,6 +54,7 @@
<string name="contentDescriptionHasLocation">Har en beliggenhet</string>
<string name="contentDescriptionSearch">Søk</string>
<string name="contentDescriptionToday">I dag</string>
<string name="customAlarmLabel">Egendefinert</string>
<plurals name="dayAmount">
<item quantity="one">%d dag</item>
<item quantity="other">%d dager</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
-->
<resources>
<string name="addEventLabel">Toevoegen</string>
<string name="alarmOffsetNone">Geen</string>
<string name="allDayLabel">De hele dag</string>
<string name="attendees">Deelnemers</string>
<plurals name="attendeesAcceptedCount">
Expand Down Expand Up @@ -53,6 +54,7 @@
<string name="contentDescriptionHasLocation">Heeft een locatie</string>
<string name="contentDescriptionSearch">Zoeken</string>
<string name="contentDescriptionToday">Vandaag</string>
<string name="customAlarmLabel">Aangepast</string>
<plurals name="dayAmount">
<item quantity="one">%d dag</item>
<item quantity="other">%d dagen</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
-->
<resources>
<string name="addEventLabel">Dodaj</string>
<string name="alarmOffsetNone">Brak</string>
<string name="allDayLabel">Przez cały dzień</string>
<string name="attendees">Uczestnicy</string>
<plurals name="attendeesAcceptedCount">
Expand Down Expand Up @@ -65,6 +66,7 @@
<string name="contentDescriptionHasLocation">Ma lokalizację</string>
<string name="contentDescriptionSearch">Szukaj</string>
<string name="contentDescriptionToday">Dziś</string>
<string name="customAlarmLabel">Niestandardowe</string>
<plurals name="dayAmount">
<item quantity="one">%d dzień</item>
<item quantity="few">%d dni</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
-->
<resources>
<string name="addEventLabel">Adicionar</string>
<string name="alarmOffsetNone">Nenhum</string>
<string name="allDayLabel">O dia todo</string>
<string name="attendees">Convidados</string>
<plurals name="attendeesAcceptedCount">
Expand Down Expand Up @@ -53,6 +54,7 @@
<string name="contentDescriptionHasLocation">Tem uma localização</string>
<string name="contentDescriptionSearch">Pesquisar</string>
<string name="contentDescriptionToday">Hoje</string>
<string name="customAlarmLabel">Personalizado</string>
<plurals name="dayAmount">
<item quantity="one">%d dia</item>
<item quantity="other">%d dias</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
-->
<resources>
<string name="addEventLabel">Lägg till</string>
<string name="alarmOffsetNone">Ingen</string>
<string name="allDayLabel">Hela dagen</string>
<string name="attendees">Deltagare</string>
<plurals name="attendeesAcceptedCount">
Expand Down Expand Up @@ -53,6 +54,7 @@
<string name="contentDescriptionHasLocation">Har en plats</string>
<string name="contentDescriptionSearch">Sök</string>
<string name="contentDescriptionToday">Idag</string>
<string name="customAlarmLabel">Anpassad</string>
<plurals name="dayAmount">
<item quantity="one">%d dag</item>
<item quantity="other">%d dagar</item>
Expand Down
2 changes: 2 additions & 0 deletions CalendarComponents/Resources/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
-->
<resources>
<string name="addEventLabel">Add</string>
<string name="alarmOffsetNone">None</string>
<string name="allDayLabel">All Day</string>
<string name="attendees">Attendees</string>
<plurals name="attendeesAcceptedCount">
Expand Down Expand Up @@ -53,6 +54,7 @@
<string name="contentDescriptionHasLocation">Has a location</string>
<string name="contentDescriptionSearch">Search</string>
<string name="contentDescriptionToday">Today</string>
<string name="customAlarmLabel">Custom</string>
<plurals name="dayAmount">
<item quantity="one">%d day</item>
<item quantity="other">%d days</item>
Expand Down
Loading