-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 💚 navigated navigation * 💚 Improved Habits * 🔥 Improved Tasks * 🔐 Made a class for Datastore * 📦 Done with Categories * 📦 Updated metadata and screenshots and added german translations
- Loading branch information
Showing
63 changed files
with
1,551 additions
and
1,140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
14 changes: 0 additions & 14 deletions
14
app/src/main/java/com/shub39/grit/app/BottomAppBarDestination.kt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,143 @@ | ||
package com.shub39.grit.app | ||
|
||
import androidx.compose.animation.AnimatedContent | ||
import androidx.compose.animation.core.tween | ||
import androidx.compose.animation.fadeIn | ||
import androidx.compose.animation.fadeOut | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.FloatingActionButton | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.runtime.* | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.lifecycle.compose.collectAsStateWithLifecycle | ||
import com.shub39.grit.core.presentation.SettingsPage | ||
import androidx.navigation.compose.NavHost | ||
import androidx.navigation.compose.composable | ||
import androidx.navigation.compose.navigation | ||
import androidx.navigation.compose.rememberNavController | ||
import com.shub39.grit.R | ||
import com.shub39.grit.habits.presentation.HabitViewModel | ||
import com.shub39.grit.habits.presentation.HabitsPage | ||
import com.shub39.grit.tasks.presentation.TaskListViewModel | ||
import com.shub39.grit.tasks.presentation.TaskPage | ||
import com.shub39.grit.tasks.presentation.task_page.TaskPage | ||
import com.shub39.grit.tasks.presentation.tasks_settings.TaskSettings | ||
import org.koin.androidx.compose.koinViewModel | ||
|
||
@Composable | ||
fun Grit( | ||
tvm: TaskListViewModel = koinViewModel(), | ||
hvm: HabitViewModel = koinViewModel() | ||
) { | ||
var currentRoute: BottomAppBarDestination by remember { mutableStateOf(BottomAppBarDestination.TasksPage) } | ||
val navController = rememberNavController() | ||
var currentRoute: Routes by remember { mutableStateOf(Routes.TasksGraph) } | ||
|
||
val taskPageState by tvm.tasksState.collectAsStateWithLifecycle() | ||
val taskSettingsState by tvm.tasksSettings.collectAsStateWithLifecycle() | ||
val habitsPageState by hvm.habitsPageState.collectAsStateWithLifecycle() | ||
|
||
Scaffold( | ||
bottomBar = { | ||
BottomBar( | ||
currentRoute = currentRoute, | ||
onChange = { currentRoute = it } | ||
) | ||
floatingActionButton = { | ||
AnimatedContent( | ||
targetState = currentRoute, | ||
label = "fab" | ||
) { | ||
when (it) { | ||
Routes.HabitsPage -> { | ||
FloatingActionButton( | ||
onClick = { | ||
navController.navigate(Routes.TasksGraph) { | ||
launchSingleTop = true | ||
} | ||
} | ||
) { | ||
Icon( | ||
painter = painterResource(R.drawable.round_checklist_24), | ||
contentDescription = null | ||
) | ||
} | ||
} | ||
|
||
Routes.TasksPage -> { | ||
FloatingActionButton( | ||
onClick = { | ||
navController.navigate(Routes.HabitGraph) { | ||
launchSingleTop = true | ||
} | ||
} | ||
) { | ||
Icon( | ||
painter = painterResource(R.drawable.round_alarm_24), | ||
contentDescription = null | ||
) | ||
} | ||
} | ||
|
||
else -> {} | ||
} | ||
} | ||
} | ||
) { padding -> | ||
NavHost( | ||
navController = navController, | ||
startDestination = Routes.TasksGraph, | ||
modifier = Modifier.padding(padding), | ||
enterTransition = { fadeIn(animationSpec = tween(300)) }, | ||
exitTransition = { fadeOut(animationSpec = tween(300)) }, | ||
popEnterTransition = { fadeIn(animationSpec = tween(300)) }, | ||
popExitTransition = { fadeOut(animationSpec = tween(300)) } | ||
) { | ||
navigation<Routes.TasksGraph>( | ||
startDestination = Routes.TasksPage | ||
) { | ||
composable<Routes.TasksPage> { | ||
currentRoute = Routes.TasksPage | ||
|
||
TaskPage( | ||
state = taskPageState, | ||
action = tvm::taskPageAction, | ||
onSettingsClick = { | ||
navController.navigate(Routes.TasksSettings) { | ||
launchSingleTop = true | ||
} | ||
} | ||
) | ||
} | ||
|
||
composable<Routes.TasksSettings> { | ||
currentRoute = Routes.TasksSettings | ||
|
||
TaskSettings( | ||
state = taskSettingsState, | ||
action = tvm::tasksSettingsAction | ||
) | ||
} | ||
} | ||
|
||
navigation<Routes.HabitGraph>( | ||
startDestination = Routes.HabitsPage | ||
) { | ||
composable<Routes.HabitsPage> { | ||
currentRoute = Routes.HabitsPage | ||
|
||
HabitsPage( | ||
state = habitsPageState, | ||
action = hvm::habitsPageAction, | ||
onSettingsClick = { | ||
navController.navigate(Routes.HabitsSettings) { | ||
launchSingleTop = true | ||
} | ||
} | ||
) | ||
} | ||
|
||
composable<Routes.HabitsSettings> { | ||
currentRoute = Routes.HabitsSettings | ||
|
||
|
||
} | ||
} | ||
} | ||
) { innerPadding -> | ||
|
||
AnimatedContent( | ||
targetState = currentRoute, | ||
modifier = Modifier.padding(innerPadding), | ||
label = "page" | ||
) { | ||
when (it) { | ||
BottomAppBarDestination.TasksPage -> { | ||
TaskPage( | ||
state = taskPageState, | ||
action = tvm::taskPageAction | ||
) | ||
} | ||
BottomAppBarDestination.HabitsPage -> { | ||
HabitsPage( | ||
state = habitsPageState, | ||
action = hvm::habitsPageAction | ||
) | ||
} | ||
BottomAppBarDestination.SettingsPage -> { | ||
SettingsPage(tvm) | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.shub39.grit.app | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
sealed interface Routes { | ||
@Serializable | ||
data object HabitGraph: Routes | ||
|
||
@Serializable | ||
data object HabitsPage: Routes | ||
|
||
@Serializable | ||
data object HabitsSettings: Routes | ||
|
||
@Serializable | ||
data object TasksGraph: Routes | ||
|
||
@Serializable | ||
data object TasksPage: Routes | ||
|
||
@Serializable | ||
data object TasksSettings: Routes | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.