import React from "react";
import {
  View,
  Text,
  StyleSheet,
  TouchableOpacity,
  Image,
  ScrollView,
} from "react-native";
import { Ionicons } from "@expo/vector-icons";

const pengaduanData = {
  id: 1,
  judul: "Sampah Menumpuk di Jalan Raya",
  alamat: "Jl. Raya No. 25, Desa Suka Maju, Nganjuk",
  catatan: "Mohon segera dibersihkan, sudah terlalu lama menumpuk.",
  tanggal: "2025-04-28",
  status: "Sedang Diproses", // Bisa diganti dengan 'Sedang Diverifikasi', 'Ditolak', dll.
  pelapor: {
    nama: "Dina",
    profilGambar:
      "https://imgv3.fotor.com/images/gallery/a-woman-linkedin-picture-with-grey-background-made-by-LinkedIn-Profile-Picture-Maker.jpg", // Gambar profil pelapor
  },
  gambarSampah: [
    "https://majanews.com/wp-content/uploads/2022/07/0_20220718_193954.jpg", // Image 1
    "https://newvision-media.s3.amazonaws.com/cms/d2d008c8-1703-4c3e-8b34-3181fc5eda5d.jpg", // Image 2// Image 3
    // "https://newvision-media.s3.amazonaws.com/cms/d2d008c8-1703-4c3e-8b34-3181fc5eda5d.jpg", // Image 2// Image 3
    // "https://newvision-media.s3.amazonaws.com/cms/d2d008c8-1703-4c3e-8b34-3181fc5eda5d.jpg", // Image 2// Image 3
    "https://newvision-media.s3.amazonaws.com/cms/d2d008c8-1703-4c3e-8b34-3181fc5eda5d.jpg", // Image 2// Image 3
  ],
};

const PengaduanScreen = ({ navigation }) => {
  return (
    <View style={styles.container}>
      {/* Judul Pengaduan */}
      <Text style={styles.title}>PENGADUAN</Text>

      {/* Tombol Kembali */}
      <TouchableOpacity
        style={styles.backButton}
        onPress={() => navigation.goBack()}
      >
        <Ionicons name="arrow-back" size={28} color="#2D572C" />
      </TouchableOpacity>

      {/* Container Pengaduan */}
      <ScrollView style={styles.pengaduanContainer}>
        <View style={styles.pelaporContainer}>
          <Image
            source={{ uri: pengaduanData.pelapor.profilGambar }}
            style={styles.pelaporImage}
          />
          <Text style={styles.pelaporNama}>{pengaduanData.pelapor.nama}</Text>
        </View>

        <View style={styles.pengaduanBox}>
          <Text style={styles.pengaduanJudul}>{pengaduanData.judul}</Text>
          <Text style={styles.pengaduanAlamat}>{pengaduanData.alamat}</Text>
          <Text style={styles.pengaduanCatatan}>{pengaduanData.catatan}</Text>
          <Text style={styles.pengaduanTanggal}>
            Tanggal: {pengaduanData.tanggal}
          </Text>

          {/* Gambar Sampah - Row Layout */}
          <View style={styles.rowContainer}>
            {pengaduanData.gambarSampah.map((image, index) => (
              <Image
                key={index}
                source={{ uri: image }}
                style={styles.sampahImage}
              />
            ))}
          </View>

          {/* Profil Pelapor */}

          {/* Status Pengaduan */}
          <View style={styles.statusContainer}>
            <TouchableOpacity style={styles.kontribusiButton}>
              <Text style={styles.kontribusiText}>Kontribusi</Text>
            </TouchableOpacity>
            {/* Jika Status Sedang Diproses */}
            {pengaduanData.status === "Sedang Diproses" && (
              <Text style={styles.koinText}>Dapatkan Koin 300</Text>
            )}
          </View>
        </View>
      </ScrollView>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 16,
    backgroundColor: "#fff",
  },
  title: {
    fontSize: 22,
    fontWeight: "bold",
    color: "#000",
    marginBottom: 16,
    marginTop: 16, // Reduced margin to bring title closer
    textAlign: "left",
    marginLeft: 35,
  },
  backButton: {
    marginBottom: 20,
    marginTop: 10, // Space between back button and title
    position: "absolute", // Positioning it at the top-left
    top: 20,
    left: 10,
    zIndex: 1,
  },
  pengaduanContainer: {
    flex: 1,
  },
  pengaduanBox: {
    padding: 16,
    backgroundColor: "#fff",
    borderRadius: 8,
    marginBottom: 20,
    shadowColor: "#000",
    shadowOpacity: 0.1,
    shadowRadius: 5,
    elevation: 3,
    marginTop: 20,
  },
  pengaduanJudul: {
    fontSize: 18,
    fontWeight: "bold",
    color: "#333",
  },
  pengaduanAlamat: {
    marginTop: 8,
    fontSize: 14,
    color: "#555",
  },
  pengaduanCatatan: {
    marginTop: 8,
    fontSize: 14,
    color: "#555",
  },
  pengaduanTanggal: {
    marginTop: 8,
    fontSize: 14,
    color: "#777",
  },
  buktiImage: {
    marginTop: 16,
    width: "100%",
    height: 150,
    borderRadius: 8,
  },
  rowContainer: {
    flexDirection: "row",
    justifyContent: "space-between",
    marginTop: 26,
    marginTop: 16,
    width: "70%",
    height: 80,
    borderRadius: 8,
  },
  sampahImage: {
    width: 80,
    height: 80,
    borderRadius: 8,
  },
  pelaporContainer: {
    flexDirection: "row",
    alignItems: "center",
    marginTop: 16,
    marginLeft: 20,
  },
  pelaporImage: {
    width: 50,
    height: 50,
    borderRadius: 20,
  },
  pelaporNama: {
    marginLeft: 12,
    fontSize: 14,
    fontWeight: "bold",
    color: "#333",
  },
  statusContainer: {
    marginTop: 16,
    alignItems: "center",
  },
  statusText: {
    fontSize: 16,
    fontWeight: "bold",
    color: "#FF6F61", // Bisa diganti dengan warna yang sesuai status
  },
  kontribusiButton: {
    marginTop: 12,
    backgroundColor: "#2D572C",
    paddingVertical: 10,
    paddingHorizontal: 20,
    borderRadius: 8,
  },
  kontribusiText: {
    color: "#fff",
    fontWeight: "bold",
  },
  koinText: {
    marginTop: 8,
    fontSize: 12,
    color: "#555",
  },
});

export default PengaduanScreen;
