package com.example.logi

import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.clickable
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items   // items
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.example.logi.ui.theme.LogiTheme

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            LogiTheme {
                Logi()
            }
        }
    }
}

@Composable
fun Logi() {
    // lista prezentów
    val prezenty = listOf("hulajnoga", "rower", "książka", "smartwatch", "tablet")

    // LazyColumn wyświetla listę prezentów
    LazyColumn() {
        items(prezenty) { item -> // 'item' to element listy
            // Wyświetlanie pojedynczego elementu
            Text(
                text = item,
                modifier = Modifier
                    .clickable {
                        Log.i("==== mój log ======","kliknięto $item")
                    }
            )
        }
    }

}

@Preview(showBackground = true)
@Composable
fun LogiPreview() {
    LogiTheme {
        Logi()
    }
}