import BorderBottomItem from "@/components/borderBottomItem"
import ButtonTab from "@/components/buttonTab"
import InputSearch from "@/components/inputSearch"
import PaperGridContent from "@/components/paperGridContent"
import { ColorsStatus } from "@/constants/ColorsStatus"
import Styles from "@/constants/Styles"
import { AntDesign, Feather, MaterialCommunityIcons, MaterialIcons } 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 ListDivision() {
   const { active } = useLocalSearchParams<{ active?: string }>()
   const [isList, setList] = useState(false)

   return (
      <SafeAreaView>
         <ScrollView>
            <View style={[Styles.p15, Styles.mb100]}>
               <View style={[Styles.wrapBtnTab]}>
                  <ButtonTab
                     active={active == "false" ? "false" : "true"}
                     value="true"
                     onPress={() => { router.push('/division?active=true') }}
                     label="Aktif"
                     icon={<Feather name="check-circle" color={active == "false" ? 'black' : 'white'} size={20} />}
                     n={2} />
                  <ButtonTab
                     active={active == "false" ? "false" : "true"}
                     value="false"
                     onPress={() => { router.push('/division?active=false') }}
                     label="Tidak Aktif"
                     icon={<AntDesign name="closecircleo" color={active == "true" ? 'black' : 'white'} size={20} />}
                     n={2} />
               </View>
               <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>
               <View style={[Styles.mv05]}>
                  <Text>Filter : Dinas</Text>
               </View>
               {
                  isList
                     ?
                     <View>
                        <BorderBottomItem
                           onPress={() => { }}
                           borderType="bottom"
                           icon={
                              <View style={[Styles.iconContent, ColorsStatus.lightGreen]}>
                                 <MaterialIcons name="group" size={25} color={'#384288'} />
                              </View>
                           }
                           title="Kasi Pelayanan"
                           titleWeight="normal"
                        />
                        <BorderBottomItem
                           onPress={() => { }}
                           borderType="bottom"
                           icon={
                              <View style={[Styles.iconContent, ColorsStatus.lightGreen]}>
                                 <MaterialIcons name="group" size={25} color={'#384288'} />
                              </View>
                           }
                           title="Kaur TU dan Umum"
                           titleWeight="normal"
                        />
                        <BorderBottomItem
                           onPress={() => { }}
                           borderType="bottom"
                           icon={
                              <View style={[Styles.iconContent, ColorsStatus.lightGreen]}>
                                 <MaterialIcons name="group" size={25} color={'#384288'} />
                              </View>
                           }
                           title="Kasi Pemerintahan"
                           titleWeight="normal"
                        />
                     </View>
                     :

                     <View>
                        <PaperGridContent onPress={() => { router.push('/division/234') }} content="page" title="Kaur Pelayanan" headerColor="primary" contentPosition="top">
                           <Text style={[Styles.textDefault]}>Deskripsi Divisi</Text>
                        </PaperGridContent>
                        <PaperGridContent onPress={() => { router.push('/division/234') }} content="page" title="Kasi Pemerintahan" headerColor="primary" contentPosition="top">
                           <Text style={[Styles.textDefault]}>Deskripsi Divisi</Text>
                        </PaperGridContent>
                        <PaperGridContent onPress={() => { router.push('/division/234') }} content="page" title="Kaur TU dan Umum" headerColor="primary" contentPosition="top">
                           <Text style={[Styles.textDefault]}>Deskripsi Divisi</Text>
                        </PaperGridContent>
                     </View>
               }


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