import BorderBottomItem from "@/components/borderBottomItem";
import ButtonTab from "@/components/buttonTab";
import InputSearch from "@/components/inputSearch";
import LabelStatus from "@/components/labelStatus";
import PaperGridContent from "@/components/paperGridContent";
import ProgressBar from "@/components/progressBar";
import { ColorsStatus } from "@/constants/ColorsStatus";
import Styles from "@/constants/Styles";
import { AntDesign, Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
import { router, useLocalSearchParams } from "expo-router";
import { useState } from "react";
import { Pressable, SafeAreaView, ScrollView, Text, View } from "react-native";

export default function ListTask() {
   const { status } = useLocalSearchParams<{ status: string }>()
   const [isList, setList] = useState(false)

   return (
      <SafeAreaView>
         <ScrollView>
            <View style={[Styles.p15, Styles.mb100]}>
               <ScrollView horizontal style={[Styles.mb10]}>
                  <ButtonTab
                     active={status}
                     value="0"
                     onPress={() => { router.push('./task?status=0') }}
                     label="Segera"
                     icon={<MaterialCommunityIcons name="clock-alert-outline" color={status == "0" ? 'white' : 'black'} size={20} />}
                     n={4} />
                  <ButtonTab
                     active={status}
                     value="1"
                     onPress={() => { router.push('./task?status=1') }}
                     label="Dikerjakan"
                     icon={<MaterialCommunityIcons name="progress-check" color={status == "1" ? 'white' : 'black'} size={20} />}
                     n={4} />
                  <ButtonTab
                     active={status}
                     value="2"
                     onPress={() => { router.push('./task?status=2') }}
                     label="Selesai"
                     icon={<Ionicons name="checkmark-done-circle-outline" color={status == "2" ? 'white' : 'black'} size={20} />}
                     n={4} />
                  <ButtonTab
                     active={status}
                     value="3"
                     onPress={() => { router.push('./task?status=3') }}
                     label="Batal"
                     icon={<AntDesign name="closecircleo" color={status == "3" ? 'white' : 'black'} size={20} />}
                     n={4} />
               </ScrollView>
               <View style={[Styles.rowSpaceBetween]}>
                  <InputSearch width={68} />
                  <Pressable onPress={() => { setList(!isList) }}>
                     <MaterialCommunityIcons name={isList ? 'format-list-bulleted' : 'view-grid'} color={"black"} size={30} />
                  </Pressable>
               </View>
               {
                  isList
                     ?
                     <View>
                        <BorderBottomItem
                           onPress={() => { }}
                           borderType="bottom"
                           icon={
                              <View style={[Styles.iconContent, ColorsStatus.lightGreen]}>
                                 <AntDesign name="areachart" size={25} color={'#384288'} />
                              </View>
                           }
                           title="Pembangunan Jembatan"
                        />
                        <BorderBottomItem
                           onPress={() => { }}
                           borderType="bottom"
                           icon={
                              <View style={[Styles.iconContent, ColorsStatus.lightGreen]}>
                                 <AntDesign name="areachart" size={25} color={'#384288'} />
                              </View>
                           }
                           title="Pembangunan Jembatan"
                        />
                        <BorderBottomItem
                           onPress={() => { }}
                           borderType="bottom"
                           icon={
                              <View style={[Styles.iconContent, ColorsStatus.lightGreen]}>
                                 <AntDesign name="areachart" size={25} color={'#384288'} />
                              </View>
                           }
                           title="Pembangunan Jembatan"
                        />
                        <BorderBottomItem
                           onPress={() => { }}
                           borderType="bottom"
                           icon={
                              <View style={[Styles.iconContent, ColorsStatus.lightGreen]}>
                                 <AntDesign name="areachart" size={25} color={'#384288'} />
                              </View>
                           }
                           title="Pembangunan Jembatan"
                        />
                     </View>
                     :

                     <View>
                        <PaperGridContent onPress={() => { router.push('./task/321') }} content="page" title="Pembangunan Jembatan" headerColor="primary">
                           <ProgressBar value={0}/>
                           <View style={[Styles.rowSpaceBetween]}>
                              <Text style={[Styles.textDefault, Styles.cGray]}>13 Februari 2025</Text>
                              <LabelStatus size="default" category="primary" text="SEGERA" />
                           </View>
                        </PaperGridContent>
                        <PaperGridContent content="page" title="Pembangunan Jembatan" headerColor="primary">
                           <ProgressBar value={0}/>
                           <View style={[Styles.rowSpaceBetween]}>
                              <Text style={[Styles.textDefault, Styles.cGray]}>13 Februari 2025</Text>
                              <LabelStatus size="default" category="primary" text="SEGERA" />
                           </View>
                        </PaperGridContent>
                        <PaperGridContent content="page" title="Pembangunan Jembatan" headerColor="primary">
                           <ProgressBar value={0}/>
                           <View style={[Styles.rowSpaceBetween]}>
                              <Text style={[Styles.textDefault, Styles.cGray]}>13 Februari 2025</Text>
                              <LabelStatus size="default" category="primary" text="SEGERA" />
                           </View>
                        </PaperGridContent>
                     </View>

               }
            </View>
         </ScrollView>
      </SafeAreaView>
   )
}