Skip to content

Instantly share code, notes, and snippets.

View MohamedGouaouri's full-sized avatar
:octocat:
learning

MohamedGouaouri

:octocat:
learning
View GitHub Profile
@MohamedGouaouri
MohamedGouaouri / MainActivity.kt
Last active April 14, 2023 17:35
MainActivity for Flowers App
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
LearnTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background
) {
@Composable
fun RestaurantScreen(
modifier: Modifier = Modifier
){
val vm: RestaurantsViewModel = viewModel()
var myRestaurants = vm.restaurantsState
class RestaurantsViewModel: ViewModel() {
private val _restaurantsState by mutableStateOf(
restaurants
)
val restaurantsState = _restaurantsState
fun toggleIsFavourite(
rid: Int,
) {
fun MutableList<Restaurant>.search(
query: String
): MutableList<Restaurant>{
val result = mutableListOf<Restaurant>()
this.forEach {restaurant ->
if (restaurant.title.contains(query, ignoreCase = true) || restaurant.description.contains(query, ignoreCase = true)){
result.add(restaurant)
}
}
return result
@Composable
fun RestaurantSearchBar(
modifier: Modifier = Modifier,
hint: String = "Search",
onSearch: (String) -> Unit = {}
) {
// 1. text field state
var text by remember {
mutableStateOf("")
}
@Composable
fun <T> T.useDebounce(
delayMillis: Long = 300L,
// 1. couroutine scope
coroutineScope: CoroutineScope = rememberCoroutineScope(),
onChange: (T) -> Unit
): T{
// 2. updating state
val state by rememberUpdatedState(this)

Users API

1. Get User Information

  • Endpoint: GET /users/{userId}
  • Description: Retrieve information about a specific user.
  • Parameters:
    • userId (path parameter) - ID of the user to retrieve.
  • Response:
@MohamedGouaouri
MohamedGouaouri / docker-hands-on.md
Last active March 14, 2024 11:28
Docker hands-on

Docker Hands-on

Inspired by Tutorial

Part 1. Containers

  1. Check that docker is correctly running and that you have permission to use

Blog app guided practice

Main Features of the Static Blog App:

  1. Blog Post List: Display a list of blog posts.
  2. Blog Post Detail View: Show details for a selected blog post.
  3. Search Functionality: Use hardcoded search functionality (no actual dynamic search or filtering).
  4. Static Styling: Use CSS Modules for styling.

Step-by-Step Guide to Build the Static Blog App