Created
April 14, 2023 16:42
-
-
Save MohamedGouaouri/3c38c82cb56478451334bc826a965fb5 to your computer and use it in GitHub Desktop.
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
@Composable | |
fun RestaurantScreen( | |
modifier: Modifier = Modifier | |
){ | |
val vm: RestaurantsViewModel = viewModel() | |
var myRestaurants = vm.restaurantsState | |
Scaffold( | |
topBar = { | |
RestaurantSearchBar( | |
modifier = Modifier | |
.fillMaxWidth(), | |
hint = "Search a restaurant" | |
) { | |
myRestaurants = restaurants.search(it) | |
} | |
}, | |
bottomBar = { | |
RestaurantBottomAppBar( | |
modifier = Modifier | |
.fillMaxWidth() | |
.height(50.dp) | |
) | |
}, | |
modifier = modifier.padding(10.dp) | |
) { pv-> | |
Box( | |
modifier = Modifier.padding(pv) | |
) { | |
LazyColumn( | |
verticalArrangement = Arrangement.spacedBy(5.dp), | |
){ | |
items(myRestaurants){ | |
RestaurantItem( | |
modifier = Modifier.fillMaxWidth(), | |
restaurantName = it.title, | |
restaurantDescription = it.description, | |
isFavourite = it.isFavourite, | |
){ | |
vm.toggleIsFavourite(it.id) | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment