Skip to content
Merged
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 @@ -20,6 +20,7 @@ import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.DatePicker
import androidx.compose.material3.DatePickerDefaults
import androidx.compose.material3.DatePickerDialog
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Text
Expand All @@ -41,13 +42,13 @@ import com.example.tudee.designsystem.theme.TudeeTheme
import com.example.tudee.presentation.components.buttons.ButtonState
import com.example.tudee.presentation.components.buttons.PrimaryButton
import com.example.tudee.presentation.components.buttons.SecondaryButton
import com.example.tudee.presentation.screen.category.model.toUiImage
import com.example.tudee.presentation.screen.home.viewmodel.CategoryUiState
import com.example.tudee.presentation.screen.home.viewmodel.HomeActions
import com.example.tudee.presentation.screen.home.viewmodel.HomeUiState
import com.example.tudee.presentation.screen.home.viewmodel.TaskPriorityUiState
import com.example.tudee.presentation.screen.home.viewmodel.TaskUiState
import com.example.tudee.presentation.utils.clickWithRipple
import com.example.tudee.presentation.utils.toCategoryIcon
import kotlinx.datetime.Instant
import kotlinx.datetime.LocalDate
import kotlinx.datetime.TimeZone
Expand Down Expand Up @@ -143,7 +144,7 @@ fun TaskContent(
placeholder = stringResource(R.string.set_due_date),
leadingContent = { isFocused ->
DefaultLeadingContent(
modifier = Modifier.clickWithRipple{ showDatePicker = true },
modifier = Modifier.clickWithRipple { showDatePicker = true },
painter = painterResource(R.drawable.ic_add_calendar),
isFocused = isFocused
)
Expand Down Expand Up @@ -184,7 +185,13 @@ fun TaskContent(
modifier = Modifier
.padding(top = 8.dp)
.clip(CircleShape)
.clickWithRipple { onAction(HomeActions.OnEditTaskPriorityChanged(priority)) }
.clickWithRipple {
onAction(
HomeActions.OnEditTaskPriorityChanged(
priority
)
)
}
)
}
}
Expand All @@ -202,7 +209,7 @@ fun TaskContent(
columns = GridCells.Adaptive(minSize = 104.dp),
verticalArrangement = Arrangement.spacedBy(24.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp),
modifier =Modifier
modifier = Modifier
.heightIn(max = 3000.dp)
.fillMaxWidth()
.padding(bottom = 160.dp),
Expand All @@ -211,9 +218,7 @@ fun TaskContent(
items(categories) { categories ->

CategoryItemWithBadge(
categoryPainter = painterResource(
categories.image.toCategoryIcon()
),
categoryPainter = categories.image.toUiImage().asPainter(),
showCheckedIcon = state.selectedTask.taskCategory.id == categories.id,
badgeBackgroundColor = TudeeTheme.color.statusColors.greenAccent,
categoryName = categories.title,
Expand Down Expand Up @@ -246,7 +251,11 @@ fun TaskContent(
) {
PrimaryButton(
modifier = Modifier.fillMaxWidth(),
state = if (state.selectedTask.taskDescription.isNotBlank() == true && state.selectedTask.taskTitle.isNotBlank() == true) ButtonState.IDLE else ButtonState.DISABLED,
state = if (state.selectedTask.taskDescription.isNotBlank() == true &&
state.selectedTask.taskTitle.isNotBlank() == true &&
state.selectedTask.taskCategory.title.isNotBlank() == true

) ButtonState.IDLE else ButtonState.DISABLED,
onClick = {
if (mode == TaskContentMode.EDIT) {
onAction(HomeActions.OnEditTaskButtonClicked)
Expand Down Expand Up @@ -283,6 +292,10 @@ fun DatePickerDialogComponent(

DatePickerDialog(
onDismissRequest = onDismiss,
colors = DatePickerDefaults.colors(
containerColor = TudeeTheme.color.surface
, titleContentColor = TudeeTheme.color.textColors.title
),
confirmButton = {
Button(onClick = {
val selectedDateMillis = datePickerState.selectedDateMillis
Expand All @@ -306,7 +319,24 @@ fun DatePickerDialogComponent(
}
}
) {
DatePicker(state = datePickerState)
DatePicker(state = datePickerState
, headline = {

},
colors = DatePickerDefaults.colors(
navigationContentColor =TudeeTheme.color.textColors.title ,
headlineContentColor = TudeeTheme.color.textColors.title,
titleContentColor = TudeeTheme.color.textColors.title,
weekdayContentColor = TudeeTheme.color.textColors.title,
dayContentColor=TudeeTheme.color.textColors.title,
containerColor = TudeeTheme.color.statusColors.greenAccent ,
selectedDayContainerColor = TudeeTheme.color.primary,
selectedDayContentColor = TudeeTheme.color.textColors.onPrimary,
todayContentColor = TudeeTheme.color.primary,
todayDateBorderColor = TudeeTheme.color.primary,

)
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.content.res.Configuration
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -40,12 +39,12 @@ import com.example.tudee.R
import com.example.tudee.designsystem.theme.TudeeTheme
import com.example.tudee.presentation.components.buttons.ButtonState
import com.example.tudee.presentation.components.buttons.SecondaryButton
import com.example.tudee.presentation.screen.category.model.toUiImage
import com.example.tudee.presentation.screen.home.viewmodel.CategoryUiState
import com.example.tudee.presentation.screen.home.viewmodel.TaskPriorityUiState
import com.example.tudee.presentation.screen.home.viewmodel.TaskStatusUiState
import com.example.tudee.presentation.screen.home.viewmodel.TaskUiState
import com.example.tudee.presentation.utils.clickWithRipple
import com.example.tudee.presentation.utils.toCategoryIcon
import kotlinx.datetime.LocalDate

@OptIn(ExperimentalMaterial3Api::class)
Expand Down Expand Up @@ -148,7 +147,9 @@ private fun TudeeTaskDetails(task: TaskUiState, modifier: Modifier = Modifier) {
.padding(top = 12.dp)
.background(color = TudeeTheme.color.surfaceHigh, shape = CircleShape)
) {
task.taskCategory.image?.let { painterResource(it.toCategoryIcon()) }?.let {
task.taskCategory.image?.let {
it.toUiImage().asPainter()
}?.let {
Image(
modifier = Modifier.padding(15.dp), painter = it,
contentDescription = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.core.text.isDigitsOnly
import coil3.compose.rememberAsyncImagePainter
import coil3.imageLoader
import com.example.tudee.presentation.utils.predefinedCategories
import com.example.tudee.presentation.utils.toCategoryIcon
import java.io.File

sealed class UiImage {
Expand Down Expand Up @@ -36,8 +37,8 @@ sealed class UiImage {
}

fun String.toUiImage(): UiImage {
return if (isDigitsOnly()) {
UiImage.Drawable(toInt())
return if (this in predefinedCategories.map { it.image }) {
UiImage.Drawable(this.toCategoryIcon())
} else {
UiImage.External(this)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import com.example.tudee.designsystem.theme.TudeeTheme
import com.example.tudee.domain.entity.TaskPriority
import com.example.tudee.domain.entity.TaskStatus
import com.example.tudee.presentation.components.CategoryTaskComponent
import com.example.tudee.presentation.screen.category.model.toUiImage
import com.example.tudee.presentation.screen.home.toTaskPriorityUiState
import com.example.tudee.presentation.screen.home.toTaskStatusUiState
import com.example.tudee.presentation.screen.home.viewmodel.CategoryUiState
import com.example.tudee.presentation.screen.home.viewmodel.HomeActions
import com.example.tudee.presentation.screen.home.viewmodel.TaskPriorityUiState
import com.example.tudee.presentation.screen.home.viewmodel.TaskUiState
import com.example.tudee.presentation.utils.toCategoryIcon
import kotlinx.datetime.LocalDate

@Composable
Expand Down Expand Up @@ -73,8 +73,9 @@ fun TaskList(
priorityIcon = painterResource(id = priorityIcon),
priorityBackgroundColor = priorityColor,
taskIcon = {

Image(
painter = painterResource(task.taskCategory.image.toCategoryIcon()),
painter = task.taskCategory.image.toUiImage().asPainter(),
contentDescription = "taskIcon",
)
},
Expand Down
Loading