-
Notifications
You must be signed in to change notification settings - Fork 1
Closes #12 #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Closes #12 #20
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
9 changes: 0 additions & 9 deletions
9
app/src/main/java/com/uniandes/ecobites/ui/screens/HomeScreen.kt
This file was deleted.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
app/src/main/java/com/uniandes/ecobites/ui/screens/home/Carousel.kt
This file contains hidden or 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,47 @@ | ||
| import androidx.compose.foundation.Image | ||
| import androidx.compose.foundation.layout.PaddingValues | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.height | ||
| import androidx.compose.material3.ExperimentalMaterial3Api | ||
| import androidx.compose.material3.MaterialTheme | ||
| import androidx.compose.material3.carousel.HorizontalMultiBrowseCarousel | ||
| import androidx.compose.material3.carousel.rememberCarouselState | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.layout.ContentScale | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.unit.dp | ||
| import com.uniandes.ecobites.R | ||
|
|
||
| @ExperimentalMaterial3Api | ||
| @Composable | ||
| fun OfferCarousel() { | ||
| // List of images to be shown in the carousel | ||
| val items = listOf( | ||
| R.drawable.percent, | ||
| R.drawable.free_delivery, | ||
| R.drawable.two_for_one, | ||
| R.drawable.fiftyoff | ||
| ) | ||
|
|
||
| // Remember Carousel State | ||
| val carouselState = rememberCarouselState { items.size } | ||
ma-r-s marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Carousel implementation using Hero Strategy | ||
| HorizontalMultiBrowseCarousel( | ||
| state = rememberCarouselState { items.count() }, | ||
| modifier = Modifier.height(250.dp).fillMaxWidth(), | ||
| preferredItemWidth = 250.dp, | ||
| itemSpacing = 8.dp, | ||
| // contentPadding = PaddingValues(horizontal = 40.dp) | ||
| ) { index -> | ||
| // Content of each carousel item | ||
| Image( | ||
| painter = painterResource(id = items[index]), | ||
| contentDescription = "Carousel Image", | ||
| contentScale = ContentScale.Crop, | ||
| modifier = Modifier | ||
| .height(300.dp).maskClip(MaterialTheme.shapes.extraLarge) | ||
| ) | ||
| } | ||
ma-r-s marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
62 changes: 62 additions & 0 deletions
62
app/src/main/java/com/uniandes/ecobites/ui/screens/home/CategoriesRow.kt
This file contains hidden or 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,62 @@ | ||
| import androidx.compose.foundation.layout.* | ||
| import androidx.compose.material.icons.Icons | ||
| import androidx.compose.material.icons.rounded.Check | ||
| import androidx.compose.material.icons.rounded.Edit | ||
| import androidx.compose.material.icons.rounded.Home | ||
| import androidx.compose.material.icons.rounded.ShoppingCart | ||
| import androidx.compose.material.icons.rounded.Star | ||
| import androidx.compose.material3.* | ||
| import androidx.compose.runtime.* | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.graphics.vector.ImageVector | ||
| import androidx.compose.ui.text.style.TextOverflow | ||
| import androidx.compose.ui.unit.dp | ||
|
|
||
| // Categories for the Tabs with Icons from Material Icons | ||
| data class Category(val name: String, val icon: ImageVector) | ||
|
|
||
| val categories = listOf( | ||
| Category("Restaurant", Icons.Rounded.Home), | ||
| Category("Ingredients", Icons.Rounded.Edit), | ||
| Category("Store", Icons.Rounded.ShoppingCart), | ||
| Category("Diet", Icons.Rounded.Check) | ||
| ) | ||
|
|
||
| @OptIn(ExperimentalMaterial3Api::class) | ||
| @Composable | ||
| fun CategoriesRow() { | ||
| var selectedTabIndex by remember { mutableStateOf(0) } | ||
|
|
||
| ScrollableTabRow( | ||
| selectedTabIndex = selectedTabIndex, | ||
| modifier = Modifier.fillMaxWidth(), | ||
| containerColor = MaterialTheme.colorScheme.surface, | ||
| contentColor = MaterialTheme.colorScheme.onSurface, | ||
| edgePadding = 16.dp // Optional padding at the edges | ||
| ) { | ||
| categories.forEachIndexed { index, category -> | ||
| Tab( | ||
| selected = selectedTabIndex == index, | ||
| onClick = { selectedTabIndex = index }, | ||
| text = { | ||
| // Row to place the icon and text horizontally | ||
| Row( | ||
| verticalAlignment = androidx.compose.ui.Alignment.CenterVertically | ||
| ) { | ||
| Icon( | ||
| imageVector = category.icon, | ||
| contentDescription = "${category.name} Icon", | ||
| modifier = Modifier.size(20.dp) | ||
| ) | ||
| Spacer(modifier = Modifier.width(8.dp)) // Space between icon and text | ||
| Text( | ||
| text = category.name, | ||
| maxLines = 1, | ||
| overflow = TextOverflow.Ellipsis | ||
| ) | ||
| } | ||
| } | ||
| ) | ||
| } | ||
| } | ||
| } |
42 changes: 42 additions & 0 deletions
42
app/src/main/java/com/uniandes/ecobites/ui/screens/home/HomeScreen.kt
This file contains hidden or 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,42 @@ | ||
| package com.uniandes.ecobites.ui.screens.home | ||
|
|
||
| import StoresGrid | ||
| import CategoriesRow | ||
| import OfferCarousel | ||
| import androidx.compose.foundation.layout.* | ||
| import androidx.compose.foundation.rememberScrollState | ||
| import androidx.compose.foundation.verticalScroll | ||
| import androidx.compose.material3.ExperimentalMaterial3Api | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.unit.dp | ||
|
|
||
LuimarcoCarrascalDiaz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| @OptIn(ExperimentalMaterial3Api::class) | ||
| @Composable | ||
| fun HomeScreen() { | ||
| Column( | ||
| modifier = Modifier | ||
| .fillMaxSize() | ||
| .verticalScroll(rememberScrollState()) | ||
| .padding(16.dp) | ||
| ) { | ||
| // Top Location and Search Bar Section | ||
| TopSection() | ||
|
|
||
| Spacer(modifier = Modifier.height(16.dp)) | ||
|
|
||
| // Offer Carousel Section | ||
| OfferCarousel() | ||
|
|
||
| Spacer(modifier = Modifier.height(16.dp)) | ||
|
|
||
| // Categories Filter Section | ||
| CategoriesRow() | ||
|
|
||
| Spacer(modifier = Modifier.height(16.dp)) | ||
|
|
||
| // Stores/Restaurants Grid Section | ||
| StoresGrid() | ||
| } | ||
| } | ||
77 changes: 77 additions & 0 deletions
77
app/src/main/java/com/uniandes/ecobites/ui/screens/home/StoresGrid.kt
This file contains hidden or 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,77 @@ | ||
| import androidx.compose.foundation.Image | ||
| import androidx.compose.foundation.layout.* | ||
| import androidx.compose.foundation.shape.RoundedCornerShape | ||
| import androidx.compose.material3.* | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.draw.clip | ||
| import androidx.compose.ui.layout.ContentScale | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.compose.ui.Alignment | ||
| import com.uniandes.ecobites.R | ||
|
|
||
| // Data class representing a store | ||
| data class Store(val name: String, val imageResId: Int) | ||
|
|
||
| // List of stores with their images | ||
| val stores = listOf( | ||
| Store("Éxito", R.drawable.exito), | ||
| Store("Hornitos", R.drawable.hornitos), | ||
| Store("McDonalds", R.drawable.mc_donalds), | ||
| Store("Dunkin Donuts", R.drawable.dunkin_donuts), | ||
| Store("Pan Pa' Ya!", R.drawable.pan_pa_ya) | ||
| ) | ||
|
|
||
| @Composable | ||
| fun StoresGrid() { | ||
| Column( | ||
| modifier = Modifier.fillMaxWidth(), | ||
| verticalArrangement = Arrangement.spacedBy(16.dp), | ||
| horizontalAlignment = Alignment.CenterHorizontally | ||
| ) { | ||
| // First row with 2 items | ||
| Row( | ||
| horizontalArrangement = Arrangement.spacedBy(16.dp), | ||
| modifier = Modifier.fillMaxWidth() | ||
| ) { | ||
| stores.take(2).forEach { store -> | ||
| StoreItem(store = store, modifier = Modifier.weight(1f)) | ||
| } | ||
| } | ||
|
|
||
| // Second row with 3 items | ||
| Row( | ||
| horizontalArrangement = Arrangement.spacedBy(16.dp), | ||
| modifier = Modifier.fillMaxWidth() | ||
| ) { | ||
| stores.drop(2).take(3).forEach { store -> | ||
| StoreItem(store = store, modifier = Modifier.weight(1f)) | ||
| } | ||
| } | ||
| } | ||
| } | ||
ma-r-s marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| @Composable | ||
| fun StoreItem(store: Store, modifier: Modifier = Modifier) { | ||
| Column( | ||
| horizontalAlignment = Alignment.CenterHorizontally, | ||
| modifier = modifier | ||
| ) { | ||
| // Display the store image | ||
| Image( | ||
| painter = painterResource(id = store.imageResId), | ||
| contentDescription = store.name, | ||
| contentScale = ContentScale.Crop, | ||
| modifier = Modifier | ||
| .size(150.dp).clip(MaterialTheme.shapes.extraLarge) // Rounded corners for the image | ||
| ) | ||
| Spacer(modifier = Modifier.height(8.dp)) | ||
|
|
||
| // Display the store name below the image | ||
| Text( | ||
| text = store.name, | ||
| style = MaterialTheme.typography.bodyMedium | ||
| ) | ||
| } | ||
| } | ||
LuimarcoCarrascalDiaz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
71 changes: 71 additions & 0 deletions
71
app/src/main/java/com/uniandes/ecobites/ui/screens/home/TopSection.kt
This file contains hidden or 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,71 @@ | ||
| package com.uniandes.ecobites.ui.screens.home | ||
|
|
||
| import androidx.compose.foundation.layout.* | ||
| import androidx.compose.material.icons.Icons | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.material.icons.outlined.LocationOn | ||
| import androidx.compose.material.icons.outlined.Search | ||
| import androidx.compose.material.icons.outlined.Close | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.compose.ui.graphics.Color | ||
| import androidx.compose.material3.* | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.runtime.setValue | ||
| import androidx.compose.runtime.remember | ||
| import androidx.compose.runtime.mutableStateOf | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
|
|
||
| // Top Section with Location and Search Bar | ||
| @Preview(showBackground = true) | ||
| @OptIn(ExperimentalMaterial3Api::class) | ||
| @Composable | ||
| fun TopSection() { | ||
| var query by remember { mutableStateOf("") } | ||
| var isActive by remember { mutableStateOf(false) } | ||
|
|
||
| Column( | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .padding(8.dp), | ||
| horizontalAlignment = Alignment.CenterHorizontally | ||
| ) { | ||
| // Location Row | ||
| Row( | ||
| verticalAlignment = Alignment.CenterVertically, | ||
| modifier = Modifier | ||
| ) { | ||
| Icon(Icons.Outlined.LocationOn, contentDescription = "Location", tint = Color.Gray) | ||
| Spacer(modifier = Modifier.width(8.dp)) | ||
| Text(text = "Calle 13 #10-22", style = MaterialTheme.typography.bodyMedium) | ||
| } | ||
| Spacer(modifier = Modifier.height(8.dp)) | ||
|
|
||
| // Material 3 Search Bar with Size Constraint | ||
| SearchBar( | ||
| query = query, | ||
| onQueryChange = { query = it }, | ||
| onSearch = { | ||
| // Handle search logic | ||
| }, | ||
| active = isActive, | ||
| onActiveChange = { isActive = it }, | ||
| placeholder = { Text("Search deals...") }, | ||
| leadingIcon = { Icon(Icons.Outlined.Search, contentDescription = "Search Icon") }, | ||
| trailingIcon = { | ||
| if (query.isNotEmpty()) { | ||
| IconButton(onClick = { query = "" }) { | ||
| Icon(Icons.Outlined.Close, contentDescription = "Clear") | ||
| } | ||
| } | ||
| }, | ||
| modifier = Modifier | ||
| .fillMaxWidth() // Ensure it fills the parent width properly | ||
| .heightIn(min = 56.dp, max = 72.dp) // Control the min and max height | ||
| .padding(horizontal = 8.dp) // Add some padding | ||
| ) { | ||
| // You can provide additional content here if needed | ||
| } | ||
| } | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.