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
@@ -0,0 +1,12 @@
package com.appnotresponding.rumbo.models

data class VisitedPlace(

Check warning

Code scanning / detekt

If a source file contains only a single non-private top-level class or object, the file name should reflect the case-sensitive name plus the .kt extension. Warning

The file name 'visitedPlace' does not match the name of the single top-level declaration 'VisitedPlace'.
Comment thread
Samu-Kiss marked this conversation as resolved.
Dismissed
val placeId: String = "",
val placeName: String = "",
val address: String = "",
val latitude: Double = 0.0,
val longitude: Double = 0.0,
val imageUrl: String? = null,
val city: String = "",
val visitedAt: Long = 0L
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,60 +14,54 @@ import com.appnotresponding.rumbo.ui.screens.itinerary.ItineraryScreen
import com.appnotresponding.rumbo.ui.screens.map.MapScreen
import com.appnotresponding.rumbo.ui.screens.onboarding.OnBoardingScreen
import com.appnotresponding.rumbo.ui.screens.plan.PlanScreen
import com.appnotresponding.rumbo.ui.screens.profile.ProfileScreen
import com.appnotresponding.rumbo.ui.screens.splash.SplashScreen
import com.appnotresponding.rumbo.ui.viewModel.PlacesViewModel
import androidx.lifecycle.ViewModel
import com.appnotresponding.rumbo.ui.viewModel.UserLocationViewModel

import com.appnotresponding.rumbo.ui.viewModel.UserViewModel

val placesViewModel: PlacesViewModel = PlacesViewModel()

enum class AppScreens{
Splash,
LogIn,
SignUp,
Map,
Chat,
ChatThread,
Plan,
Itinerary,
OnBoarding
enum class AppScreens {
Splash, LogIn, SignUp, Map, Chat, ChatThread, Plan, Itinerary, Profile, OnBoarding
}

@Composable
fun Navigation(
locationViewModel: UserLocationViewModel = viewModel(),
userViewModel: UserViewModel = viewModel()
){
val context = LocalContext.current
) {
LocalContext.current
val navController = rememberNavController()
NavHost(navController=navController, startDestination = AppScreens.Splash.name){
composable (route = AppScreens.Splash.name){
NavHost(navController = navController, startDestination = AppScreens.Splash.name) {
composable(route = AppScreens.Splash.name) {
SplashScreen(navController)
}
composable(route = AppScreens.LogIn.name){
composable(route = AppScreens.LogIn.name) {
LogInScreen(navController)
}
composable (route = AppScreens.SignUp.name){
composable(route = AppScreens.SignUp.name) {
SignUpScreen(navController)
}
composable (route = AppScreens.Map.name) {
composable(route = AppScreens.Map.name) {
MapScreen(navController, placesViewModel, locationViewModel, userViewModel)
}
composable (route = AppScreens.Chat.name) {
composable(route = AppScreens.Chat.name) {
ChatListScreen(navController, userViewModel)
}
composable(route = AppScreens.ChatThread.name){
composable(route = AppScreens.ChatThread.name) {
ChatThreadScreen(navController)
}
composable(route = AppScreens.Plan.name){
composable(route = AppScreens.Plan.name) {
PlanScreen(navController, placesViewModel, locationViewModel, userViewModel)
}
composable(route = AppScreens.Itinerary.name){
composable(route = AppScreens.Itinerary.name) {
ItineraryScreen(navController, placesViewModel, userViewModel)
}
composable(route = AppScreens.OnBoarding.name){
composable(route = AppScreens.Profile.name) {
ProfileScreen(navController, userViewModel)
}
composable(route = AppScreens.OnBoarding.name) {
OnBoardingScreen(navController)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.navigation.NavHostController
import com.appnotresponding.rumbo.auth
import com.appnotresponding.rumbo.models.sampleUser
import com.appnotresponding.rumbo.navigation.AppScreens
import com.appnotresponding.rumbo.ui.templates.ItineraryTemplate
Expand All @@ -21,11 +20,7 @@ fun ItineraryScreen(

ItineraryTemplate(
user = user, itineraryList = state.itinerary, controller = controller, onProfileClick = {
auth.signOut()
controller.navigate(AppScreens.Splash.name) {
popUpTo(controller.graph.startDestinationId) { inclusive = true }
launchSingleTop = true
}
controller.navigate(AppScreens.Profile.name)
}, placesViewModel
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.navigation.NavHostController
import com.appnotresponding.rumbo.auth
import com.appnotresponding.rumbo.models.sampleUser
import com.appnotresponding.rumbo.navigation.AppScreens
import com.appnotresponding.rumbo.ui.templates.MapTemplate
Expand All @@ -24,11 +23,7 @@ fun MapScreen(

MapTemplate(
user = user, controller = controller, onProfileClick = {
auth.signOut()
controller.navigate(AppScreens.Splash.name) {
popUpTo(controller.graph.startDestinationId) { inclusive = true }
launchSingleTop = true
}
controller.navigate(AppScreens.Profile.name)
}, placesViewModel = placesViewModel, locationViewModel = locationViewModel
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.platform.LocalContext
import androidx.navigation.NavHostController
import com.appnotresponding.rumbo.auth
import com.appnotresponding.rumbo.models.sampleUser
import com.appnotresponding.rumbo.navigation.AppScreens
import com.appnotresponding.rumbo.ui.templates.PlanTemplate
Expand Down Expand Up @@ -64,12 +63,8 @@ fun PlanScreen(
placesList = placesState.availablePlaces,
controller = controller,
onProfileClick = {
auth.signOut()
controller.navigate(AppScreens.Splash.name) {
popUpTo(controller.graph.startDestinationId) { inclusive = true }
launchSingleTop = true
}
controller.navigate(AppScreens.Profile.name)
},
placesViewModel
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.appnotresponding.rumbo.ui.screens.profile

import android.net.Uri
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavHostController
import com.appnotresponding.rumbo.auth
import com.appnotresponding.rumbo.navigation.AppScreens
import com.appnotresponding.rumbo.ui.templates.ProfileTemplate
import com.appnotresponding.rumbo.ui.viewModel.ProfileViewModel
import com.appnotresponding.rumbo.ui.viewModel.UserViewModel

@Composable
fun ProfileScreen(
controller: NavHostController,
userViewModel: UserViewModel,
profileViewModel: ProfileViewModel = viewModel()
) {
val userState by userViewModel.currentUserState.collectAsState()
val profileState by profileViewModel.uiState.collectAsState()
var selectedPhotoUri by remember { mutableStateOf<Uri?>(null) }

val imagePicker = rememberLauncherForActivityResult(
contract = ActivityResultContracts.GetContent()
) { uri ->
selectedPhotoUri = uri
}

val user = userState
if (user == null) {
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
CircularProgressIndicator(color = MaterialTheme.colorScheme.primary)
}
return
}

LaunchedEffect(user.id) {
profileViewModel.loadItineraryHistory(user.id)
profileViewModel.loadUserDropNotes(user.id)
}

ProfileTemplate(
user = user,
itineraryHistory = profileState.itineraryHistory,
dropNotes = profileState.userDropNotes,
selectedPhotoUri = selectedPhotoUri,
isSavingProfile = profileState.isSavingProfile,
profileError = profileState.profileError,
profileSuccess = profileState.profileSuccess,
controller = controller,
onBackClick = { controller.popBackStack() },
onPickPhoto = { imagePicker.launch("image/*") },
onSaveProfile = { name, lastname, phone ->
profileViewModel.updateProfile(
user = user,
name = name,
lastname = lastname,
phone = phone,
photoUri = selectedPhotoUri,
onSuccess = { selectedPhotoUri = null })
},
onSignOut = {
auth.signOut()
controller.navigate(AppScreens.Splash.name) {
popUpTo(controller.graph.startDestinationId) { inclusive = true }
launchSingleTop = true
}
})
}
Loading
Loading