This commit is contained in:
Trey t
2025-11-07 12:21:48 -06:00
parent 66fe773398
commit 1b777049a8
27 changed files with 2003 additions and 718 deletions

View File

@@ -3,11 +3,13 @@ package com.example.mycrib
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.safeContentPadding
import androidx.compose.material3.Button
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
@@ -32,9 +34,18 @@ import androidx.navigation.compose.rememberNavController
import androidx.navigation.compose.composable
import androidx.navigation.toRoute
import com.mycrib.android.ui.screens.MainScreen
import com.mycrib.android.ui.screens.ProfileScreen
import com.mycrib.android.ui.theme.MyCribTheme
import com.mycrib.navigation.*
import com.mycrib.repository.LookupsRepository
import com.mycrib.shared.models.Residence
import com.mycrib.shared.models.TaskCategory
import com.mycrib.shared.models.TaskDetail
import com.mycrib.shared.models.TaskFrequency
import com.mycrib.shared.models.TaskPriority
import com.mycrib.shared.models.TaskStatus
import com.mycrib.shared.network.ApiResult
import com.mycrib.shared.network.AuthApi
import com.mycrib.storage.TokenStorage
import mycrib.composeapp.generated.resources.Res
@@ -55,12 +66,12 @@ fun App() {
if (hasToken) {
// Fetch current user to check verification status
val authApi = com.mycrib.shared.network.AuthApi()
val authApi = AuthApi()
val token = TokenStorage.getToken()
if (token != null) {
when (val result = authApi.getCurrentUser(token)) {
is com.mycrib.shared.network.ApiResult.Success -> {
is ApiResult.Success -> {
isVerified = result.data.verified
LookupsRepository.initialize()
}
@@ -76,33 +87,34 @@ fun App() {
isCheckingAuth = false
}
if (isCheckingAuth) {
// Show loading screen while checking auth
MyCribTheme {
if (isCheckingAuth) {
// Show loading screen while checking auth
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
CircularProgressIndicator()
}
}
return@MyCribTheme
}
val startDestination = when {
!isLoggedIn -> LoginRoute
!isVerified -> VerifyEmailRoute
else -> MainRoute
}
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
androidx.compose.foundation.layout.Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
androidx.compose.material3.CircularProgressIndicator()
}
}
return
}
val startDestination = when {
!isLoggedIn -> LoginRoute
!isVerified -> VerifyEmailRoute
else -> MainRoute
}
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
NavHost(
NavHost(
navController = navController,
startDestination = startDestination
) {
@@ -187,6 +199,11 @@ fun App() {
onAddResidence = {
navController.navigate(AddResidenceRoute)
},
onAddTask = {
// Tasks are added from within a residence
// Navigate to first residence or show message if no residences exist
// For now, this will be handled by the UI showing "add a property first"
},
onNavigateToEditResidence = { residence ->
navController.navigate(
EditResidenceRoute(
@@ -399,16 +416,20 @@ fun App() {
composable<EditTaskRoute> { backStackEntry ->
val route = backStackEntry.toRoute<EditTaskRoute>()
EditTaskScreen(
task = com.mycrib.shared.models.TaskDetail(
task = TaskDetail(
id = route.taskId,
residence = route.residenceId,
title = route.title,
description = route.description,
category = com.mycrib.shared.models.TaskCategory(route.categoryId, route.categoryName),
frequency = com.mycrib.shared.models.TaskFrequency(route.frequencyId, route.frequencyName, ""),
priority = com.mycrib.shared.models.TaskPriority(route.priorityId, route.priorityName, displayName = route.statusName ?: ""),
category = TaskCategory(route.categoryId, route.categoryName),
frequency = TaskFrequency(
route.frequencyId, route.frequencyName, "",
daySpan = 0,
notifyDays = 0
),
priority = TaskPriority(route.priorityId, route.priorityName, displayName = route.statusName ?: ""),
status = route.statusId?.let {
com.mycrib.shared.models.TaskStatus(it, route.statusName ?: "", displayName = route.statusName ?: "")
TaskStatus(it, route.statusName ?: "", displayName = route.statusName ?: "")
},
dueDate = route.dueDate,
estimatedCost = route.estimatedCost,
@@ -426,7 +447,7 @@ fun App() {
}
composable<ProfileRoute> {
com.mycrib.android.ui.screens.ProfileScreen(
ProfileScreen(
onNavigateBack = {
navController.popBackStack()
},
@@ -443,6 +464,7 @@ fun App() {
)
}
}
}
}