Skip to content

Commit 1d4882a

Browse files
Merge pull request #178 from ShahanasParapporu/feature/rest_cust_selection_screen_design
Navigation flow added when selected Restaurant during initial setup : Issue #176
2 parents d11af2f + 6a33da1 commit 1d4882a

File tree

6 files changed

+271
-21
lines changed

6 files changed

+271
-21
lines changed

app/src/main/java/com/project/resqfood/presentation/MainActivity.kt

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ import androidx.compose.animation.slideInHorizontally
1515
import androidx.compose.foundation.layout.PaddingValues
1616
import androidx.compose.runtime.mutableStateOf
1717
import androidx.lifecycle.viewmodel.compose.viewModel
18+
import androidx.navigation.NavType
1819
import androidx.navigation.compose.NavHost
1920
import androidx.navigation.compose.composable
2021
import androidx.navigation.compose.rememberNavController
22+
import androidx.navigation.navArgument
23+
import androidx.navigation.toRoute
2124

2225
import com.google.firebase.auth.FirebaseAuth
2326
import com.project.resqfood.R
@@ -40,6 +43,8 @@ import com.project.resqfood.presentation.login.NavWaitScreen
4043
import com.project.resqfood.presentation.login.PersonalDetails
4144
import com.project.resqfood.presentation.login.Screens.MainScreen
4245
import com.project.resqfood.presentation.login.Screens.NavMainScreen
46+
import com.project.resqfood.presentation.login.Screens.NavRoleSelectScreen
47+
import com.project.resqfood.presentation.login.Screens.ResqFoodUserSelection
4348
import com.project.resqfood.presentation.login.SignInDataViewModel
4449
import com.project.resqfood.presentation.login.WaitScreen
4550
import com.project.resqfood.presentation.login.emaillogin.EmailSignInViewModel
@@ -63,7 +68,7 @@ import com.project.resqfood.presentation.restaurantonboarding.ListingViewModel
6368
import com.project.resqfood.presentation.restaurantonboarding.ListingViewModelFactory
6469
import com.project.resqfood.presentation.restaurantonboarding.NavListingRestaurant
6570
import com.project.resqfood.ui.theme.AppTheme
66-
import com.project.resqfood.presentation.login.Screens.ShoppingCartScreen
71+
//import com.project.resqfood.presentation.login.Screens.ShoppingCartScreen
6772
import com.project.resqfood.presentation.restaurantDashboard.NavRestaurantDashboardScreen
6873
import com.project.resqfood.presentation.restaurantDashboard.RestaurantDashboardScreen
6974
import com.project.resqfood.presentation.restaurantDashboard.RestaurantViewModel
@@ -173,7 +178,7 @@ class MainActivity : ComponentActivity() {
173178
) {
174179
PersonalDetails(navigationAfterCompletion = {
175180
navController.popBackStack(navController.graph.startDestinationId, true)
176-
navController.navigate(NavMainScreen)
181+
navController.navigate(NavRoleSelectScreen)
177182
})
178183
}
179184
composable<NavWaitScreen> {
@@ -228,9 +233,24 @@ class MainActivity : ComponentActivity() {
228233
composable<NavOnboarding>{
229234
Onboarding(navController = navController)
230235
}
231-
composable<NavListingRestaurant> {
236+
composable<NavRoleSelectScreen>{
237+
ResqFoodUserSelection(navController = navController)
238+
}
239+
/* composable<NavListingRestaurant> {
232240
ListingRestaurantScreen(restaurantListingViewModel, navController)
241+
}*/
242+
243+
composable<NavListingRestaurant> { backStackEntry ->
244+
val args = backStackEntry.toRoute<NavListingRestaurant>()
245+
ListingRestaurantScreen(
246+
restaurantListingViewModel,
247+
navController,
248+
args.entryPoint // pass it down
249+
)
233250
}
251+
252+
253+
234254
//added the shopping cart screen
235255
composable<ShoppingCartScreen>(
236256
enterTransition = { slideHorizontallyAnimation() }
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
package com.project.resqfood.presentation.login.Screens
2+
3+
import androidx.compose.foundation.background
4+
import androidx.compose.foundation.clickable
5+
import androidx.compose.foundation.layout.*
6+
import androidx.compose.foundation.shape.CircleShape
7+
import androidx.compose.foundation.shape.RoundedCornerShape
8+
import androidx.compose.material.icons.Icons
9+
import androidx.compose.material.icons.filled.Person
10+
import androidx.compose.material.icons.filled.Restaurant
11+
import androidx.compose.material3.*
12+
import androidx.compose.runtime.*
13+
import androidx.compose.ui.Alignment
14+
import androidx.compose.ui.Modifier
15+
import androidx.compose.ui.geometry.Offset
16+
import androidx.compose.ui.graphics.Brush
17+
import androidx.compose.ui.graphics.Color
18+
import androidx.compose.ui.graphics.RectangleShape
19+
import androidx.compose.ui.text.font.FontWeight
20+
import androidx.compose.ui.text.style.TextAlign
21+
import androidx.compose.ui.unit.dp
22+
import androidx.compose.ui.unit.sp
23+
import androidx.navigation.NavHostController
24+
import com.project.resqfood.presentation.restaurantonboarding.NavListingRestaurant
25+
import kotlinx.serialization.Serializable
26+
27+
@Serializable
28+
object NavRoleSelectScreen
29+
@Composable
30+
fun ResqFoodUserSelection(navController: NavHostController?) {
31+
Card(
32+
modifier = Modifier
33+
.fillMaxSize(),
34+
colors = CardDefaults.cardColors(
35+
containerColor = Color.Magenta.copy(alpha = 0.95f)
36+
),
37+
shape = RectangleShape,
38+
elevation = CardDefaults.cardElevation(defaultElevation = 8.dp)
39+
) {
40+
Box(
41+
modifier = Modifier
42+
.fillMaxSize()
43+
.background(
44+
brush = Brush.linearGradient(
45+
colors = listOf(
46+
Color(0xFFFF5E5E),
47+
Color(0xFFFFC78F)
48+
),
49+
start = Offset(80f, 0f),
50+
end = Offset(900f, 820f) // ~60° angle
51+
)
52+
)
53+
) {
54+
Column(
55+
modifier = Modifier
56+
.fillMaxSize()
57+
.padding(24.dp),
58+
horizontalAlignment = Alignment.CenterHorizontally
59+
) {
60+
// Header Section
61+
Spacer(modifier = Modifier.height(48.dp))
62+
63+
Text(
64+
text = "ResqFood",
65+
fontSize = 32.sp,
66+
fontWeight = FontWeight.Bold,
67+
color = Color(0xFF2E7D32)
68+
)
69+
70+
Spacer(modifier = Modifier.height(8.dp))
71+
72+
Text(
73+
text = "Reduce Food Waste, Save Money",
74+
fontSize = 16.sp,
75+
color = Color.Gray,
76+
textAlign = TextAlign.Center
77+
)
78+
79+
Spacer(modifier = Modifier.height(48.dp))
80+
81+
// Restaurant Option
82+
UserTypeCard(
83+
icon = {
84+
RestaurantIcon()
85+
},
86+
title = "Restaurant",
87+
description = "List your leftover food and reduce waste while earning extra revenue",
88+
onClick = { navController?.navigate(NavListingRestaurant(entryPoint = "fromRegistration")) }
89+
)
90+
91+
Spacer(modifier = Modifier.height(24.dp))
92+
93+
// Customer Option
94+
UserTypeCard(
95+
icon = {
96+
CustomerIcon()
97+
},
98+
title = "Customer",
99+
description = "Find delicious food at discounted prices and help reduce food waste",
100+
onClick = { navController?.navigate(NavMainScreen) }
101+
)
102+
103+
Spacer(modifier = Modifier.weight(1f))
104+
}
105+
}
106+
}
107+
108+
}
109+
110+
@Composable
111+
fun UserTypeCard(
112+
icon: @Composable () -> Unit,
113+
title: String,
114+
description: String,
115+
onClick: () -> Unit
116+
) {
117+
Card(
118+
modifier = Modifier
119+
.fillMaxWidth()
120+
.clickable { onClick() },
121+
shape = RoundedCornerShape(16.dp),
122+
colors = CardDefaults.cardColors(containerColor = Color.White),
123+
elevation = CardDefaults.cardElevation(defaultElevation = 4.dp)
124+
) {
125+
Column(
126+
modifier = Modifier
127+
.fillMaxWidth()
128+
.padding(24.dp),
129+
horizontalAlignment = Alignment.CenterHorizontally
130+
) {
131+
icon()
132+
133+
Spacer(modifier = Modifier.height(16.dp))
134+
135+
Text(
136+
text = title,
137+
fontSize = 20.sp,
138+
fontWeight = FontWeight.SemiBold,
139+
color = Color(0xFF2E2E2E)
140+
)
141+
142+
Spacer(modifier = Modifier.height(8.dp))
143+
144+
Text(
145+
text = description,
146+
fontSize = 14.sp,
147+
color = Color.Gray,
148+
textAlign = TextAlign.Center,
149+
lineHeight = 20.sp
150+
)
151+
}
152+
}
153+
}
154+
155+
@Composable
156+
fun RestaurantIcon() {
157+
Box(
158+
modifier = Modifier
159+
.size(64.dp)
160+
.background(
161+
color = Color(0xFF4CAF50),
162+
shape = CircleShape
163+
),
164+
contentAlignment = Alignment.Center
165+
) {
166+
// Simple restaurant building icon
167+
Column(
168+
horizontalAlignment = Alignment.CenterHorizontally
169+
) {
170+
Icon(
171+
imageVector = Icons.Default.Restaurant, // 🍴 restaurant icon
172+
contentDescription = "Restaurant",
173+
tint = Color.White,
174+
modifier = Modifier.size(40.dp) // adjust size
175+
)
176+
}
177+
}
178+
}
179+
180+
@Composable
181+
fun CustomerIcon() {
182+
Box(
183+
modifier = Modifier
184+
.size(64.dp)
185+
.background(
186+
color = Color(0xFFFF7043),
187+
shape = CircleShape
188+
),
189+
contentAlignment = Alignment.Center
190+
) {
191+
// Simple person icon
192+
Column(
193+
horizontalAlignment = Alignment.CenterHorizontally
194+
) {
195+
// Head
196+
Icon(
197+
imageVector = Icons.Default.Person, // 👈 built-in person icon
198+
contentDescription = "User",
199+
tint = Color.White,
200+
modifier = Modifier.size(40.dp) // adjust size as needed
201+
)
202+
}
203+
}
204+
}
205+
206+
/*
207+
@Preview(showBackground = true, showSystemUi = true)
208+
@Composable
209+
fun ResqFoodUserSelectionScreenPreview() {
210+
MaterialTheme {
211+
ResqFoodUserSelectionScreen()
212+
}
213+
}*/

app/src/main/java/com/project/resqfood/presentation/profilescreens/ProfileScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ val myOrderList = listOf(
102102
onClick = { it.navigate("address_screen") }
103103
),
104104
ProfileItem(vectorImage = Icons.Default.Payments, label = "Payments Methods", onClick = {it.navigate(NavAddingLeftovers)}),
105-
ProfileItem(vectorImage = Icons.Default.Restaurant, label = "Add Restaurant", onClick = {it.navigate(NavListingRestaurant)}),
105+
ProfileItem(vectorImage = Icons.Default.Restaurant, label = "Add Restaurant", onClick = {it.navigate(NavListingRestaurant(entryPoint = "normalFlow"))}),
106106
ProfileItem(vectorImage = Icons.Default.HouseSiding, label = "Add Trusts", onClick = {/*TODO*/}),
107107
ProfileItem(vectorImage = Icons.Default.ShoppingCart, label = "Ordering and Pickup", onClick = {it.navigate(NavOrderingPickup)})
108108
)

app/src/main/java/com/project/resqfood/presentation/restaurantonboarding/ListingRestaurantScreen.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.project.resqfood.presentation.restaurantonboarding
22

3+
import android.annotation.SuppressLint
34
import androidx.compose.animation.AnimatedContent
45
import androidx.compose.animation.AnimatedContentTransitionScope
56
import androidx.compose.animation.core.EaseIn
@@ -48,14 +49,21 @@ import coil.compose.AsyncImage
4849
import com.project.resqfood.R
4950
import kotlinx.serialization.Serializable
5051

52+
/*@Serializable
53+
object NavListingRestaurant*/
54+
55+
56+
@SuppressLint("UnsafeOptInUsageError")
5157
@Serializable
52-
object NavListingRestaurant
58+
data class NavListingRestaurant(val entryPoint: String)
59+
5360

5461

5562
@Composable
5663
fun ListingRestaurantScreen(
5764
restaurantListingViewModel: ListingViewModel,
58-
navController: NavHostController
65+
navController: NavHostController,
66+
entryPoint: String
5967
) {
6068
val scrollState = rememberScrollState()
6169
val data by restaurantListingViewModel.listingData
@@ -125,7 +133,7 @@ fun ListingRestaurantScreen(
125133
)
126134
.padding(12.dp),
127135
isFirst = (uiState == ListingUIState.RESTAURANT_SUCCESS_SCREEN || uiState == ListingUIState.RESTAURANT_DETAILS_SCREEN),
128-
onNext = { restaurantListingViewModel.onNextClick(navController = navController, snackbarHostState = snackbarHostState) }) {
136+
onNext = { restaurantListingViewModel.onNextClick(navController = navController, snackbarHostState = snackbarHostState,entryPoint = entryPoint) }) {
129137
restaurantListingViewModel.onBackClick()
130138
}
131139
Column(

app/src/main/java/com/project/resqfood/presentation/restaurantonboarding/ListingViewModel.kt

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import com.google.firebase.storage.FirebaseStorage
1111
import com.project.resqfood.domain.repository.RestaurantDataRepository
1212
import com.project.resqfood.model.RestaurantEntity
1313
import com.project.resqfood.model.RestaurantType
14+
import com.project.resqfood.presentation.login.Screens.NavMainScreen
15+
import com.project.resqfood.presentation.login.Screens.NavRoleSelectScreen
1416
import com.project.resqfood.presentation.login.emailCheck
1517
import com.project.resqfood.presentation.login.phoneNumberCheck
1618
import kotlinx.coroutines.launch
@@ -25,21 +27,28 @@ class ListingViewModel : ViewModel() {
2527
var isStart = true
2628
private var currentIndex = 0
2729

28-
fun onNextClick(snackbarHostState: SnackbarHostState, navController: NavController) {
29-
isStart = false
30-
if (uiState.value == ListingUIState.RESTAURANT_SUCCESS_SCREEN)
31-
navController.navigateUp()
32-
if (uiState.value == ListingUIState.RESTAURANT_IMAGES_SCREEN)
33-
saveData()
34-
when (currentIndex) {
35-
in 0..(order.size - 3) -> {
36-
if (validateRestaurantDetails(snackbarHostState)) {
37-
currentIndex++
38-
uiState.value = order[currentIndex]
39-
isStart = true
30+
fun onNextClick(snackbarHostState: SnackbarHostState, navController: NavController,entryPoint: String) {
31+
isStart = false
32+
if (uiState.value == ListingUIState.RESTAURANT_SUCCESS_SCREEN)
33+
//navController.navigateUp()
34+
if (entryPoint == "fromRegistration") {
35+
navController.navigate(NavMainScreen) {
36+
popUpTo(NavRoleSelectScreen) { inclusive = true }
37+
}
38+
} else {
39+
navController.navigateUp()
40+
}
41+
if (uiState.value == ListingUIState.RESTAURANT_IMAGES_SCREEN)
42+
saveData()
43+
when (currentIndex) {
44+
in 0..(order.size - 3) -> {
45+
if (validateRestaurantDetails(snackbarHostState)) {
46+
currentIndex++
47+
uiState.value = order[currentIndex]
48+
isStart = true
49+
}
4050
}
4151
}
42-
}
4352
// when(uiState.value){
4453
// ListingUIState.RESTAURANT_DETAILS_SCREEN -> {
4554
// }

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
accompanistPager = "0.12.0"
5-
agp = "8.12.0"
5+
agp = "8.11.1"
66

77

88
annotationPlugin = "1.0.1"

0 commit comments

Comments
 (0)