Skip to content

Commit

Permalink
Merge pull request #102 from waseefakhtar/feature/delete-additional-time
Browse files Browse the repository at this point in the history
Feature: Add support to delete additional time in AddMedication
  • Loading branch information
waseefakhtar authored Nov 11, 2023
2 parents 25d8d89 + fa27b18 commit 7e89b91
Showing 1 changed file with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ 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.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.KeyboardOptions
Expand All @@ -18,6 +19,7 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.DateRange
import androidx.compose.material.icons.filled.Delete
import androidx.compose.material.icons.filled.Info
import androidx.compose.material3.Button
import androidx.compose.material3.DropdownMenuItem
Expand All @@ -27,6 +29,7 @@ import androidx.compose.material3.ExposedDropdownMenuDefaults
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.FloatingActionButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SelectableDates
Expand All @@ -42,6 +45,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
Expand Down Expand Up @@ -265,12 +269,14 @@ fun AddMedicationScreen(

for (index in selectedTimes.indices) {
TimerTextField(
isLastItem = selectedTimes.lastIndex == index,
isOnlyItem = selectedTimes.size == 1,
time = {
selectedTimes[index] = it
},
onDeleteClick = {
analyticsHelper.logEvent(AnalyticsEvents.ADD_MEDICATION_DELETE_TIME_CLICKED)
removeTime(it)
removeTime(selectedTimes[index])
},
analyticsHelper = analyticsHelper
)
Expand Down Expand Up @@ -465,8 +471,10 @@ fun EndDateTextField(endDate: (Long) -> Unit) {

@Composable
fun TimerTextField(
isLastItem: Boolean,
isOnlyItem: Boolean,
time: (CalendarInformation) -> Unit,
onDeleteClick: (CalendarInformation) -> Unit,
onDeleteClick: () -> Unit,
analyticsHelper: AnalyticsHelper
) {
val interactionSource = remember { MutableInteractionSource() }
Expand All @@ -493,17 +501,19 @@ fun TimerTextField(
onValueChange = {},
trailingIcon = {
// TODO: Make delete action work properly
/*Row(
verticalAlignment = Alignment.CenterVertically
) {
IconButton(onClick = { onDeleteClick(selectedTime) } ) {
Icon(
imageVector = Icons.Default.Delete,
contentDescription = "Delete",
modifier = Modifier.size(24.dp)
)
if (isLastItem && !isOnlyItem) {
Row(
verticalAlignment = Alignment.CenterVertically
) {
IconButton(onClick = onDeleteClick) {
Icon(
imageVector = Icons.Default.Delete,
contentDescription = "Delete",
modifier = Modifier.size(24.dp)
)
}
}
}*/
}
},
interactionSource = interactionSource
)
Expand Down

0 comments on commit 7e89b91

Please sign in to comment.