package com.example.zadaniekwiaciarnia;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import java.util.ArrayList;

public class GotoweWiazanki extends AppCompatActivity {
ListView lista;
String element="";
Button powrot;
    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_gotowe_wiazanki);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.wiazankiMain), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
        lista = findViewById(R.id.lista);
        powrot = findViewById(R.id.btnPowrot);

        ArrayList<String> bukiety = new ArrayList<>();
        bukiety.add("Bukiet róż - 520zł");
        bukiety.add("Bukiet tulipanow - 170zł");
        bukiety.add("Bukiet mieszany - 180zł");
        bukiety.add("Bukiet wiosenny - 100zł");
        ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(this, R.layout.list_item,R.id.textView1,bukiety);
        lista.setAdapter(arrayAdapter);
        lista.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                element = (String) lista.getItemAtPosition(i);
                Toast.makeText(GotoweWiazanki.this,"Wybrano bukiet: "+element,Toast.LENGTH_SHORT).show();
            }
        });

        powrot.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getApplicationContext(), MainActivity.class);
                startActivity(intent);
                finish();
            }
        });
    }


}
