import React, { useState } from "react"; import { View, Text, StyleSheet, TouchableOpacity, Image, ScrollView, Alert, ToastAndroid, } from "react-native"; import { Ionicons } from "@expo/vector-icons"; import { useNavigation } from "@react-navigation/native"; const PosterEdukasiScreen = () => { const navigation = useNavigation(); // State untuk menyimpan daftar poster const [posters, setPosters] = useState([ { id: 1, image: require("../../assets/images/poster1.png") }, { id: 2, image: require("../../assets/images/poster2.png") }, // Tambah poster kedua { id: 2, image: require("../../assets/images/poster3.png") }, // Tambah poster kedua // Tambahkan poster lainnya sesuai kebutuhan ]); // Handle add poster action const handleAddPoster = () => { navigation.navigate("AddPosterScreen"); }; // Fungsi untuk menghapus poster const handleDeletePoster = (posterId) => { Alert.alert( "Hapus Poster", "Apakah Anda yakin ingin menghapus poster ini?", [ { text: "Batal", style: "cancel", }, { text: "Hapus", onPress: () => { // Hapus poster berdasarkan ID const updatedPosters = posters.filter( (poster) => poster.id !== posterId ); setPosters(updatedPosters); ToastAndroid.show("Poster telah dihapus", ToastAndroid.SHORT); }, }, ] ); }; return ( {/* Header */} navigation.goBack()} > POSTER EDUKASI {/* Daftar Poster */} {posters.map((poster) => ( handleDeletePoster(poster.id)}> {/* Tombol Hapus Poster */} handleDeletePoster(poster.id)} > ))} {/* Add Poster Button */} Tambah Poster ); }; const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: "#FFF", padding: 16, }, header: { marginTop: 40, flexDirection: "row", alignItems: "center", marginBottom: 20, }, backButton: { marginRight: 12, }, title: { fontSize: 22, fontWeight: "bold", color: "#000", }, posterList: { marginBottom: 20, }, posterItem: { position: "relative", marginBottom: 15, }, posterImage: { width: "100%", height: 250, resizeMode: "contain", borderRadius: 8, }, deleteIcon: { position: "absolute", top: 10, right: 10, backgroundColor: "red", padding: 6, borderRadius: 16, }, addPosterContainer: { marginTop: 20, alignItems: "center", marginBottom: 50, }, addButton: { backgroundColor: "#2D572C", paddingVertical: 12, paddingHorizontal: 32, borderRadius: 8, flexDirection: "row", justifyContent: "center", alignItems: "center", }, addButtonText: { color: "#FFF", fontWeight: "bold", marginLeft: 8, }, }); export default PosterEdukasiScreen;