Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-opus-4-20250514-thinking-16k· AnthropicHugging Face LMArena Human Preference 140K

Stworz mi aplikacje w react native

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with chatgpt-4o-latest-20250326’s answer.
  1. User

    Stworz mi aplikacje w react native

  2. Claude Assistant

    Chętnie pomogę Ci stworzyć aplikację w React Native! Stworzę dla Ciebie prosty przykład aplikacji z podstawową strukturą.

    Prosta aplikacja To-Do w React Native

    Najpierw upewnij się, że masz zainstalowane:

    • Node.js (wersja 14 lub wyższa)
    • npm lub yarn
    • React Native CLI lub Expo CLI

    Struktura projektu:

    App.js

    import React, { useState } from 'react';
    import {
      SafeAreaView,
      StyleSheet,
      Text,
      View,
      TextInput,
      TouchableOpacity,
      FlatList,
      Alert
    } from 'react-native';
    
    const App = () => {
      const [task, setTask] = useState('');
      const [tasks, setTasks] = useState([]);
    
      const addTask = () => {
        if (task.trim().length === 0) {
          Alert.alert('Błąd', 'Proszę wpisać zadanie');
          return;
        }
    
        const newTask = {
          id: Date.now().toString(),
          text: task,
          completed: false
        };
    
        setTasks([...tasks, newTask]);
        setTask('');
      };
    
      const toggleTask = (id) => {
        setTasks(tasks.map(item => 
          item.id === id ? { ...item, completed: !item.completed } : item
        ));
      };
    
      const deleteTask = (id) => {
        Alert.alert(
          'Usuń zadanie',
          'Czy na pewno chcesz usunąć to zadanie?',
          [
            { text: 'Anuluj', style: 'cancel' },
            { text: 'Usuń', onPress: () => setTasks(tasks.filter(item => item.id !== id)) }
          ]
        );
      };
    
      const renderTask = ({ item }) => (
        <View style={styles.taskContainer}>
          <TouchableOpacity 
            style={styles.taskContent}
            onPress={() => toggleTask(item.id)}
          >
            <Text style={[
              styles.taskText, 
              item.completed && styles.taskCompleted
            ]}>
              {item.text}
            </Text>
          </TouchableOpacity>
          <TouchableOpacity 
            style={styles.deleteButton}
            onPress={() => deleteTask(item.id)}
          >
            <Text style={styles.deleteButtonText}>Usuń</Text>
          </TouchableOpacity>
        </View>
      );
    
      return (
        <SafeAreaView style={styles.container}>
          <View style={styles.header}>
            <Text style={styles.title}>Moja Lista Zadań</Text>
          </View>
    
          <View style={styles.inputContainer}>
            <TextInput
              style={styles.input}
              placeholder="Dodaj nowe zadanie..."
              value={task}
              onChangeText={setTask}
              onSubmitEditing={addTask}
            />
            <TouchableOpacity style={styles.addButton} onPress={addTask}>
              <Text style={styles.addButtonText}>Dodaj</Text>
            </TouchableOpacity>
          </View>
    
          <FlatList
            data={tasks}
            renderItem={renderTask}
            keyExtractor={item => item.id}
            contentContainerStyle={styles.tasksList}
            ListEmptyComponent={
              <Text style={styles.emptyText}>Brak zadań do wyświetlenia</Text>
            }
          />
        </SafeAreaView>
      );
    };
    
    const styles = StyleSheet.create({
      container: {
        flex: 1,
        backgroundColor: '#f5f5f5',
      },
      header: {
        backgroundColor: '#4a90e2',
        padding: 20,
        alignItems: 'center',
      },
      title: {
        fontSize: 24,
        fontWeight: 'bold',
        color: 'white',
      },
      inputContainer: {
        flexDirection: 'row',
        padding: 15,
        backgroundColor: 'white',
        shadowColor: '#000',
        shadowOffset: { width: 0, height: 2 },
        shadowOpacity: 0.1,
        shadowRadius: 3,
        elevation: 3,
      },
      input: {
        flex: 1,
        borderWidth: 1,
        borderColor: '#ddd',
        padding: 10,
        borderRadius: 8,
        fontSize: 16,
        marginRight: 10,
      },
      addButton: {
        backgroundColor: '#4a90e2',
        paddingHorizontal: 20,
        paddingVertical: 10,
        borderRadius: 8,
        justifyContent: 'center',
      },
      addButtonText: {
        color: 'white',
        fontWeight: 'bold',
        fontSize: 16,
      },
      tasksList: {
        padding: 15,
      },
      taskContainer: {
        flexDirection: 'row',
        backgroundColor: 'white',
        padding: 15,
        borderRadius: 8,
        marginBottom: 10,
        shadowColor: '#000',
        shadowOffset: { width: 0, height: 1 },
        shadowOpacity: 0.05,
        shadowRadius: 2,
        elevation: 2,
      },
      taskContent: {
        flex: 1,
      },
      taskText: {
        fontSize: 16,
        color: '#333',
      },
      taskCompleted: {
        textDecorationLine: 'line-through',
        color: '#999',
      },
      deleteButton: {
        paddingHorizontal: 15,
        paddingVertical: 5,
        backgroundColor: '#ff4444',
        borderRadius: 5,
        justifyContent: 'center',
      },
      deleteButtonText: {
        color: 'white',
        fontWeight: 'bold',
      },
      emptyText: {
        textAlign: 'center',
        marginTop: 50,
        fontSize: 16,
        color: '#999',
      },
    });
    
    export default App;
    

    Jak uruchomić aplikację:

    1. Utwórz nowy projekt:
    npx react-native init MojaAplikacja
    cd MojaAplikacja
    
    1. Zastąp zawartość pliku App.js powyższym kodem

    2. Uruchom aplikację:

    Dla iOS:

    npx react-native run-ios
    

    Dla Android:

    npx react-native run-android
    

    Funkcjonalności aplikacji:

    • Dodawanie nowych zadań
    • Oznaczanie zadań jako ukończone (kliknięcie na zadanie)
    • Usuwanie zadań
    • Walidacja pustego pola
    • Przyjazny interfejs użytkownika

    Czy chciałbyś, żebym dodał jakieś konkretne funkcjonalności lub stworzył inny rodzaj aplikacji? Mogę również pokazać Ci jak dodać nawigację między ekranami, połączenie z API lub przechowywanie danych lokalnie.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.