Skip to content

Instantly share code, notes, and snippets.

@MohamedGouaouri
Created April 14, 2023 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MohamedGouaouri/3c38c82cb56478451334bc826a965fb5 to your computer and use it in GitHub Desktop.
Save MohamedGouaouri/3c38c82cb56478451334bc826a965fb5 to your computer and use it in GitHub Desktop.
@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