Skip to content

Commit

Permalink
Atom enhancements (#137)
Browse files Browse the repository at this point in the history
* Make task detail full screen and hide

Also, given a new screen has been added, also the logic for showing or hiding the bottom nav has been set up.

* Add new navigation layout

Also, the libraries have been upgraded to their latest version

* Fix bottom sheet safe drawing

* Remove elevation and keep a plain design on agenda

* Use border color to emphasize today's day

Also, this would let us remain the day of the week and day of the month equal no matter if it's today or not, which is more pleasant in terms of visual alignment

* Improve and add missing copies

* Replace deprecated code

* Open detail when tap on task card and add more icon

Now, the actions will be opened only when tapping on the more icon. And, by default, the task detail screen will be opened when tapping anywhere on the task card

Also, the height has been decreased to have a cleaner and more condensed UI

* Fix scroll when tapping on today

* Show calendar view when tap on calendar action icon

* Remove unnecessary code

* Add swipe to delete a task

* Fix lint errors

* Remove unused component

* Fix TextField style

* Fix edge to edge status and navigation styling
  • Loading branch information
costular authored Oct 10, 2024
1 parent 2bb2e9e commit 8beb9ee
Show file tree
Hide file tree
Showing 110 changed files with 629 additions and 1,911 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added
- Swipe to remove

### Changed
- New adaptative layout
- Task detail screen is used by default now
- New today indicator
- Cleaner and more condensed design
- Header is not expandable now, it's been replaced by the select day dialog

### Deprecated

Expand Down
16 changes: 5 additions & 11 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import com.costular.atomtasks.Versioning

plugins {
id("atomtasks.android.application")
kotlin("kapt")
id("kotlin-parcelize")
id("com.google.gms.google-services")
id("com.google.firebase.crashlytics")
Expand Down Expand Up @@ -67,10 +66,6 @@ android {
}
}

kapt {
correctErrorTypes = true
}

configurations {
androidTestImplementation {
exclude(group = "io.mockk", module = "mockk-agent-jvm")
Expand All @@ -84,28 +79,25 @@ dependencies {
implementation(projects.core.logging)
implementation(project(":data"))
implementation(project(":feature:agenda"))
implementation(project(":feature:createtask"))
implementation(project(":feature:settings"))
implementation(projects.common.tasks)
implementation(projects.feature.edittask)
implementation(projects.feature.postponeTask)
implementation(projects.feature.detail)

implementation(libs.fragment)
implementation(libs.compose.activity)
implementation(libs.compose.ui)
implementation(libs.compose.material3)
implementation(libs.compose.material3.windowsize)
implementation(libs.compose.adaptative.navigation)
implementation(libs.compose.material.icons)
implementation(libs.accompanist.systemui)
implementation(libs.compose.ui.tooling)
implementation(libs.androidx.core)
implementation(libs.appcompat)
implementation(libs.lifecycle.compose)
implementation(libs.viewmodel)
implementation(libs.hilt)
implementation(libs.profileinstaller)
kapt(libs.hilt.compiler)
ksp(libs.hilt.compiler)
implementation(libs.hilt.work)
implementation(libs.hilt.navigation.compose)
implementation(libs.startup)
Expand All @@ -115,7 +107,9 @@ dependencies {
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.analytics)
implementation(libs.firebase.crashlytics)
implementation(libs.compose.destinations)
implementation(libs.compose.destinations.core)
implementation(libs.compose.destinations.bottomsheet)
ksp(libs.compose.destinations.ksp)

testImplementation(libs.android.junit)
testImplementation(libs.junit)
Expand Down
48 changes: 4 additions & 44 deletions app/src/main/java/com/costular/atomtasks/ui/AppNavigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,14 @@ package com.costular.atomtasks.ui

import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.State
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.navigation.NavController
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.ramcosta.composedestinations.DestinationsNavHost
import com.ramcosta.composedestinations.animations.rememberAnimatedNavHostEngine
import com.ramcosta.composedestinations.generated.NavGraphs
import com.ramcosta.composedestinations.navigation.dependency
import com.ramcosta.composedestinations.rememberNavHostEngine
import com.ramcosta.composedestinations.scope.DestinationScopeWithNoDependencies
import com.ramcosta.composedestinations.spec.NavGraphSpec

@Stable
@Composable
fun NavController.currentScreenAsState(): State<NavGraphSpec> {
val selectedItem = remember { mutableStateOf(NavGraphs.agenda) }

DisposableEffect(this) {
val listener = NavController.OnDestinationChangedListener { _, destination, _ ->
selectedItem.value = destination.navGraph()
}
addOnDestinationChangedListener(listener)

onDispose {
removeOnDestinationChangedListener(listener)
}
}

return selectedItem
}

fun NavDestination.navGraph(): NavGraphSpec {
hierarchy.forEach { destination ->
NavGraphs.root.nestedNavGraphs.forEach { navGraph ->
if (destination.route == navGraph.route) {
return navGraph
}
}
}

throw NavigationError(route)
}

fun DestinationScopeWithNoDependencies<*>.currentNavigator(): AppNavigator {
return AppNavigator(navController)
Expand All @@ -62,13 +23,12 @@ internal fun AppNavigation(
modifier: Modifier = Modifier,
) {
DestinationsNavHost(
engine = rememberAnimatedNavHostEngine(),
engine = rememberNavHostEngine(),
navController = appState.navController,
navGraph = NavGraphs.root,
navGraph = NavGraphs.main,
modifier = modifier,
dependenciesContainerBuilder = {
dependency(currentNavigator())
dependency(appState.windowSizeClass)
dependency(fabClick)
},
)
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/com/costular/atomtasks/ui/MainGraph.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.costular.atomtasks.ui

import com.ramcosta.composedestinations.annotation.ExternalNavGraph
import com.ramcosta.composedestinations.annotation.NavHostGraph
import com.ramcosta.composedestinations.generated.agenda.navgraphs.AgendaNavGraph
import com.ramcosta.composedestinations.generated.detail.navgraphs.TaskDetailNavGraph
import com.ramcosta.composedestinations.generated.settings.navgraphs.SettingsNavGraph

@NavHostGraph
annotation class MainGraph {
@ExternalNavGraph<SettingsNavGraph>
@ExternalNavGraph<TaskDetailNavGraph>()
@ExternalNavGraph<AgendaNavGraph>(start = true)
companion object Includes
}
76 changes: 0 additions & 76 deletions app/src/main/java/com/costular/atomtasks/ui/NavGraphs.kt

This file was deleted.

16 changes: 3 additions & 13 deletions app/src/main/java/com/costular/atomtasks/ui/home/AppNavigator.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.costular.atomtasks.ui.home

import androidx.navigation.NavController
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.generated.agenda.destinations.TasksActionsBottomSheetDestination
import com.ramcosta.composedestinations.generated.detail.destinations.TaskDetailScreenDestination
import com.ramcosta.composedestinations.generated.settings.destinations.ThemeSelectorScreenDestination
import com.ramcosta.composedestinations.utils.toDestinationsNavigator
import java.time.LocalDate

Expand All @@ -19,14 +17,6 @@ class AppNavigator(
navController.toDestinationsNavigator()
}

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

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

override fun navigateToDetailScreenForCreateTask(date: String) {
destinationsNavigator.navigate(
TaskDetailScreenDestination(
Expand Down
47 changes: 28 additions & 19 deletions app/src/main/java/com/costular/atomtasks/ui/home/AtomAppState.kt
Original file line number Diff line number Diff line change
@@ -1,44 +1,53 @@
package com.costular.atomtasks.ui.home

import androidx.compose.material3.windowsizeclass.WindowSizeClass
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo
import androidx.compose.material3.adaptive.navigationsuite.NavigationSuiteScaffoldDefaults
import androidx.compose.material3.adaptive.navigationsuite.NavigationSuiteType
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.remember
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavGraph.Companion.findStartDestination
import androidx.navigation.NavHostController
import androidx.navigation.compose.currentBackStackEntryAsState
import com.ramcosta.composedestinations.spec.NavGraphSpec
import com.ramcosta.composedestinations.generated.agenda.destinations.AgendaScreenDestination
import com.ramcosta.composedestinations.generated.settings.destinations.SettingsScreenDestination
import com.ramcosta.composedestinations.generated.settings.destinations.ThemeSelectorScreenDestination
import com.ramcosta.composedestinations.spec.DestinationSpec
import com.ramcosta.composedestinations.utils.currentDestinationAsState

@Composable
fun rememberAtomAppState(
navController: NavHostController,
windowSizeClass: WindowSizeClass,
): AtomAppState {
return remember(navController, windowSizeClass) {
AtomAppState(navController, windowSizeClass)
return remember(navController) {
AtomAppState(navController)
}
}

@Stable
class AtomAppState(
val navController: NavHostController,
val windowSizeClass: WindowSizeClass,
) {
val currentDestination: NavBackStackEntry?
@Composable get() = navController.currentBackStackEntryAsState().value
val currentDestination: DestinationSpec?
@Composable get() = navController.currentDestinationAsState().value

val atomNavigationType: AtomNavigationType
get() = when (windowSizeClass.widthSizeClass) {
WindowWidthSizeClass.Compact ->
AtomNavigationType.BOTTOM_NAVIGATION
WindowWidthSizeClass.Medium, WindowWidthSizeClass.Expanded ->
AtomNavigationType.RAIL_NAVIGATION
else -> AtomNavigationType.BOTTOM_NAVIGATION
val shouldShowNavigation: Boolean
@Composable get() = currentDestination?.route in listOf(
AgendaScreenDestination,
SettingsScreenDestination,
ThemeSelectorScreenDestination,
).map { it.route }

val navigationLayoutType: NavigationSuiteType
@Composable get() {
val adaptiveInfo = currentWindowAdaptiveInfo()
return if (!shouldShowNavigation) {
NavigationSuiteType.None
} else {
NavigationSuiteScaffoldDefaults.calculateFromAdaptiveInfo(adaptiveInfo)
}
}

fun navigateToTopLevelDestination(selected: NavGraphSpec) {
fun navigateToTopLevelDestination(selected: DestinationSpec) {
navController.navigate(selected.route) {
launchSingleTop = true
restoreState = true
Expand Down

This file was deleted.

Loading

0 comments on commit 8beb9ee

Please sign in to comment.