Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
costular committed Aug 2, 2024
2 parents ee2b550 + 2df8b27 commit be91002
Show file tree
Hide file tree
Showing 79 changed files with 1,448 additions and 60 deletions.
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ dependencies {
implementation(projects.common.tasks)
implementation(projects.feature.edittask)
implementation(projects.feature.postponeTask)
implementation(projects.feature.detail)

implementation(libs.fragment)
implementation(libs.compose.activity)
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/com/costular/atomtasks/ui/AppNavigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import androidx.navigation.NavDestination
import androidx.navigation.NavDestination.Companion.hierarchy
import com.costular.atomtasks.ui.home.AppNavigator
import com.costular.atomtasks.ui.home.AtomAppState
import com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApi
import com.ramcosta.composedestinations.DestinationsNavHost
import com.ramcosta.composedestinations.animations.rememberAnimatedNavHostEngine
import com.ramcosta.composedestinations.navigation.dependency
Expand Down Expand Up @@ -55,7 +54,6 @@ fun DestinationScopeWithNoDependencies<*>.currentNavigator(): AppNavigator {
return AppNavigator(navController)
}

@OptIn(ExperimentalMaterialNavigationApi::class)
@ExperimentalAnimationApi
@Composable
internal fun AppNavigation(
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/costular/atomtasks/ui/NavGraphs.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.costular.atomtasks.ui

import com.atomtasks.feature.detail.destinations.TaskDetailScreenDestination
import com.costular.atomtasks.agenda.destinations.AgendaScreenDestination
import com.costular.atomtasks.agenda.destinations.TasksActionsBottomSheetDestination
import com.costular.atomtasks.createtask.destinations.CreateTaskScreenDestination
Expand All @@ -20,6 +21,7 @@ object NavGraphs {
override val destinationsByRoute = listOf<DestinationSpec<*>>(
AgendaScreenDestination,
TasksActionsBottomSheetDestination,
TaskDetailScreenDestination,
).associateBy { it.route }
}

Expand Down
40 changes: 32 additions & 8 deletions app/src/main/java/com/costular/atomtasks/ui/home/AppNavigator.kt
Original file line number Diff line number Diff line change
@@ -1,35 +1,59 @@
package com.costular.atomtasks.ui.home

import androidx.navigation.NavController
import com.costular.atomtasks.agenda.ui.AgendaNavigator
import com.atomtasks.feature.detail.destinations.TaskDetailScreenDestination
import com.costular.atomtasks.agenda.destinations.TasksActionsBottomSheetDestination
import com.costular.atomtasks.agenda.ui.AgendaNavigator
import com.costular.atomtasks.createtask.destinations.CreateTaskScreenDestination
import com.costular.atomtasks.feature.edittask.destinations.EditTaskScreenDestination
import com.costular.atomtasks.settings.SettingsNavigator
import com.costular.atomtasks.settings.destinations.ThemeSelectorScreenDestination
import com.ramcosta.composedestinations.navigation.navigate
import com.ramcosta.composedestinations.utils.toDestinationsNavigator
import java.time.LocalDate

class AppNavigator(
private val navController: NavController,
) : SettingsNavigator, AgendaNavigator {

override fun navigateToCreateTask(date: String, text: String?) {
navController.navigate(CreateTaskScreenDestination(text = text, date = date))
private val destinationsNavigator by lazy {
navController.toDestinationsNavigator()
}

override fun navigateToCreateTask(date: String) {
destinationsNavigator.navigate(CreateTaskScreenDestination(date))
}

override fun navigateToEditTask(taskId: Long) {
navController.navigate(EditTaskScreenDestination(taskId))
destinationsNavigator.navigate(EditTaskScreenDestination(taskId))
}

override fun navigateToDetailScreenForCreateTask(date: String) {
destinationsNavigator.navigate(
TaskDetailScreenDestination(
defaultDate = LocalDate.parse(date),
taskId = null,
)
)
}

override fun navigateToDetailScreenToEdit(taskId: Long) {
destinationsNavigator.navigate(
TaskDetailScreenDestination(
defaultDate = null,
taskId = taskId
)
)
}

override fun openTaskActions(taskId: Long, taskName: String, isDone: Boolean) {
navController.navigate(TasksActionsBottomSheetDestination(taskId, taskName, isDone))
destinationsNavigator.navigate(TasksActionsBottomSheetDestination(taskId, taskName, isDone))
}

override fun navigateUp() {
navController.navigateUp()
destinationsNavigator.navigateUp()
}

override fun navigateToSelectTheme(theme: String) {
navController.navigate(ThemeSelectorScreenDestination(theme))
destinationsNavigator.navigate(ThemeSelectorScreenDestination(theme))
}
}
3 changes: 1 addition & 2 deletions app/src/main/java/com/costular/atomtasks/ui/home/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ import com.costular.atomtasks.ui.AppNavigation
import com.costular.atomtasks.ui.NavGraphs
import com.costular.atomtasks.ui.currentScreenAsState
import com.costular.designsystem.theme.AtomTheme
import com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApi
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import com.ramcosta.composedestinations.animations.rememberAnimatedNavHostEngine
import com.ramcosta.composedestinations.spec.NavGraphSpec
import com.costular.atomtasks.core.ui.R.string as S

@OptIn(ExperimentalAnimationApi::class, ExperimentalMaterialNavigationApi::class)
@OptIn(ExperimentalAnimationApi::class)
@Composable
fun App(
windowSizeClass: WindowSizeClass,
Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ plugins {
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.firebase.crashlytics) apply false
alias(libs.plugins.kotlin.compose.compiler) apply false
alias(libs.plugins.jetbrains.kotlin.android) apply false
}
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,10 @@ private fun NotificationPermissionEffect(
onAccept: @Composable () -> Unit,
) {
if (LocalInspectionMode.current) return
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) return
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
onAccept()
return
}

val context = LocalContext.current
val alarmManager = context.applicationContext.getSystemService<AlarmManager>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import com.costular.atomtasks.tasks.model.RecurrenceType
import com.costular.atomtasks.core.ui.R.string as S

@Composable
fun RecurrenceType.localized(): String {
fun RecurrenceType?.localized(): String {
if (this == null) {
return stringResource(S.task_recurrence_never)
}

val stringRes = when(this) {
RecurrenceType.DAILY -> S.task_recurrence_daily
RecurrenceType.WEEKDAYS -> S.task_recurrence_weekdays
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import androidx.compose.foundation.selection.selectable
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Check
import androidx.compose.material.ripple.rememberRipple
import androidx.compose.material3.Icon
import androidx.compose.material3.ripple
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
Expand Down Expand Up @@ -59,7 +59,7 @@ fun Markable(
isMarked,
interactionSource = interaction,
role = Role.Checkbox,
indication = rememberRipple(bounded = false),
indication = ripple(),
enabled = true,
onClick = onClick,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@ package com.costular.designsystem.components
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.material3.OutlinedTextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.VisualTransformation

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AtomOutlinedTextField(
value: String,
Expand All @@ -37,8 +35,6 @@ fun AtomOutlinedTextField(
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
shape: Shape = MaterialTheme.shapes.small,
) {
val colors = TextFieldDefaults.outlinedTextFieldColors()

OutlinedTextField(
value = value,
onValueChange = onValueChange,
Expand All @@ -58,6 +54,6 @@ fun AtomOutlinedTextField(
maxLines = maxLines,
interactionSource = interactionSource,
shape = shape,
colors = colors,
colors = OutlinedTextFieldDefaults.colors(),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@ package com.costular.atomtasks.core.ui
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material.navigation.ModalBottomSheetLayout
import androidx.compose.material.navigation.rememberBottomSheetNavigator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.navigation.NavHostController
import androidx.navigation.plusAssign
import com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApi
import com.google.accompanist.navigation.material.ModalBottomSheetLayout
import com.google.accompanist.navigation.material.rememberBottomSheetNavigator
import androidx.navigation.NavArgs

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun DestinationsScaffold(
navController: NavHostController,
Expand All @@ -34,7 +30,6 @@ fun DestinationsScaffold(
}
}

@OptIn(ExperimentalMaterialNavigationApi::class)
@Composable
fun DestinationsBottomSheet(
navController: NavHostController,
Expand Down
32 changes: 23 additions & 9 deletions core/ui/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,41 @@
<string name="agenda_mark_as_undone">Mark as undone</string>
<string name="agenda_create_new_task">New task</string>
<string name="agenda_tutorial_task_order">Want your tasks in order? Long press and drag!</string>

<string name="today">Today</string>
<string name="create_task_set_date">Choose a Date</string>
<string name="create_task_set_reminder">Set reminder</string>
<string name="create_task_set_recurrence">Repeat</string>
<string name="task_recurrence_never">Just once</string>
<string name="task_recurrence_daily">Daily</string>
<string name="task_recurrence_weekdays">Weekdays</string>
<string name="task_recurrence_weekly">Weekly</string>
<string name="task_recurrence_monthly">Monthly</string>
<string name="task_recurrence_yearly">Yearly</string>
<string name="remove_task_message">Are you sure to remove this task?</string>
<string name="no_reminder">No reminder</string>
<string name="enable_reminder">Enable reminder</string>
<string name="task_list_empty_title">No tasks</string>
<string name="task_list_empty_description">Create a task and start organizing your life!</string>

<!-- Create task -->
<string name="create_task_set_date">Choose a Date</string>
<string name="create_task_set_reminder">Set reminder</string>
<string name="create_task_set_recurrence">Repeat</string>
<string name="create_task_recurrence_picker_none">Does not repeat</string>
<string name="create_task_recurrence_picker_daily">Every Day</string>
<string name="create_task_recurrence_picker_weekdays">Every Weekday</string>
<string name="create_task_recurrence_picker_weekly">Every Week</string>
<string name="create_task_recurrence_picker_monthly">Every Month</string>
<string name="create_task_recurrence_picker_yearly">Every Year</string>
<string name="remove_task_message">Are you sure to remove this task?</string>
<string name="no_reminder">No reminder</string>
<string name="enable_reminder">Enable reminder</string>
<string name="task_list_empty_title">No tasks</string>
<string name="task_list_empty_description">Create a task and start organizing your life!</string>

<!-- Task detail -->
<string name="task_detail_day_subhead">Date</string>
<string name="task_detail_reminder_subhead">Reminder</string>
<string name="task_detail_reminder_add_reminder">Reminder</string>
<string name="task_detail_recurrence_subhead">Repeat</string>
<string name="task_detail_recurrence_picker_none">Does not repeat</string>
<string name="task_detail_recurrence_picker_daily">Every Day</string>
<string name="task_detail_recurrence_picker_weekdays">Every Weekday</string>
<string name="task_detail_recurrence_picker_weekly">Every Week</string>
<string name="task_detail_recurrence_picker_monthly">Every Month</string>
<string name="task_detail_recurrence_picker_yearly">Every Year</string>

<string name="notification_channel_reminders_title">Reminders</string>
<string name="notification_channel_reminders_description">Reminders for your tasks</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@ package com.costular.atomtasks.agenda.ui
interface AgendaNavigator {
fun navigateToCreateTask(
date: String,
text: String? = null,
)

fun navigateToEditTask(
taskId: Long,
)

fun navigateToDetailScreenForCreateTask(
date: String,
)

fun navigateToDetailScreenToEdit(
taskId: Long,
)

fun openTaskActions(
taskId: Long,
taskName: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.costular.atomtasks.agenda.actions.TaskActionsResult
import com.costular.atomtasks.agenda.destinations.TasksActionsBottomSheetDestination
import com.costular.atomtasks.core.ui.mvi.EventObserver
import com.costular.atomtasks.core.ui.utils.DevicesPreview
import com.costular.atomtasks.core.ui.utils.generateWindowSizeClass
import com.costular.atomtasks.review.ui.ReviewHandler
Expand Down Expand Up @@ -74,19 +75,33 @@ internal fun AgendaScreen(
) {
val state by viewModel.state.collectAsStateWithLifecycle()

LaunchedEffect(Unit) {
setFabOnClick {
viewModel.onCreateTask()
navigator.navigateToCreateTask(state.selectedDay.date.toString())
EventObserver(viewModel.uiEvents) { event ->
when (event) {
is AgendaUiEvents.GoToNewTaskScreen -> {
if (event.shouldShowNewScreen) {
navigator.navigateToDetailScreenForCreateTask(event.date.toString())
} else {
navigator.navigateToCreateTask(event.date.toString())
}
}

is AgendaUiEvents.GoToEditScreen -> {
if (event.shouldShowNewScreen) {
navigator.navigateToDetailScreenToEdit(event.taskId)
} else {
navigator.navigateToEditTask(event.taskId)
}
}
}
}

LaunchedEffect(Unit) {
setFabOnClick(viewModel::onCreateTask)
}

HandleResultRecipients(
resultRecipient = resultRecipient,
onEdit = { taskId ->
viewModel.onEditTask()
navigator.navigateToEditTask(taskId)
},
onEdit = viewModel::onEditTask,
onDelete = viewModel::actionDelete,
onMarkTask = viewModel::onMarkTask,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.costular.atomtasks.agenda.ui

import com.costular.atomtasks.core.ui.mvi.UiEvent
import java.time.LocalDate

sealed interface AgendaUiEvents : UiEvent {

data class GoToNewTaskScreen(
val date: LocalDate,
val shouldShowNewScreen: Boolean,
) : AgendaUiEvents

data class GoToEditScreen(
val taskId: Long,
val shouldShowNewScreen: Boolean,
) : AgendaUiEvents
}
Loading

0 comments on commit be91002

Please sign in to comment.