import React from 'react';
import { StyleSheet, Text, View, TextInput, Button, Alert } from 'react-native';

export default function App() {
  const [name, setName] = React.useState('');
  const [greeting, setGreeting] = React.useState('');
  const apiKey="12345-ABCDE";

  const handleGreet = () => {
    if (name.trim()) {
      setGreeting(`Cześć, ${name}! Witaj w aplikacji Expo!`);
    } else {
      Alert.alert('Proszę podać swoje imię');
    }
  };

  return (
    <View style={styles.container}>
      <Text style={styles.title}>Witaj w Mojej Aplikacji Expo!</Text>
      <TextInput
        style={styles.input}
        placeholder={`Hasło: "${apiKey}"`}
        value={name}
        onChangeText={setName}
      />
      <Button title="Przywitaj mnie" onPress={handleGreet} />
      {greeting ? <Text style={styles.greeting}>{greeting}</Text> : null}
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#f5f5f5',
    padding: 20,
  },
  title: {
    fontSize: 24,
    fontWeight: 'bold',
    marginBottom: 20,
  },
  input: {
    height: 40,
    borderColor: '#ccc',
    borderWidth: 1,
    borderRadius: 5,
    paddingHorizontal: 10,
    marginBottom: 10,
    width: '100%',
  },
  greeting: {
    marginTop: 20,
    fontSize: 18,
    color: '#333',
  },
});
